From: Matt Corallo Date: Sat, 7 Sep 2024 12:57:39 +0000 (+0000) Subject: Make several tests more robust against harmless transaction changes X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=7e344dfc11ec0217f28643a05f990d2b06c935f4;p=rust-lightning Make several tests more robust against harmless transaction changes In the next commit we'll be changing the order some transactions get spent in packages, causing some tests to spuriously fail. Here we update a few tests to avoid that by checking sets of inputs rather than specific ordering. --- diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index 200e5ed84..f0a63f8b9 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -1637,15 +1637,15 @@ fn do_test_revoked_counterparty_htlc_tx_balances(anchors: bool) { assert_eq!(as_commitment_claim_txn[0].input[0].previous_output.vout, 4); // Separate to_remote claim check_spends!(as_commitment_claim_txn[0], revoked_local_txn[0]); assert_eq!(as_commitment_claim_txn[1].input.len(), 2); - assert_eq!(as_commitment_claim_txn[1].input[0].previous_output.vout, 2); - assert_eq!(as_commitment_claim_txn[1].input[1].previous_output.vout, 3); + assert!(as_commitment_claim_txn[1].input.iter().any(|inp| inp.previous_output.vout == 2)); + assert!(as_commitment_claim_txn[1].input.iter().any(|inp| inp.previous_output.vout == 3)); check_spends!(as_commitment_claim_txn[1], revoked_local_txn[0]); Some(as_commitment_claim_txn.remove(0)) } else { assert_eq!(as_commitment_claim_txn[0].input.len(), 3); - assert_eq!(as_commitment_claim_txn[0].input[0].previous_output.vout, 2); - assert_eq!(as_commitment_claim_txn[0].input[1].previous_output.vout, 0); - assert_eq!(as_commitment_claim_txn[0].input[2].previous_output.vout, 1); + assert!(as_commitment_claim_txn[0].input.iter().any(|inp| inp.previous_output.vout == 2)); + assert!(as_commitment_claim_txn[0].input.iter().any(|inp| inp.previous_output.vout == 0)); + assert!(as_commitment_claim_txn[0].input.iter().any(|inp| inp.previous_output.vout == 1)); check_spends!(as_commitment_claim_txn[0], revoked_local_txn[0]); None } @@ -1953,9 +1953,9 @@ fn do_test_revoked_counterparty_aggregated_claims(anchors: bool) { Some(claim_txn.remove(0)) } else { assert_eq!(claim_txn[0].input.len(), 3); - assert_eq!(claim_txn[0].input[0].previous_output.vout, 3); - assert_eq!(claim_txn[0].input[1].previous_output.vout, 0); - assert_eq!(claim_txn[0].input[2].previous_output.vout, 1); + assert!(claim_txn[0].input.iter().any(|inp| inp.previous_output.vout == 3)); + assert!(claim_txn[0].input.iter().any(|inp| inp.previous_output.vout == 0)); + assert!(claim_txn[0].input.iter().any(|inp| inp.previous_output.vout == 1)); check_spends!(claim_txn[0], as_revoked_txn[0]); None };