fix flacky wallet test#143
Conversation
…aking sure when we mine a block, that we wait for the indexer that it has indexed all transactions before we return from mine_block.
…o be fixed. I set it to ignired for now with a TODO
|
Are there no Clippy warnings after these changes? There are a number of places where |
| // TODO fix this test, I guess we need to rewrite it, may be the whole streaming of transaction | ||
| // events. | ||
| #[tokio::test(flavor = "multi_thread", worker_threads = 1)] | ||
| #[ignore = "needs to be fixedy"] |
| env.mine_block()?; | ||
|
|
||
| wallet.sync_all(data_source)?; | ||
| wallet.sync_all(env.bdk_electrum_client())?; |
There was a problem hiding this comment.
Why is this separation needed?
Wouldn't this return the same client?
There was a problem hiding this comment.
borrow checker complains, if I store it is Data_source. I dont remember the exact details, if you want to see then just change it quickly back and see the error message. Basically a consequence that with &mut be can have only one reference at a time.
| fn test_q_tik() -> anyhow::Result<()> { | ||
| let env = TestEnv::new()?; | ||
| let mut env = TestEnv::new()?; | ||
| // env.start_explorer_in_container()?; |
There was a problem hiding this comment.
Can we remove these comments if not needed anymore?
It's not because the receiver of the function call have changed. see testenv/lib.rs |
Yes, sorry, I see now. By adding the extra |
Internally I add all transactions which are broadcasted by TestEnv to a Vec. When mine_block() is called, I wait for all these transaction to be seen in Electrs (and bitcoind), to assume they are fully synced again. then I remove the transactions from the Vec and return from mine_block(). So in the new model even simple method calls on TestEnv will change the internal state. I tried around using RefCell<Vec<...>> internally, but I think its better to make clear even to the caller, that most operations now do change the internal state. So clippy doesnt warn, because I change most of the API to require &mut. |
by tracking all broadcasted transactions and making sure when we mine a block, that we wait for the indexer that it has indexed all transactions before we return from mine_block.
Internally I add all transactions which are broadcasted by TestEnv to a Vec. When mine_block() is called, I wait for all these transaction to be seen in Electrs (and bitcoind), to assume they are fully synced again. then I remove the transactions from the Vec and return from mine_block()