From: 志宇 Date: Fri, 29 Dec 2023 10:23:42 +0000 (+0800) Subject: test(chain): `LocalChain` test for update that is shorter than original X-Git-Tag: v1.0.0-alpha.5~18^2~4 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/enum.AnyDatabase.html?a=commitdiff_plain;h=8f2d4d9d400e398b54cf1bad36057f3f8f4a69a4;p=bdk test(chain): `LocalChain` test for update that is shorter than original --- diff --git a/crates/chain/tests/test_local_chain.rs b/crates/chain/tests/test_local_chain.rs index c190ae52..c1a1cd7f 100644 --- a/crates/chain/tests/test_local_chain.rs +++ b/crates/chain/tests/test_local_chain.rs @@ -292,6 +292,27 @@ fn update_local_chain() { ], }, }, + // Allow update that is shorter than original chain + // | 0 | 1 | 2 | 3 | 4 | 5 + // chain | A C D E F + // update | A C D' + TestLocalChain { + name: "allow update that is shorter than original chain", + chain: local_chain![(0, h!("_")), (2, h!("C")), (3, h!("D")), (4, h!("E")), (5, h!("F"))], + update: chain_update![(0, h!("_")), (2, h!("C")), (3, h!("D'"))], + exp: ExpectedResult::Ok { + changeset: &[ + (3, Some(h!("D'"))), + (4, None), + (5, None), + ], + init_changeset: &[ + (0, Some(h!("_"))), + (2, Some(h!("C"))), + (3, Some(h!("D'"))), + ], + }, + }, ] .into_iter() .for_each(TestLocalChain::run);