-
Notifications
You must be signed in to change notification settings - Fork 31
chore: use ERC20 subscriptions instead of eventually to check balances #1289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
27680a5
to
62bbd44
Compare
assert not eventResult.isErr | ||
counter += 1 | ||
if counter == 6: | ||
transferEvent.fire() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that the event is going to fire only once, unless it's reset, so if thats what you want then fine.
counter += 1 | ||
if counter == 6: | ||
transferEvent.fire() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels flakey, and is difficult to understand why we need to wait for 6 Transfer events without spending the time looking through the code or logs. Maybe we could instead inspect the Transfer
event for the expected values (receiver
address, and value
), or after each transfer event, check our conditions?
proc onTransfer(eventResult: ?!Transfer) =
assert not eventResult.isErr
let rewardReceived =
(await token.balanceOf(hostAccount)) - startBalanceHost >=
(duration - 5 * 60).u256 * pricePerSlotPerSecond * ecNodes.u256
let clientRefunded = ((await token.balanceOf(clientAccount)) - clientBalanceBeforeFinished > 0)
if rewardReceived and clientRefunded:
transferEvent.fire()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after each transfer event, check our conditions?
Yeah, that's exactly what I just pushed. After each transfer event, I created an async event that triggers when the balances exactly match the expected amounts, instead of just checking if the value is greater than expected. The test now waits for those async events to complete successfully.
1099480
to
3d7a4b7
Compare
… from the smart contracts instead of looking into the reservations
This PR uses ERC20 subscriptions instead of eventually to check balances.
It catches HttpConnectionError when using eventually, to prevent failures on the first HTTP request error.
It also enables logs for
repair from local and remote store
to help identify the cause when the test fails in CI.