Skip to content

Commit c9aecf4

Browse files
fix pallet-multisig tests
1 parent bf39109 commit c9aecf4

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

substrate/frame/multisig/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,10 @@ impl<T: Config> Pallet<T> {
718718
let (call_hash, call_len, maybe_versioned_call) = match call_or_hash {
719719
CallOrHash::Call(versioned_call) => {
720720
// Validate the version before proceeding
721-
let _ = Self::validate_and_extract_call(&versioned_call)?;
721+
let call = Self::validate_and_extract_call(&versioned_call)?;
722722

723-
let call_hash = blake2_256(&versioned_call.encode());
723+
// Hash the actual call, not the versioned wrapper
724+
let call_hash = blake2_256(&call.encode());
724725
let call_len = versioned_call.encode().len();
725726
(call_hash, call_len, Some(versioned_call))
726727
},

substrate/frame/multisig/src/tests.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ impl Config for Test {
7575
type BlockNumberProvider = frame_system::Pallet<Test>;
7676
}
7777

78+
impl MaxEncodedLen for RuntimeCall {
79+
fn max_encoded_len() -> usize {
80+
4096
81+
}
82+
}
83+
7884
use pallet_balances::{Call as BalancesCall, Error as BalancesError};
7985

8086
pub fn new_test_ext() -> TestState {
@@ -192,6 +198,7 @@ fn timepoint_checking_works() {
192198
hash,
193199
Weight::zero()
194200
));
201+
let timepoint = now();
195202

196203
assert_noop!(
197204
Multisig::as_multi(
@@ -204,7 +211,7 @@ fn timepoint_checking_works() {
204211
),
205212
Error::<Test>::NoTimepoint,
206213
);
207-
let later = Timepoint { index: 1, ..now() };
214+
let later = Timepoint { index: 1, ..timepoint };
208215
assert_noop!(
209216
Multisig::as_multi(
210217
RuntimeOrigin::signed(2),
@@ -238,13 +245,14 @@ fn multisig_2_of_3_works() {
238245
hash,
239246
Weight::zero()
240247
));
248+
let timepoint = now();
241249
assert_eq!(Balances::free_balance(6), 0);
242250

243251
assert_ok!(Multisig::as_multi(
244252
RuntimeOrigin::signed(2),
245253
2,
246254
vec![1, 3],
247-
Some(now()),
255+
Some(timepoint),
248256
call,
249257
call_weight
250258
));
@@ -271,11 +279,12 @@ fn multisig_3_of_3_works() {
271279
hash,
272280
Weight::zero()
273281
));
282+
let timepoint = now();
274283
assert_ok!(Multisig::approve_as_multi(
275284
RuntimeOrigin::signed(2),
276285
3,
277286
vec![1, 3],
278-
Some(now()),
287+
Some(timepoint),
279288
hash,
280289
Weight::zero()
281290
));
@@ -285,7 +294,7 @@ fn multisig_3_of_3_works() {
285294
RuntimeOrigin::signed(3),
286295
3,
287296
vec![1, 2],
288-
Some(now()),
297+
Some(timepoint),
289298
call,
290299
call_weight
291300
));
@@ -424,11 +433,12 @@ fn multisig_2_of_3_cannot_reissue_same_call() {
424433
call.clone(),
425434
Weight::zero()
426435
));
436+
let timepoint1 = now();
427437
assert_ok!(Multisig::as_multi(
428438
RuntimeOrigin::signed(2),
429439
2,
430440
vec![1, 3],
431-
Some(now()),
441+
Some(timepoint1),
432442
call.clone(),
433443
call_weight
434444
));
@@ -442,19 +452,20 @@ fn multisig_2_of_3_cannot_reissue_same_call() {
442452
call.clone(),
443453
Weight::zero()
444454
));
455+
let timepoint2 = now();
445456
assert_ok!(Multisig::as_multi(
446457
RuntimeOrigin::signed(3),
447458
2,
448459
vec![1, 2],
449-
Some(now()),
460+
Some(timepoint2),
450461
call.clone(),
451462
call_weight
452463
));
453464

454465
System::assert_last_event(
455466
pallet_multisig::Event::MultisigExecuted {
456467
approving: 3,
457-
timepoint: now(),
468+
timepoint: timepoint2,
458469
multisig: multi,
459470
call_hash: hash,
460471
result: Err(TokenError::FundsUnavailable.into()),
@@ -675,19 +686,20 @@ fn multisig_handles_no_preimage_after_all_approve() {
675686
hash,
676687
Weight::zero()
677688
));
689+
let timepoint = now();
678690
assert_ok!(Multisig::approve_as_multi(
679691
RuntimeOrigin::signed(2),
680692
3,
681693
vec![1, 3],
682-
Some(now()),
694+
Some(timepoint),
683695
hash,
684696
Weight::zero()
685697
));
686698
assert_ok!(Multisig::approve_as_multi(
687699
RuntimeOrigin::signed(3),
688700
3,
689701
vec![1, 2],
690-
Some(now()),
702+
Some(timepoint),
691703
hash,
692704
Weight::zero()
693705
));
@@ -697,7 +709,7 @@ fn multisig_handles_no_preimage_after_all_approve() {
697709
RuntimeOrigin::signed(3),
698710
3,
699711
vec![1, 2],
700-
Some(now()),
712+
Some(timepoint),
701713
call,
702714
call_weight
703715
));

0 commit comments

Comments
 (0)