From: 志宇 Date: Fri, 6 Dec 2024 05:35:56 +0000 (+1100) Subject: test(chain): Add canonicalization test X-Git-Tag: v1.0.0-beta.6~2^2~6 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/static/struct.CommandStringError.html?a=commitdiff_plain;h=68f7b7724388eb104775a256b3529198e5af84b7;p=bdk test(chain): Add canonicalization test Tx anchored in orphaned block and not seen in the mempool should be canon. --- diff --git a/crates/chain/tests/test_tx_graph_conflicts.rs b/crates/chain/tests/test_tx_graph_conflicts.rs index a2b6abdc..ff4c8b1f 100644 --- a/crates/chain/tests/test_tx_graph_conflicts.rs +++ b/crates/chain/tests/test_tx_graph_conflicts.rs @@ -663,6 +663,29 @@ fn test_tx_conflict_handling() { confirmed: Amount::from_sat(8000), ..Default::default() } + }, + Scenario { + name: "tx anchored in orphaned block and not seen in mempool should be canon", + tx_templates: &[ + TxTemplate { + tx_name: "root", + inputs: &[TxInTemplate::Bogus], + outputs: &[TxOutTemplate::new(10_000, None)], + anchors: &[block_id!(1, "B")], + ..Default::default() + }, + TxTemplate { + tx_name: "tx", + inputs: &[TxInTemplate::PrevTx("root", 0)], + outputs: &[TxOutTemplate::new(9000, Some(0))], + anchors: &[block_id!(6, "not G")], + ..Default::default() + }, + ], + exp_chain_txs: HashSet::from(["root", "tx"]), + exp_chain_txouts: HashSet::from([("tx", 0)]), + exp_unspents: HashSet::from([("tx", 0)]), + exp_balance: Balance { trusted_pending: Amount::from_sat(9000), ..Default::default() } } ];