From: Tobin Harding Date: Wed, 24 Feb 2021 02:39:36 +0000 (+1100) Subject: Use mixed order insertions X-Git-Tag: v0.5.0~10^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/struct.EncoderStringWriter.html?a=commitdiff_plain;h=bda416df0acee8e0df2e32227a94aceb0c08e2a5;p=bdk Use mixed order insertions Currently we have a unit test to test that signers are sorted by ordering. We call `add_external` to add them but currently we add them in the same order we expect them to be in. This means if the implementation happens to insert them simply in the order they are added (i.e. insert to end of list) then this test will still pass. Insert in a mixed order, including one lower followed by one higher - this ensures we are not inserting at the front or at the back but are actually sorting based on the `SignerOrdering`. --- diff --git a/src/wallet/signer.rs b/src/wallet/signer.rs index a573c6e1..eebafa58 100644 --- a/src/wallet/signer.rs +++ b/src/wallet/signer.rs @@ -602,8 +602,9 @@ mod signers_container_tests { let signer2 = Arc::new(DummySigner { number: 2 }); let signer3 = Arc::new(DummySigner { number: 3 }); - signers.add_external(SignerId::Dummy(1), SignerOrdering(1), signer1.clone()); + // Mixed order insertions verifies we are not inserting at head or tail. signers.add_external(SignerId::Dummy(2), SignerOrdering(2), signer2.clone()); + signers.add_external(SignerId::Dummy(1), SignerOrdering(1), signer1.clone()); signers.add_external(SignerId::Dummy(3), SignerOrdering(3), signer3.clone()); // Check that signers are sorted from lowest to highest ordering