Skip to content

Commit e9b3355

Browse files
committed
Fix anchor test.
1 parent 098e951 commit e9b3355

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

lightning/src/ln/monitor_tests.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,7 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
21912191

21922192
// Alice should see that Bob is trying to claim to HTLCs, so she should now try to claim them at
21932193
// the second level instead.
2194-
let revoked_claims = {
2194+
let revoked_claim_transactions = {
21952195
let txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
21962196
assert_eq!(txn.len(), 2);
21972197

@@ -2205,10 +2205,14 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
22052205
check_spends!(revoked_htlc_claim, htlc_tx);
22062206
}
22072207

2208-
txn
2208+
let mut revoked_claim_transaction_map = HashMap::new();
2209+
for current_tx in txn.into_iter() {
2210+
revoked_claim_transaction_map.insert(current_tx.txid(), current_tx);
2211+
}
2212+
revoked_claim_transaction_map
22092213
};
22102214
for node in &nodes {
2211-
mine_transactions(node, &revoked_claims.iter().collect::<Vec<_>>());
2215+
mine_transactions(node, &revoked_claim_transactions.values().collect::<Vec<_>>());
22122216
}
22132217

22142218

@@ -2234,7 +2238,20 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
22342238
let spend_tx = nodes[0].keys_manager.backing.spend_spendable_outputs(
22352239
&[&outputs[0]], Vec::new(), Script::new_op_return(&[]), 253, None, &Secp256k1::new(),
22362240
).unwrap();
2237-
check_spends!(spend_tx, revoked_claims[idx]);
2241+
2242+
{ // recursively expanded macro
2243+
let get_output = |out_point: &bitcoin::blockdata::transaction::OutPoint| {
2244+
let revoked_claim_transaction = revoked_claim_transactions.get(&out_point.txid);
2245+
if let Some(revoked_claim_tx) = revoked_claim_transaction {
2246+
for outp in revoked_claim_tx.output.iter() {
2247+
assert!(outp.value >= outp.script_pubkey.dust_value().to_sat(), "Input tx output didn't meet dust limit");
2248+
}
2249+
return revoked_claim_tx.output.get(out_point.vout as usize).cloned();
2250+
}
2251+
None
2252+
};
2253+
do_check_spends(&spend_tx, get_output);
2254+
}
22382255
} else {
22392256
panic!("unexpected event");
22402257
}

0 commit comments

Comments
 (0)