Unverified Commit 72bb3dfc authored by thiolliere's avatar thiolliere Committed by GitHub
Browse files

Companion: remove IsCallable make use of introduced in-origin filtering (#1226)

* remove IsCallable make use of in-origin filter

* update lock

* bump version for runtimes as spec as changed

* trigger CI

* Revert "trigger CI"

This reverts commit 5ac58fd4.
parent 8495eb37
Pipeline #96909 canceled with stages
in 5 minutes and 41 seconds
This diff is collapsed.
......@@ -666,6 +666,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Call = Call;
type Index = u64;
......@@ -794,7 +795,7 @@ mod tests {
fn claiming_works() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&42), 100);
assert_eq!(Vesting::vesting_balance(&42), Some(50));
assert_eq!(Claims::total(), total_claims() - 100);
......@@ -807,8 +808,8 @@ mod tests {
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(Claims::move_claim(Origin::signed(1), eth(&alice()), eth(&bob()), None), BadOrigin);
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&alice()), eth(&bob()), None));
assert_noop!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])), Error::<Test>::SignerHasNoClaim);
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&bob(), &42u64.encode(), &[][..])));
assert_noop!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])), Error::<Test>::SignerHasNoClaim);
assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&bob(), &42u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&42), 100);
assert_eq!(Vesting::vesting_balance(&42), Some(50));
assert_eq!(Claims::total(), total_claims() - 100);
......@@ -820,7 +821,7 @@ mod tests {
new_test_ext().execute_with(|| {
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&dave()), eth(&bob()), None));
let s = sig::<Test>(&bob(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec()));
assert_ok!(Claims::claim_attest(Origin::none(), 42, s, StatementKind::Regular.to_text().to_vec()));
assert_eq!(Balances::free_balance(&42), 200);
});
}
......@@ -837,16 +838,16 @@ mod tests {
#[test]
fn claiming_does_not_bypass_signing() {
new_test_ext().execute_with(|| {
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&dave(), &42u64.encode(), &[][..])),
Claims::claim(Origin::none(), 42, sig::<Test>(&dave(), &42u64.encode(), &[][..])),
Error::<Test>::InvalidStatement,
);
assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&eve(), &42u64.encode(), &[][..])),
Claims::claim(Origin::none(), 42, sig::<Test>(&eve(), &42u64.encode(), &[][..])),
Error::<Test>::InvalidStatement,
);
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&frank(), &42u64.encode(), &[][..])));
assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&frank(), &42u64.encode(), &[][..])));
});
}
......@@ -855,21 +856,21 @@ mod tests {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Saft.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s.clone(), StatementKind::Saft.to_text().to_vec());
let r = Claims::claim_attest(Origin::none(), 42, s.clone(), StatementKind::Saft.to_text().to_vec());
assert_noop!(r, Error::<Test>::InvalidStatement);
let r = Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec());
let r = Claims::claim_attest(Origin::none(), 42, s, StatementKind::Regular.to_text().to_vec());
assert_noop!(r, Error::<Test>::SignerHasNoClaim);
// ^^^ we use ecdsa_recover, so an invalid signature just results in a random signer id
// being recovered, which realistically will never have a claim.
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec()));
assert_ok!(Claims::claim_attest(Origin::none(), 42, s, StatementKind::Regular.to_text().to_vec()));
assert_eq!(Balances::free_balance(&42), 200);
assert_eq!(Claims::total(), total_claims() - 200);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec());
let r = Claims::claim_attest(Origin::none(), 42, s, StatementKind::Regular.to_text().to_vec());
assert_noop!(r, Error::<Test>::SignerHasNoClaim);
});
}
......@@ -891,7 +892,7 @@ mod tests {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
// Alice's claim is 100
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&42), 100);
// Eve's claim is 300 through Account 42
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec()));
......@@ -932,7 +933,7 @@ mod tests {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), &[]);
let r = Claims::claim(Origin::NONE, 42, s.clone());
let r = Claims::claim(Origin::none(), 42, s.clone());
assert_noop!(r, Error::<Test>::InvalidStatement);
});
}
......@@ -946,12 +947,12 @@ mod tests {
);
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim,
);
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None, None));
assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, None, None));
assert_eq!(Claims::total(), total_claims() + 200);
assert_ok!(Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])));
assert_ok!(Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&69), 200);
assert_eq!(Vesting::vesting_balance(&69), None);
assert_eq!(Claims::total(), total_claims());
......@@ -967,11 +968,11 @@ mod tests {
);
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim,
);
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, Some((50, 10, 1)), None));
assert_ok!(Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])));
assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, Some((50, 10, 1)), None));
assert_ok!(Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&69), 200);
assert_eq!(Vesting::vesting_balance(&69), Some(50));
......@@ -994,20 +995,20 @@ mod tests {
let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text());
assert_noop!(
Claims::claim_attest(
Origin::NONE, 69, signature.clone(), StatementKind::Regular.to_text().to_vec()
Origin::none(), 69, signature.clone(), StatementKind::Regular.to_text().to_vec()
),
Error::<Test>::SignerHasNoClaim
);
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None, Some(StatementKind::Regular)));
assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, None, Some(StatementKind::Regular)));
assert_noop!(
Claims::claim_attest(
Origin::NONE, 69, signature.clone(), vec![],
Origin::none(), 69, signature.clone(), vec![],
),
Error::<Test>::SignerHasNoClaim
);
assert_ok!(
Claims::claim_attest(
Origin::NONE, 69, signature.clone(), StatementKind::Regular.to_text().to_vec()
Origin::none(), 69, signature.clone(), StatementKind::Regular.to_text().to_vec()
)
);
assert_eq!(Balances::free_balance(&69), 200);
......@@ -1029,9 +1030,9 @@ mod tests {
fn double_claiming_doesnt_work() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])),
Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim
);
});
......@@ -1044,13 +1045,13 @@ mod tests {
assert_ok!(<Test as Trait>::VestingSchedule::add_vesting_schedule(&69, total_claims(), 100, 10));
CurrencyOf::<Test>::make_free_balance_be(&69, total_claims());
assert_eq!(Balances::free_balance(69), total_claims());
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, Some((50, 10, 1)), None));
assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, Some((50, 10, 1)), None));
// New total
assert_eq!(Claims::total(), total_claims() + 200);
// They should not be able to claim
assert_noop!(
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Error::<Test>::VestedBalanceExists,
);
});
......@@ -1061,7 +1062,7 @@ mod tests {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &69u64.encode(), &[][..])),
Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &69u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim
);
});
......@@ -1072,7 +1073,7 @@ mod tests {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Claims::claim(Origin::none(), 42, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim
);
});
......
......@@ -593,6 +593,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Call = ();
type Index = u64;
......@@ -985,7 +986,7 @@ mod tests {
fn onboard_works() {
new_test_ext().execute_with(|| {
// Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
assert_eq!(Balances::free_balance(1), 999);
......@@ -1021,7 +1022,7 @@ mod tests {
fn onboard_handles_basic_errors() {
new_test_ext().execute_with(|| {
// Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
assert_eq!(Balances::free_balance(1), 999);
......@@ -1059,7 +1060,7 @@ mod tests {
fn begin_retirement_works() {
new_test_ext().execute_with(|| {
// Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
assert_eq!(Balances::free_balance(1), 999);
......@@ -1102,7 +1103,7 @@ mod tests {
fn begin_retirement_handles_basic_errors() {
new_test_ext().execute_with(|| {
// Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
assert_eq!(Balances::free_balance(1), 999);
......@@ -1147,7 +1148,7 @@ mod tests {
fn withdraw_works() {
new_test_ext().execute_with(|| {
// Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
// Transfer fee is taken here
assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100));
......@@ -1173,7 +1174,7 @@ mod tests {
fn withdraw_handles_basic_errors() {
new_test_ext().execute_with(|| {
// Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
// Transfer fee is taken here
assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 49));
......@@ -1197,7 +1198,7 @@ mod tests {
fn dissolve_works() {
new_test_ext().execute_with(|| {
// Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
// Transfer fee is taken here
assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100));
......@@ -1234,7 +1235,7 @@ mod tests {
fn dissolve_handles_basic_errors() {
new_test_ext().execute_with(|| {
// Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
// Transfer fee is taken here
assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100));
......@@ -1276,7 +1277,7 @@ mod tests {
// Some blocks later...
run_to_block(2);
// Create an auction
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
// Add deploy data
assert_ok!(Crowdfund::fix_deploy_data(
Origin::signed(1),
......@@ -1306,7 +1307,7 @@ mod tests {
fn fund_across_multiple_auctions_works() {
new_test_ext().execute_with(|| {
// Create an auction
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
// Create two competing crowdfunds, with end dates across multiple auctions
// Each crowdfund is competing for the same slots, so only one can win
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 30));
......@@ -1344,7 +1345,7 @@ mod tests {
assert_eq!(Slots::managed_ids(), vec![0.into()]);
// Create a second auction
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
// Contribute to existing funds add to NewRaise
assert_ok!(Crowdfund::contribute(Origin::signed(1), 1, 10));
......
......@@ -27,15 +27,10 @@ pub mod slots;
pub mod crowdfund;
pub mod impls;
use sp_std::marker::PhantomData;
use codec::{Encode, Decode};
use primitives::{BlockNumber, AccountId, ValidityError};
use sp_runtime::{
Perbill, traits::{Saturating, SignedExtension, DispatchInfoOf},
transaction_validity::{TransactionValidityError, TransactionValidity, InvalidTransaction}
};
use primitives::BlockNumber;
use sp_runtime::{Perbill, traits::Saturating};
use frame_support::{
parameter_types, traits::{Currency, Filter},
parameter_types, traits::{Currency},
weights::{Weight, constants::WEIGHT_PER_SECOND},
};
use static_assertions::const_assert;
......@@ -52,7 +47,6 @@ pub use parachains::Call as ParachainsCall;
/// Implementations of some helper traits passed into runtime modules as associated types.
pub use impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor};
use sp_runtime::traits::Dispatchable;
pub type NegativeImbalance<T> = <balances::Module<T> as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
......@@ -67,66 +61,3 @@ parameter_types! {
}
const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct());
/// Apply a given filter to transactions.
pub struct TransactionCallFilter<T: Filter<Call>, Call>(PhantomData<(T, Call)>);
impl<F: Filter<Call>, Call> Default for TransactionCallFilter<F, Call> {
fn default() -> Self { Self::new() }
}
impl<F: Filter<Call>, Call> Encode for TransactionCallFilter<F, Call> {
fn using_encoded<R, FO: FnOnce(&[u8]) -> R>(&self, f: FO) -> R { f(&b""[..]) }
}
impl<F: Filter<Call>, Call> Decode for TransactionCallFilter<F, Call> {
fn decode<I: codec::Input>(_: &mut I) -> Result<Self, codec::Error> { Ok(Self::new()) }
}
impl<F: Filter<Call>, Call> Clone for TransactionCallFilter<F, Call> {
fn clone(&self) -> Self { Self::new() }
}
impl<F: Filter<Call>, Call> Eq for TransactionCallFilter<F, Call> {}
impl<F: Filter<Call>, Call> PartialEq for TransactionCallFilter<F, Call> {
fn eq(&self, _: &Self) -> bool { true }
}
impl<F: Filter<Call>, Call> sp_std::fmt::Debug for TransactionCallFilter<F, Call> {
fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) }
}
fn validate<F: Filter<Call>, Call>(call: &Call) -> TransactionValidity {
if F::filter(call) {
Ok(Default::default())
} else {
Err(InvalidTransaction::Custom(ValidityError::NoPermission.into()).into())
}
}
impl<F: Filter<Call> + Send + Sync, Call: Dispatchable + Send + Sync>
SignedExtension for TransactionCallFilter<F, Call>
{
const IDENTIFIER: &'static str = "TransactionCallFilter";
type AccountId = AccountId;
type Call = Call;
type AdditionalSigned = ();
type Pre = ();
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }
fn validate(&self,
_: &Self::AccountId,
call: &Call,
_: &DispatchInfoOf<Self::Call>,
_: usize,
) -> TransactionValidity { validate::<F, _>(call) }
fn validate_unsigned(
call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> TransactionValidity { validate::<F, _>(call) }
}
impl<F: Filter<Call>, Call> TransactionCallFilter<F, Call> {
/// Create a new instance.
pub fn new() -> Self {
Self(sp_std::marker::PhantomData)
}
}
......@@ -1609,6 +1609,7 @@ mod tests {
}
impl system::Trait for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Call = Call;
type Index = u64;
......@@ -2142,7 +2143,7 @@ mod tests {
if System::block_number() > 1 {
println!("Finalizing {}", System::block_number());
if !DidUpdate::get().is_some() {
Parachains::set_heads(Origin::NONE, vec![]).unwrap();
Parachains::set_heads(Origin::none(), vec![]).unwrap();
}
Parachains::on_finalize(System::block_number());
......@@ -2423,10 +2424,7 @@ mod tests {
];
candidates.iter_mut().for_each(make_attestations);
assert_ok!(Parachains::dispatch(
set_heads(candidates),
Origin::NONE,
));
assert_ok!(Call::from(set_heads(candidates)).dispatch(Origin::none()));
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
assert!(<RelayDispatchQueue>::get(ParaId::from(1)).is_empty());
......@@ -2463,21 +2461,21 @@ mod tests {
assert_eq!(Parachains::parachain_code(ParaId::from(100u32)), Some(vec![4,5,6].into()));
assert_ok!(Registrar::register_para(
Origin::ROOT,
Origin::root(),
99u32.into(),
ParaInfo{scheduling: Scheduling::Always},
vec![7,8,9].into(),
vec![1, 1, 1].into(),
));
assert_ok!(Parachains::set_heads(Origin::NONE, vec![]));
assert_ok!(Parachains::set_heads(Origin::none(), vec![]));
run_to_block(3);
assert_eq!(Parachains::active_parachains(), vec![(5u32.into(), None), (99u32.into(), None), (100u32.into(), None)]);
assert_eq!(Parachains::parachain_code(&ParaId::from(99u32)), Some(vec![7,8,9].into()));
assert_ok!(Registrar::deregister_para(Origin::ROOT, 5u32.into()));
assert_ok!(Parachains::set_heads(Origin::NONE, vec![]));
assert_ok!(Registrar::deregister_para(Origin::root(), 5u32.into()));
assert_ok!(Parachains::set_heads(Origin::none(), vec![]));
// parachain still active this block. another block must pass before it's inactive.
run_to_block(4);
......@@ -2533,7 +2531,7 @@ mod tests {
new_test_ext(parachains.clone()).execute_with(|| {
run_to_block(2);
let candidate = make_blank_attested(raw_candidate(0.into()));
assert!(Parachains::dispatch(set_heads(vec![candidate]), Origin::NONE).is_err());
assert!(Call::from(set_heads(vec![candidate])).dispatch(Origin::none()).is_err());
})
}
......@@ -2554,15 +2552,11 @@ mod tests {
make_attestations(&mut candidate_a);
make_attestations(&mut candidate_b);
assert!(Parachains::dispatch(
set_heads(vec![candidate_b.clone(), candidate_a.clone()]),
Origin::NONE,
).is_err());
assert!(Call::from(set_heads(vec![candidate_b.clone(), candidate_a.clone()]))
.dispatch(Origin::none()).is_err());
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a.clone(), candidate_b.clone()]),
Origin::NONE,
));
assert_ok!(Call::from(set_heads(vec![candidate_a.clone(), candidate_b.clone()]))
.dispatch(Origin::none()));
assert_eq!(Heads::get(&ParaId::from(0)), Some(candidate_a.candidate.head_data));
assert_eq!(Heads::get(&ParaId::from(1)), Some(candidate_b.candidate.head_data));
......@@ -2586,10 +2580,7 @@ mod tests {
double_validity.validity_votes.push(candidate.validity_votes[0].clone());
double_validity.validator_indices.push(true);
assert!(Parachains::dispatch(
set_heads(vec![double_validity]),
Origin::NONE,
).is_err());
assert!(Call::from(set_heads(vec![double_validity])).dispatch(Origin::none()).is_err());
});
}
......@@ -2610,10 +2601,7 @@ mod tests {
assert!(candidate.validator_indices.pop().is_some());
candidate.validator_indices.append(&mut bitvec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
assert!(Parachains::dispatch(
set_heads(vec![candidate]),
Origin::NONE,
).is_err());
assert!(Call::from(set_heads(vec![candidate])).dispatch(Origin::none()).is_err());
});
}
......@@ -2774,10 +2762,7 @@ mod tests {
assert_eq!(applied_after, 1 + ValidationUpgradeDelay::get());
make_attestations(&mut candidate_a);
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a.clone()]),
Origin::NONE,
));
assert_ok!(Call::from(set_heads(vec![candidate_a.clone()])).dispatch(Origin::none()));
assert!(Parachains::past_code_meta(&para_id).most_recent_change().is_none());
assert_eq!(Parachains::code_upgrade_schedule(&para_id), Some(applied_after));
......@@ -2798,10 +2783,7 @@ mod tests {
make_attestations(&mut candidate_a);
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a.clone()]),
Origin::NONE,
));
assert_ok!(Call::from(set_heads(vec![candidate_a.clone()])).dispatch(Origin::none()));
assert!(Parachains::past_code_meta(&para_id).most_recent_change().is_none());
assert_eq!(Parachains::code_upgrade_schedule(&para_id), Some(applied_after));
......@@ -2820,10 +2802,7 @@ mod tests {
make_attestations(&mut candidate_a);
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a.clone()]),
Origin::NONE,
));
assert_ok!(Call::from(set_heads(vec![candidate_a.clone()])).dispatch(Origin::none()));
assert_eq!(
Parachains::past_code_meta(&para_id).most_recent_change(),
......@@ -2865,10 +2844,7 @@ mod tests {
assert_eq!(applied_after, 1 + ValidationUpgradeDelay::get());
make_attestations(&mut candidate_a);
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a.clone()]),
Origin::NONE,
));
assert_ok!(Call::from(set_heads(vec![candidate_a.clone()])).dispatch(Origin::none()));
assert!(Parachains::past_code_meta(&para_id).most_recent_change().is_none());
assert_eq!(Parachains::code_upgrade_schedule(&para_id), Some(applied_after));
......@@ -2887,10 +2863,7 @@ mod tests {
make_attestations(&mut candidate_a);
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a.clone()]),
Origin::NONE,
));
assert_ok!(Call::from(set_heads(vec![candidate_a.clone()])).dispatch(Origin::none()));
assert_eq!(
Parachains::past_code_meta(&para_id).most_recent_change(),
......@@ -2927,10 +2900,7 @@ mod tests {
make_attestations(&mut candidate_a);
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a.clone()]),
Origin::NONE,
));
assert_ok!(Call::from(set_heads(vec![candidate_a.clone()])).dispatch(Origin::none()));
};
run_to_block(3);
......@@ -2944,10 +2914,7 @@ mod tests {
make_attestations(&mut candidate_a);
assert_err!(
Parachains::dispatch(
set_heads(vec![candidate_a.clone()]),