MetaMask / eth-token-tracker

A JS module for tracking Ethereum token balances over block changes
ISC License
76 stars 43 forks source link

Randomly wrong order of magnitude in balance tests #135

Open legobeat opened 1 month ago

legobeat commented 1 month ago

This occurs randomly in CI, and has been for some time. I can not say I'm sure this was ever not happening:

# HumanStandardToken balance changes are emitted
eth_call
eth_call
eth_call
eth_blockNumber
eth_call
not ok 11 initial balance loaded from last test
  ---
    operator: equal
    expected: '8.9'
    actual:   '890'
    at: TokenTracker.<anonymous> (/home/runner/work/eth-token-tracker/eth-token-tracker/test/integration/human-standard-token.js:143:16)
    stack: |-
      Error: initial balance loaded from last test
          at Test.assert [as _assert] (/home/runner/work/eth-token-tracker/eth-token-tracker/node_modules/tape/lib/test.js:312:48)
          at Test.bound [as _assert] (/home/runner/work/eth-token-tracker/eth-token-tracker/node_modules/tape/lib/test.js:95:17)
          at Test.strictEqual (/home/runner/work/eth-token-tracker/eth-token-tracker/node_modules/tape/lib/test.js:476:7)
          at Test.bound [as equal] (/home/runner/work/eth-token-tracker/eth-token-tracker/node_modules/tape/lib/test.js:95:17)
          at TokenTracker.<anonymous> (/home/runner/work/eth-token-tracker/eth-token-tracker/test/integration/human-standard-token.js:143:16)
          at safeApply (/home/runner/work/eth-token-tracker/eth-token-tracker/node_modules/@metamask/safe-event-emitter/index.js:6:17)
          at TokenTracker.emit (/home/runner/work/eth-token-tracker/eth-token-tracker/node_modules/@metamask/safe-event-emitter/index.js:54:13)
          at TokenTracker._update (/home/runner/work/eth-token-tracker/eth-token-tracker/lib/index.js:106:10)
          at TokenTracker.updateBalances (/home/runner/work/eth-token-tracker/eth-token-tracker/lib/index.js:62:12)
  ...

As can be seen in that CI run, the same test that fail in the Node.js 18 run passes on both 16 and 20. If retried, it will usually pass. Not currently clear if this is an actual bug or just an issue with the test setup.

Related

mcmire commented 1 month ago

Interesting. Well, this is not surprising to me. The tests in this repo have not been audited, so there is a chance that they are not written well or are not doing the right thing.