]> Untitled Git - bdk/commitdiff
test(chain): Add canonicalization test
author志宇 <hello@evanlinjin.me>
Fri, 6 Dec 2024 05:35:56 +0000 (16:35 +1100)
committer志宇 <hello@evanlinjin.me>
Tue, 10 Dec 2024 10:39:24 +0000 (21:39 +1100)
Tx anchored in orphaned block and not seen in the mempool should be
canon.

crates/chain/tests/test_tx_graph_conflicts.rs

index a2b6abdc349ac4a8cf73be704848923056881190..ff4c8b1f9635bdd919e18e87f61bf1d37ff965e1 100644 (file)
@@ -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() }
         }
     ];