What does this pull request do? Explain your changes. (required)
The expect.to.emit accepts any kind of tx state as argument - tx promise, resolved tx, or even tx hash. Internally it actually waits for the tx to resolve if not already resolved and uses the transaction hash to check for events (also eliminating the need to do tx.wait after the event check).
The tests were updated to follow the same common pattern except in cases where the tx receipt is needed to get additional data like "cumulativeGasUsed" like PoolUpdatesWithHints test case and PollCreator test case the transaction is resolved first, the tx receipt is extracted from the tx and then tx.hash is passed to the emit assertion.
What does this pull request do? Explain your changes. (required)
The
expect.to.emit
accepts any kind of tx state as argument - tx promise, resolved tx, or even tx hash. Internally it actually waits for the tx to resolve if not already resolved and uses the transaction hash to check for events (also eliminating the need to do tx.wait after the event check).In the official waffle docs and also in it's own test suite the following pattern is used.
await
is used withemit()
as it uses promises inside itself. For https://github.com/livepeer/protocol/pull/475#discussion_r710460706 I guess it is now okay to say that the issue was caused due to missingawait
before expectother test suites in projects like uniswap v3 tests and graph protocol tests also follow the same pattern.
Specific updates (required)
The tests were updated to follow the same common pattern except in cases where the tx receipt is needed to get additional data like "cumulativeGasUsed" like PoolUpdatesWithHints test case and PollCreator test case the transaction is resolved first, the tx receipt is extracted from the tx and then
tx.hash
is passed to the emit assertion.Does this pull request close any open issues?
closes #476
Checklist:
yarn test
pass