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

generate_tm_block is slowing down MockContext creation in unit tests #1687

Closed
5 tasks
soareschen opened this issue Dec 13, 2021 · 0 comments · Fixed by #1768
Closed
5 tasks

generate_tm_block is slowing down MockContext creation in unit tests #1687

soareschen opened this issue Dec 13, 2021 · 0 comments · Fixed by #1768
Milestone

Comments

@soareschen
Copy link
Contributor

Crate

ibc-relayer

Summary

The generate_tm_block function sleeps for 1 second before returning. This is called at least 20 times in MockContext::new, which in turns is called at least twice in each unit test. This result in at least 40 seconds delay for each test to run.

Unfortunately the fix is not as straightforward as reducing the sleep time, as it will cause existing tests to fail. To properly fix this, we need to stop calling Time::now() everywhere to get the current time, and instead allow the time to be passed explicitly so that it can be mocked.

For the temporary fix, we could also try and see if it is possible to use time in the past when calling generate_tm_block so that it can be returned immediately.

Steps to Reproduce

Running a test like foreign_client::test::foreign_client_update takes over 40 seconds before the test start running and producing logs.

RUST_LOG=debug cargo test -p ibc-relayer -- --nocapture foreign_client::test::foreign_client_update

Acceptance Criteria


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate milestone (priority) applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
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 a pull request may close this issue.

2 participants