Skip to content

Commit 4ec7940

Browse files
committed
test(wallet): pattern match ChainPosition::Confirmed in anchors persistence check
1 parent 2eb19f5 commit 4ec7940

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

crates/wallet/tests/wallet.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ fn wallet_should_persist_anchors_and_recover() {
248248
};
249249
let txid = small_output_tx.compute_txid();
250250
insert_tx(&mut wallet, small_output_tx);
251-
let anchor = ConfirmationBlockTime {
251+
let expected_anchor = ConfirmationBlockTime {
252252
block_id: wallet.latest_checkpoint().block_id(),
253253
confirmation_time: 200,
254254
};
255-
insert_anchor(&mut wallet, txid, anchor);
255+
insert_anchor(&mut wallet, txid, expected_anchor);
256256
assert!(wallet.persist(&mut db).unwrap());
257257

258258
// should recover persisted wallet
@@ -266,13 +266,18 @@ fn wallet_should_persist_anchors_and_recover() {
266266
.unwrap()
267267
.expect("must have loaded changeset");
268268
// stored anchor should be retrieved in the same condition it was persisted
269-
assert_eq!(
270-
wallet
271-
.get_tx(txid)
272-
.expect("should retrieve stored tx")
273-
.chain_position,
274-
ChainPosition::Confirmed(&anchor),
275-
);
269+
if let ChainPosition::Confirmed {
270+
anchor: &obtained_anchor,
271+
..
272+
} = wallet
273+
.get_tx(txid)
274+
.expect("should retrieve stored tx")
275+
.chain_position
276+
{
277+
assert_eq!(obtained_anchor, expected_anchor)
278+
} else {
279+
panic!("Should have got ChainPosition::Confirmed)");
280+
}
276281
}
277282

278283
#[test]

0 commit comments

Comments
 (0)