chore(tests): don't use .wait() and use block_on instead#2220
Merged
Conversation
this makes sure we run these waited futures on the same runtime. this fixes the problem with tokio tcp stream breaking when it's instantiated from within the .wait() method and not from the tokio runtime
because we now use tokio's block_on to wait for this method and not futures' wait. this means we will block_on the same runtime recurrsively and panic. So instead of block_on in mock methods, fut.boxed() like the original methods. the difference between the two impls of the mock is that the first one ran synchronously and returned an immediately ready future, the second one creates an non-ready future to be ran asynchronously by the caller.
a732d94 to
6d7e8eb
Compare
onur-ozkan
reviewed
Sep 17, 2024
onur-ozkan
left a comment
There was a problem hiding this comment.
These .wait methods used were using a different runtime - from futures - to run the future, but we could have instead did block_on(fut.compat()) and run it on MM2's tokio runtime.
This is hard to maintain manually. I would create clippy rule and let the clippy do the work for us.
Creating clippy.toml with this rule should make that work:
[[disallowed-methods]]
path = "futures::future::Future::wait"
replacement = "common::block_on_f01"
reason = "Use the default KDF async executor."
Collaborator
Author
doc comments & magic clippy rule :O
6a88b35 to
1ebc318
Compare
shamardy
previously approved these changes
Sep 24, 2024
Collaborator
shamardy
left a comment
There was a problem hiding this comment.
Please fix conflicts :)
shamardy
approved these changes
Sep 24, 2024
onur-ozkan
approved these changes
Sep 24, 2024
dimxy
pushed a commit
that referenced
this pull request
Oct 4, 2024
* dev: fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
dimxy
pushed a commit
that referenced
this pull request
Oct 4, 2024
* dev: fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
dimxy
pushed a commit
that referenced
this pull request
Oct 17, 2024
* dev: fix(cosmos): fix tx broadcasting error (#2238) chore(solana): remove solana implementation (#2239) chore(cli): remove leftover subcommands from help message (#2235) fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Encountered an issue regarding a tokio tcp stream that breaks because it was spawned in a non-tokio runtime (in #1966).
These
.waitmethods used were using a different runtime - fromfutures- to run the future, but we could have instead didblock_on(fut.compat())and run it on MM2's tokio runtime.PRing this on its own to reduce the clutter in #1966 :)