Skip to content

Commit 6638b6a

Browse files
committed
don't use block_on on mocked methods
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.
1 parent fbab60a commit 6638b6a

File tree

2 files changed

+268
-216
lines changed

2 files changed

+268
-216
lines changed

mm2src/coins/qrc20/qrc20_tests.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,22 @@ fn test_withdraw_impl_fee_details() {
112112
let (_ctx, coin) = qrc20_coin_for_test(priv_key, None);
113113

114114
Qrc20Coin::get_unspent_ordered_list.mock_safe(|coin, _| {
115-
let cache = block_on(coin.as_ref().recently_spent_outpoints.lock());
116-
let unspents = vec![UnspentInfo {
117-
outpoint: OutPoint {
118-
hash: 1.into(),
119-
index: 0,
120-
},
121-
value: 1000000000,
122-
height: Default::default(),
123-
script: coin
124-
.script_for_address(&block_on(coin.as_ref().derivation_method.unwrap_single_addr()))
125-
.unwrap(),
126-
}];
127-
MockResult::Return(Box::pin(futures::future::ok((unspents, cache))))
115+
let fut = async move {
116+
let cache = coin.as_ref().recently_spent_outpoints.lock().await;
117+
let unspents = vec![UnspentInfo {
118+
outpoint: OutPoint {
119+
hash: 1.into(),
120+
index: 0,
121+
},
122+
value: 1000000000,
123+
height: Default::default(),
124+
script: coin
125+
.script_for_address(&coin.as_ref().derivation_method.unwrap_single_addr().await)
126+
.unwrap(),
127+
}];
128+
Ok((unspents, cache))
129+
};
130+
MockResult::Return(fut.boxed())
128131
});
129132

130133
let withdraw_req = WithdrawRequest {

0 commit comments

Comments
 (0)