Allow the mempool_transaction_expiration test to get network requests in any order (#4830)

This commit is contained in:
teor 2022-07-27 12:15:53 +10:00 committed by GitHub
parent 9b2185ad3d
commit c811457f46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 3 deletions

View File

@ -404,14 +404,41 @@ async fn mempool_transaction_expiration() -> Result<(), crate::BoxError> {
// Test transaction 1 is gossiped
let mut hs = HashSet::new();
hs.insert(tx1_id);
// Transaction and Block IDs are gossipped, in any order
let possible_requests = &mut [
Request::AdvertiseTransactionIds(hs),
Request::AdvertiseBlock(block_two.hash()),
]
.to_vec();
peer_set
.expect_request(Request::AdvertiseTransactionIds(hs))
.expect_request_that(|request| {
let is_possible = possible_requests.contains(request);
*possible_requests = possible_requests
.clone()
.into_iter()
.filter(|possible| possible != request)
.collect();
is_possible
})
.await
.respond(Response::Nil);
// Block is gossiped then
peer_set
.expect_request(Request::AdvertiseBlock(block_two.hash()))
.expect_request_that(|request| {
let is_possible = possible_requests.contains(request);
*possible_requests = possible_requests
.clone()
.into_iter()
.filter(|possible| possible != request)
.collect();
is_possible
})
.await
.respond(Response::Nil);