]> Untitled Git - bdk/commitdiff
test(chain): `LocalChain` test for update that is shorter than original
author志宇 <hello@evanlinjin.me>
Fri, 29 Dec 2023 10:23:42 +0000 (18:23 +0800)
committer志宇 <hello@evanlinjin.me>
Mon, 15 Jan 2024 16:27:02 +0000 (00:27 +0800)
crates/chain/tests/test_local_chain.rs

index c190ae52bd49b9aa7e895de846f012aef3dad2fe..c1a1cd7f9bf7ae2413cb645747404a0ffc58bac8 100644 (file)
@@ -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);