mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
Fix flaky aggregated HTLC revocation test.
Releasing write locks in between monitor updates requires storing a set of cloned keys to iterate over. For efficiency purposes, that set of keys is an actual set, as opposed to array, which means that the iteration order may not be consistent. The test was relying on an event array index to access the revocation transaction. We change that to accessing a hash map keyed by the txid, fixing the test.
This commit is contained in:
parent
c7a4949a25
commit
f80284cc88
1 changed files with 9 additions and 4 deletions
|
@ -2191,7 +2191,7 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
|
|||
|
||||
// Alice should see that Bob is trying to claim to HTLCs, so she should now try to claim them at
|
||||
// the second level instead.
|
||||
let revoked_claims = {
|
||||
let revoked_claim_transactions = {
|
||||
let txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
|
||||
assert_eq!(txn.len(), 2);
|
||||
|
||||
|
@ -2205,10 +2205,14 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
|
|||
check_spends!(revoked_htlc_claim, htlc_tx);
|
||||
}
|
||||
|
||||
txn
|
||||
let mut revoked_claim_transaction_map = HashMap::new();
|
||||
for current_tx in txn.into_iter() {
|
||||
revoked_claim_transaction_map.insert(current_tx.txid(), current_tx);
|
||||
}
|
||||
revoked_claim_transaction_map
|
||||
};
|
||||
for node in &nodes {
|
||||
mine_transactions(node, &revoked_claims.iter().collect::<Vec<_>>());
|
||||
mine_transactions(node, &revoked_claim_transactions.values().collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
|
||||
|
@ -2234,7 +2238,8 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
|
|||
let spend_tx = nodes[0].keys_manager.backing.spend_spendable_outputs(
|
||||
&[&outputs[0]], Vec::new(), Script::new_op_return(&[]), 253, None, &Secp256k1::new(),
|
||||
).unwrap();
|
||||
check_spends!(spend_tx, revoked_claims[idx]);
|
||||
|
||||
check_spends!(spend_tx, revoked_claim_transactions.get(&spend_tx.input[0].previous_output.txid).unwrap());
|
||||
} else {
|
||||
panic!("unexpected event");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue