Skip to content

Conversation

2-towns
Copy link
Contributor

@2-towns 2-towns commented Jun 24, 2025

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.

@2-towns 2-towns force-pushed the chore/use-erc20-subscriptions branch from 27680a5 to 62bbd44 Compare June 25, 2025 13:02
@2-towns 2-towns marked this pull request as ready for review June 25, 2025 13:04
assert not eventResult.isErr
counter += 1
if counter == 6:
transferEvent.fire()
Copy link
Contributor

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.

Comment on lines 116 to 118
counter += 1
if counter == 6:
transferEvent.fire()
Copy link
Contributor

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()

Copy link
Contributor Author

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.

@2-towns 2-towns marked this pull request as draft July 1, 2025 08:01
@2-towns 2-towns force-pushed the chore/use-erc20-subscriptions branch from 1099480 to 3d7a4b7 Compare July 1, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants