From bda416df0acee8e0df2e32227a94aceb0c08e2a5 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Wed, 24 Feb 2021 13:39:36 +1100 Subject: [PATCH] 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`. --- src/wallet/signer.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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