Skip to content

Commit dacd214

Browse files
rdeiorishstove
andauthored
Update testnet/stacks-node/src/tests/nakamoto_integrations.rs
Co-authored-by: Hank Stoever <[email protected]>
1 parent 0fd54df commit dacd214

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11507,17 +11507,22 @@ fn v3_transactions_api_endpoint() {
1150711507
};
1150811508

1150911509
let get_transaction_from_block = |index_block_hash: String, txid: String| {
11510-
for block_json in test_observer::get_blocks() {
11511-
if block_json["index_block_hash"].as_str().unwrap() == format!("0x{}", index_block_hash)
11512-
{
11513-
for transaction_json in block_json["transactions"].as_array().unwrap() {
11514-
if transaction_json["txid"].as_str().unwrap() == format!("0x{}", txid) {
11515-
return Some(transaction_json["raw_tx"].as_str().unwrap().to_string());
11516-
}
11517-
}
11518-
}
11519-
}
11520-
None
11510+
test_observer::get_blocks()
11511+
.into_iter()
11512+
.find(|block_json| {
11513+
block_json["index_block_hash"].as_str().unwrap()
11514+
== format!("0x{}", index_block_hash)
11515+
})
11516+
.and_then(|block_json| {
11517+
block_json["transactions"]
11518+
.as_array()
11519+
.unwrap()
11520+
.iter()
11521+
.find(|transaction| {
11522+
transaction["txid"].as_str().unwrap() == format!("0x{}", txid)
11523+
})
11524+
.map(|transaction| transaction["raw_tx"].as_str().unwrap().to_string())
11525+
})
1152111526
};
1152211527

1152311528
let block_events = test_observer::get_mined_nakamoto_blocks();

0 commit comments

Comments
 (0)