Skip to content
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

Slow useCalls updates after changing mockContract return value and mining a new block #1116

Open
dospore opened this issue Jun 10, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@dospore
Copy link

dospore commented Jun 10, 2023

UseCalls not getting hit when mining a new block
Hey, I might be doing something wrong here but wanted to double check. Im using your testing suite to test a couple of hooks we have. Everything works well except its all a bit slow. The tests were timing out a lot and I couldnt figure out what it was so I added a try catch. After 15 seconds useCalls gets hit and it updates itself.

tl;dr
Calling the mockContract directly returns the correct result. useCalls takes +10 seconds to realise the updated mockReturn value. Requires a tryCatch around waitForCurrent since test throws on timeout otherwise.

I tried adding refresh: "everyBlock" but was my understanding this was default anyway. I also tried sending an 'evm_mine' to trigger the refresh but didnt seem to help. I've attached to screenshots of my debugging as well as the test code. Basically just changes the mock return value from 12 -> 0, I'm imagining useDapp should pick this up. Inside the hook, there is the same function call that was passed into useCalls, its just in a useEffect and you can see in the logs the updated mock return value is the expected 0. Eventually useCalls picks it up, the test runs for about 15 seconds each time before passing. Am wondering if you guys have any suspicions on what I could be doing wrong.

Screen Shot 2023-06-10 at 4 13 35 pm Screen Shot 2023-06-10 at 4 14 08 pm

Software versions

  • useDapp version (installed version of @usedapp/core): 1.2.10
  • Package manager: yarn
  • Node version: 16.14.0
@dospore dospore added the bug Something isn't working label Jun 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant