Skip to content

Commit 6749608

Browse files
authored
Merge pull request #221 from hashed-io/native-bitcoin-vault/fix_tests
Native bitcoin vault/fix tests
2 parents a029f60 + 52b7203 commit 6749608

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

.github/ISSUE_TEMPLATE/suggest-a-feature.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ labels: enhancement
66
assignees: ""
77
---
88

9-
**Motivation**
9+
**Description**
1010

1111
_Describe the need or frustration that motivated you to make this suggestion. Please note that the
1212
goal of this project is to provide a general-purpose template project, so please take care when

pallets/bitcoin-vaults/src/tests.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn inserting_same_xpub_should_fail() {
8787
new_test_ext().execute_with(|| {
8888
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
8989
assert_noop!(BitcoinVaults::set_xpub(Origin::signed(test_pub(2)), dummy_xpub()),Error::<Test>::XPubAlreadyTaken);
90-
90+
9191
});
9292
}
9393

@@ -96,7 +96,7 @@ fn inserting_without_removing_xpub_should_fail() {
9696
new_test_ext().execute_with(|| {
9797
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
9898
assert_noop!(BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub_2()),Error::<Test>::UserAlreadyHasXpub);
99-
99+
100100
});
101101
}
102102

@@ -123,7 +123,7 @@ fn removing_twice_should_not_work() {
123123
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
124124
assert_ok!(BitcoinVaults::remove_xpub(Origin::signed(test_pub(1))));
125125
assert_noop!(BitcoinVaults::remove_xpub(Origin::signed(test_pub(1))), Error::<Test>::XPubNotFound);
126-
126+
127127
});
128128
}
129129

@@ -132,7 +132,7 @@ fn creating_vault_should_work() {
132132
new_test_ext().execute_with(|| {
133133
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
134134
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(2)), dummy_xpub_2()) );
135-
135+
136136
let cosigners = BoundedVec::<<Test as frame_system::Config>::AccountId, MaxCosignersPerVault>::
137137
try_from([ test_pub(2),].to_vec()).unwrap();
138138
assert_ok!(BitcoinVaults::create_vault( Origin::signed(test_pub(1)) , 2, dummy_description(),true, cosigners) );
@@ -186,7 +186,7 @@ fn vault_with_duplicate_members_shouldnt_work() {
186186
fn vault_with_duplicate_incomplete_members() {
187187
new_test_ext().execute_with(|| {
188188
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
189-
189+
190190
let cosigners = BoundedVec::<<Test as frame_system::Config>::AccountId, MaxCosignersPerVault>::
191191
try_from([ test_pub(2),test_pub(1),].to_vec()).unwrap();
192192
assert_noop!(BitcoinVaults::create_vault( Origin::signed(test_pub(1)) , 1, dummy_description(), true,
@@ -259,7 +259,7 @@ fn removing_vault_should_work() {
259259
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
260260
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(2)), dummy_xpub_2()) );
261261
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(3)), dummy_xpub_3()) );
262-
262+
263263
// Insert a normal vault
264264
let cosigners = BoundedVec::<<Test as frame_system::Config>::AccountId, MaxCosignersPerVault>::
265265
try_from([ test_pub(2),test_pub(3)].to_vec()).unwrap();
@@ -277,7 +277,7 @@ fn removing_vault_which_isnt_yours_shoulnt_work() {
277277
new_test_ext().execute_with(|| {
278278
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
279279
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(2)), dummy_xpub_2()) );
280-
280+
281281
// Insert a normal vault
282282
let cosigners = BoundedVec::<<Test as frame_system::Config>::AccountId, MaxCosignersPerVault>::
283283
try_from([ test_pub(2),].to_vec()).unwrap();
@@ -295,7 +295,7 @@ fn removing_vault_and_xpub_in_order_should_work() {
295295
new_test_ext().execute_with(|| {
296296
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
297297
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(2)), dummy_xpub_2()) );
298-
298+
299299
// Insert a normal vault
300300
let cosigners = BoundedVec::<<Test as frame_system::Config>::AccountId, MaxCosignersPerVault>::
301301
try_from([ test_pub(2),].to_vec()).unwrap();
@@ -315,7 +315,7 @@ fn removing_xpub_before_vault_shouldnt_work() {
315315
new_test_ext().execute_with(|| {
316316
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(1)), dummy_xpub()) );
317317
assert_ok!( BitcoinVaults::set_xpub(Origin::signed(test_pub(2)), dummy_xpub_2()) );
318-
318+
319319
// Insert a normal vault
320320
let cosigners = BoundedVec::<<Test as frame_system::Config>::AccountId, MaxCosignersPerVault>::
321321
try_from([ test_pub(2),].to_vec()).unwrap();
@@ -447,7 +447,7 @@ fn saving_psbt_form_external_user_shouldnt_work(){
447447
assert_ok!(BitcoinVaults::propose(Origin::signed(test_pub(1)),vault_id,dummy_testnet_recipient_address(),1000,dummy_description()));
448448
// obtaining proposal id and saving a psbt with a user that is not in the vault
449449
let proposal_id = BitcoinVaults::proposals_by_vault(vault_id).pop().unwrap();
450-
// user 3 is not on
450+
// user 3 is not on
451451
assert_noop!(BitcoinVaults::save_psbt(Origin::signed(test_pub(3)), proposal_id, dummy_psbt()), Error::<Test>::SignerPermissionsNeeded);
452452
});
453453
}
@@ -491,8 +491,8 @@ fn finalize_psbt_should_work(){
491491
let proposal_id = BitcoinVaults::proposals_by_vault(vault_id).pop().unwrap();
492492
make_proposal_valid(proposal_id);
493493

494-
assert_ok!(BitcoinVaults::save_psbt(Origin::signed(test_pub(1)), proposal_id, dummy_psbt()) );
495-
assert_ok!(BitcoinVaults::finalize_psbt(Origin::signed(test_pub(1)), proposal_id,false));
494+
assert_ok!(BitcoinVaults::save_psbt(Origin::signed(test_pub(1)), proposal_id, dummy_psbt()));
495+
// When a proposal meets the threshold changes it status to ReadyToFinalize false
496496
assert!(BitcoinVaults::proposals(proposal_id).unwrap().status.eq(&ProposalStatus::ReadyToFinalize(false)));
497497
});
498498
}
@@ -515,7 +515,7 @@ fn finalize_psbt_twice_shouldnt_work(){
515515
make_proposal_valid(proposal_id);
516516

517517
assert_ok!(BitcoinVaults::save_psbt(Origin::signed(test_pub(1)), proposal_id, dummy_psbt()) );
518-
assert_ok!(BitcoinVaults::finalize_psbt(Origin::signed(test_pub(1)), proposal_id,false));
518+
// When a proposal meets the threshold changes it status to ReadyToFinalize false
519519
assert!(BitcoinVaults::proposals(proposal_id).unwrap().status.eq(&ProposalStatus::ReadyToFinalize(false)));
520520
assert_noop!(BitcoinVaults::finalize_psbt(Origin::signed(test_pub(1)), proposal_id,false), Error::<Test>::PendingProposalRequired);
521521
});
@@ -540,4 +540,4 @@ fn finalize_psbt_without_signatures_shouldnt_work(){
540540

541541
assert_noop!(BitcoinVaults::finalize_psbt(Origin::signed(test_pub(1)), proposal_id,false), Error::<Test>::NotEnoughSignatures);
542542
});
543-
}
543+
}

0 commit comments

Comments
 (0)