From: nymius <155548262+nymius@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:29:14 +0000 (-0300) Subject: test(wallet): pattern match ChainPosition::Confirmed in anchors persistence check X-Git-Tag: v1.0.0-beta.6~3^2~2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.DecoderReader.html?a=commitdiff_plain;h=4ec7940158e80c0e8d657ffa07f540de81e3cbfa;p=bdk test(wallet): pattern match ChainPosition::Confirmed in anchors persistence check --- diff --git a/crates/wallet/tests/wallet.rs b/crates/wallet/tests/wallet.rs index f7bf4363..4a53c350 100644 --- a/crates/wallet/tests/wallet.rs +++ b/crates/wallet/tests/wallet.rs @@ -248,11 +248,11 @@ fn wallet_should_persist_anchors_and_recover() { }; let txid = small_output_tx.compute_txid(); insert_tx(&mut wallet, small_output_tx); - let anchor = ConfirmationBlockTime { + let expected_anchor = ConfirmationBlockTime { block_id: wallet.latest_checkpoint().block_id(), confirmation_time: 200, }; - insert_anchor(&mut wallet, txid, anchor); + insert_anchor(&mut wallet, txid, expected_anchor); assert!(wallet.persist(&mut db).unwrap()); // should recover persisted wallet @@ -266,13 +266,18 @@ fn wallet_should_persist_anchors_and_recover() { .unwrap() .expect("must have loaded changeset"); // stored anchor should be retrieved in the same condition it was persisted - assert_eq!( - wallet - .get_tx(txid) - .expect("should retrieve stored tx") - .chain_position, - ChainPosition::Confirmed(&anchor), - ); + if let ChainPosition::Confirmed { + anchor: &obtained_anchor, + .. + } = wallet + .get_tx(txid) + .expect("should retrieve stored tx") + .chain_position + { + assert_eq!(obtained_anchor, expected_anchor) + } else { + panic!("Should have got ChainPosition::Confirmed)"); + } } #[test]