poanetwork / token-wizard

(Discontinued) TokenWizard is an DApp to create and manage crowdsale and token contracts using a simple UI
MIT License
384 stars 215 forks source link

(Bug) function processReservedTokens: return after first invalid value #1068

Closed dennis00010011b closed 6 years ago

dennis00010011b commented 6 years ago

Problem: function src/utils/processReservedTokens returns after first invalid value of rows

Test below is failed after first row. Last row(with valid value) will never be called

 it('should ignore invalid numbers', () => {
    // Given
    const rows = [
      ['0x1111111111111111111111111111111111111111', 'tokens', 'foo'],
      ['0x2222222222222222222222222222222222222222', 'tokens', ''],
      ['0x2222222222222222222222222222222222222222', 'percentage', 'bar'],
      ['0x3333333333333333333333333333333333333333', 'percentage', ''],
      ['0x2589bd7D8A58Ac9A4aC01d68A7c63315ef184c63', 'tokens', '10'] //valid parameters
    ]
    const cb = jest.fn()

    // When
    const { called } = processReservedTokens({ rows, decimals: 2 }, cb)

    // Then
    expect(called).toBe(1)
  })

Solution: change break to continue

https://github.com/poanetwork/token-wizard/blob/5a95d7de126a8fa16e4a2bb8661c6452e2be5f0b/src/utils/processReservedTokens.js#L47 https://github.com/poanetwork/token-wizard/blob/5a95d7de126a8fa16e4a2bb8661c6452e2be5f0b/src/utils/processReservedTokens.js#L51