mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 04:37:57 +00:00
This PR reverts #2280 which introduced `TransactionExtension` to replace `SignedExtension`. As a result of the discussion [here](https://github.com/paritytech/polkadot-sdk/pull/3623#issuecomment-1986789700), the changes will be reverted for now with plans to reintroduce the concept in the future. --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
This commit is contained in:
@@ -327,42 +327,10 @@ impl frame_system::Config for Runtime {
|
||||
|
||||
type Balance = u64;
|
||||
|
||||
pub struct BalancesWeights;
|
||||
impl pallet_balances::WeightInfo for BalancesWeights {
|
||||
fn transfer_allow_death() -> Weight {
|
||||
Weight::from_parts(25, 0)
|
||||
}
|
||||
fn transfer_keep_alive() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn force_set_balance_creating() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn force_set_balance_killing() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn force_transfer() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn transfer_all() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn force_unreserve() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn upgrade_accounts(_u: u32) -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn force_adjust_total_issuance() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)]
|
||||
impl pallet_balances::Config for Runtime {
|
||||
type Balance = Balance;
|
||||
type AccountStore = System;
|
||||
type WeightInfo = BalancesWeights;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -375,7 +343,6 @@ impl pallet_transaction_payment::Config for Runtime {
|
||||
type WeightToFee = IdentityFee<Balance>;
|
||||
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
|
||||
type FeeMultiplierUpdate = ();
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
impl custom::Config for Runtime {}
|
||||
@@ -388,46 +355,19 @@ impl frame_support::traits::Get<sp_version::RuntimeVersion> for RuntimeVersion {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Encode, codec::Decode, PartialEq, Eq, scale_info::TypeInfo)]
|
||||
pub struct AccountU64(u64);
|
||||
impl sp_runtime::traits::IdentifyAccount for AccountU64 {
|
||||
type AccountId = u64;
|
||||
fn into_account(self) -> u64 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_runtime::traits::Verify for AccountU64 {
|
||||
type Signer = AccountU64;
|
||||
fn verify<L: sp_runtime::traits::Lazy<[u8]>>(
|
||||
&self,
|
||||
_msg: L,
|
||||
_signer: &<Self::Signer as sp_runtime::traits::IdentifyAccount>::AccountId,
|
||||
) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for AccountU64 {
|
||||
fn from(value: u64) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub static RuntimeVersionTestValues: sp_version::RuntimeVersion =
|
||||
Default::default();
|
||||
}
|
||||
|
||||
type TxExtension = (
|
||||
type SignedExtra = (
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
);
|
||||
type UncheckedXt =
|
||||
sp_runtime::generic::UncheckedExtrinsic<u64, RuntimeCall, AccountU64, TxExtension>;
|
||||
type TestBlock = Block<UncheckedXt>;
|
||||
type TestXt = sp_runtime::testing::TestXt<RuntimeCall, SignedExtra>;
|
||||
type TestBlock = Block<TestXt>;
|
||||
|
||||
// Will contain `true` when the custom runtime logic was called.
|
||||
const CUSTOM_ON_RUNTIME_KEY: &[u8] = b":custom:on_runtime";
|
||||
@@ -447,7 +387,7 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
|
||||
|
||||
type Executive = super::Executive<
|
||||
Runtime,
|
||||
Block<UncheckedXt>,
|
||||
Block<TestXt>,
|
||||
ChainContext<Runtime>,
|
||||
Runtime,
|
||||
AllPalletsWithSystem,
|
||||
@@ -522,14 +462,17 @@ impl MultiStepMigrator for MockedModeGetter {
|
||||
}
|
||||
}
|
||||
|
||||
fn tx_ext(nonce: u64, fee: Balance) -> TxExtension {
|
||||
fn extra(nonce: u64, fee: Balance) -> SignedExtra {
|
||||
(
|
||||
frame_system::CheckEra::from(Era::Immortal),
|
||||
frame_system::CheckNonce::from(nonce),
|
||||
frame_system::CheckWeight::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::from(fee),
|
||||
)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn sign_extra(who: u64, nonce: u64, fee: Balance) -> Option<(u64, SignedExtra)> {
|
||||
Some((who, extra(nonce, fee)))
|
||||
}
|
||||
|
||||
fn call_transfer(dest: u64, value: u64) -> RuntimeCall {
|
||||
@@ -542,7 +485,7 @@ fn balance_transfer_dispatch_works() {
|
||||
pallet_balances::GenesisConfig::<Runtime> { balances: vec![(1, 211)] }
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
let xt = UncheckedXt::new_signed(call_transfer(2, 69), 1, 1.into(), tx_ext(0, 0));
|
||||
let xt = TestXt::new(call_transfer(2, 69), sign_extra(1, 0, 0));
|
||||
let weight = xt.get_dispatch_info().weight +
|
||||
<Runtime as frame_system::Config>::BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
@@ -653,7 +596,7 @@ fn block_import_of_bad_extrinsic_root_fails() {
|
||||
fn bad_extrinsic_not_inserted() {
|
||||
let mut t = new_test_ext(1);
|
||||
// bad nonce check!
|
||||
let xt = UncheckedXt::new_signed(call_transfer(33, 69), 1, 1.into(), tx_ext(30, 0));
|
||||
let xt = TestXt::new(call_transfer(33, 69), sign_extra(1, 30, 0));
|
||||
t.execute_with(|| {
|
||||
Executive::initialize_block(&Header::new_from_number(1));
|
||||
assert_err!(
|
||||
@@ -667,24 +610,27 @@ fn bad_extrinsic_not_inserted() {
|
||||
#[test]
|
||||
fn block_weight_limit_enforced() {
|
||||
let mut t = new_test_ext(10000);
|
||||
let transfer_weight =
|
||||
<<Runtime as pallet_balances::Config>::WeightInfo as pallet_balances::WeightInfo>::transfer_allow_death();
|
||||
// given: TestXt uses the encoded len as fixed Len:
|
||||
let xt = TestXt::new(
|
||||
RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }),
|
||||
sign_extra(1, 0, 0),
|
||||
);
|
||||
let encoded = xt.encode();
|
||||
let encoded_len = encoded.len() as u64;
|
||||
// on_initialize weight + base block execution weight
|
||||
let block_weights = <Runtime as frame_system::Config>::BlockWeights::get();
|
||||
let base_block_weight = Weight::from_parts(175, 0) + block_weights.base_block;
|
||||
let limit = block_weights.get(DispatchClass::Normal).max_total.unwrap() - base_block_weight;
|
||||
let num_to_exhaust_block = limit.ref_time() / (transfer_weight.ref_time() + 5);
|
||||
let num_to_exhaust_block = limit.ref_time() / (encoded_len + 5);
|
||||
t.execute_with(|| {
|
||||
Executive::initialize_block(&Header::new_from_number(1));
|
||||
// Base block execution weight + `on_initialize` weight from the custom module.
|
||||
assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), base_block_weight);
|
||||
|
||||
for nonce in 0..=num_to_exhaust_block {
|
||||
let xt = UncheckedXt::new_signed(
|
||||
let xt = TestXt::new(
|
||||
RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(nonce.into(), 0),
|
||||
sign_extra(1, nonce.into(), 0),
|
||||
);
|
||||
let res = Executive::apply_extrinsic(xt);
|
||||
if nonce != num_to_exhaust_block {
|
||||
@@ -692,8 +638,7 @@ fn block_weight_limit_enforced() {
|
||||
assert_eq!(
|
||||
<frame_system::Pallet<Runtime>>::block_weight().total(),
|
||||
//--------------------- on_initialize + block_execution + extrinsic_base weight
|
||||
Weight::from_parts((transfer_weight.ref_time() + 5) * (nonce + 1), 0) +
|
||||
base_block_weight,
|
||||
Weight::from_parts((encoded_len + 5) * (nonce + 1), 0) + base_block_weight,
|
||||
);
|
||||
assert_eq!(
|
||||
<frame_system::Pallet<Runtime>>::extrinsic_index(),
|
||||
@@ -708,26 +653,19 @@ fn block_weight_limit_enforced() {
|
||||
|
||||
#[test]
|
||||
fn block_weight_and_size_is_stored_per_tx() {
|
||||
let xt = UncheckedXt::new_signed(
|
||||
let xt = TestXt::new(
|
||||
RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(0, 0),
|
||||
sign_extra(1, 0, 0),
|
||||
);
|
||||
let x1 = UncheckedXt::new_signed(
|
||||
let x1 = TestXt::new(
|
||||
RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(1, 0),
|
||||
sign_extra(1, 1, 0),
|
||||
);
|
||||
let x2 = UncheckedXt::new_signed(
|
||||
let x2 = TestXt::new(
|
||||
RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(2, 0),
|
||||
sign_extra(1, 2, 0),
|
||||
);
|
||||
let len = xt.clone().encode().len() as u32;
|
||||
let transfer_weight = <<Runtime as pallet_balances::Config>::WeightInfo as pallet_balances::WeightInfo>::transfer_allow_death();
|
||||
let mut t = new_test_ext(1);
|
||||
t.execute_with(|| {
|
||||
// Block execution weight + on_initialize weight from custom module
|
||||
@@ -743,7 +681,8 @@ fn block_weight_and_size_is_stored_per_tx() {
|
||||
assert!(Executive::apply_extrinsic(x1.clone()).unwrap().is_ok());
|
||||
assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok());
|
||||
|
||||
let extrinsic_weight = transfer_weight +
|
||||
// default weight for `TestXt` == encoded length.
|
||||
let extrinsic_weight = Weight::from_parts(len as u64, 0) +
|
||||
<Runtime as frame_system::Config>::BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.base_extrinsic;
|
||||
@@ -768,8 +707,8 @@ fn block_weight_and_size_is_stored_per_tx() {
|
||||
|
||||
#[test]
|
||||
fn validate_unsigned() {
|
||||
let valid = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::allowed_unsigned {}));
|
||||
let invalid = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::unallowed_unsigned {}));
|
||||
let valid = TestXt::new(RuntimeCall::Custom(custom::Call::allowed_unsigned {}), None);
|
||||
let invalid = TestXt::new(RuntimeCall::Custom(custom::Call::unallowed_unsigned {}), None);
|
||||
let mut t = new_test_ext(1);
|
||||
|
||||
t.execute_with(|| {
|
||||
@@ -806,11 +745,9 @@ fn can_not_pay_for_tx_fee_on_full_lock() {
|
||||
t.execute_with(|| {
|
||||
<pallet_balances::Pallet<Runtime> as fungible::MutateFreeze<u64>>::set_freeze(&(), &1, 110)
|
||||
.unwrap();
|
||||
let xt = UncheckedXt::new_signed(
|
||||
let xt = TestXt::new(
|
||||
RuntimeCall::System(frame_system::Call::remark { remark: vec![1u8] }),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(0, 0),
|
||||
sign_extra(1, 0, 0),
|
||||
);
|
||||
Executive::initialize_block(&Header::new_from_number(1));
|
||||
|
||||
@@ -935,11 +872,9 @@ fn event_from_runtime_upgrade_is_included() {
|
||||
/// used through the `ExecuteBlock` trait.
|
||||
#[test]
|
||||
fn custom_runtime_upgrade_is_called_when_using_execute_block_trait() {
|
||||
let xt = UncheckedXt::new_signed(
|
||||
let xt = TestXt::new(
|
||||
RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(0, 0),
|
||||
sign_extra(1, 0, 0),
|
||||
);
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
@@ -967,10 +902,7 @@ fn custom_runtime_upgrade_is_called_when_using_execute_block_trait() {
|
||||
*v = sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
});
|
||||
|
||||
<Executive as ExecuteBlock<Block<UncheckedXt>>>::execute_block(Block::new(
|
||||
header,
|
||||
vec![xt],
|
||||
));
|
||||
<Executive as ExecuteBlock<Block<TestXt>>>::execute_block(Block::new(header, vec![xt]));
|
||||
|
||||
assert_eq!(&sp_io::storage::get(TEST_KEY).unwrap()[..], *b"module");
|
||||
assert_eq!(sp_io::storage::get(CUSTOM_ON_RUNTIME_KEY).unwrap(), true.encode());
|
||||
@@ -1036,7 +968,7 @@ fn offchain_worker_works_as_expected() {
|
||||
#[test]
|
||||
fn calculating_storage_root_twice_works() {
|
||||
let call = RuntimeCall::Custom(custom::Call::calculate_storage_root {});
|
||||
let xt = UncheckedXt::new_signed(call, 1, 1.into(), tx_ext(0, 0));
|
||||
let xt = TestXt::new(call, sign_extra(1, 0, 0));
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
// Let's build some fake block.
|
||||
@@ -1055,13 +987,11 @@ fn calculating_storage_root_twice_works() {
|
||||
#[test]
|
||||
#[should_panic(expected = "Invalid inherent position for extrinsic at index 1")]
|
||||
fn invalid_inherent_position_fail() {
|
||||
let xt1 = UncheckedXt::new_signed(
|
||||
let xt1 = TestXt::new(
|
||||
RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 33, value: 0 }),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(0, 0),
|
||||
sign_extra(1, 0, 0),
|
||||
);
|
||||
let xt2 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let xt2 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
// Let's build some fake block.
|
||||
@@ -1080,8 +1010,8 @@ fn invalid_inherent_position_fail() {
|
||||
|
||||
#[test]
|
||||
fn valid_inherents_position_works() {
|
||||
let xt1 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let xt2 = UncheckedXt::new_signed(call_transfer(33, 0), 1, 1.into(), tx_ext(0, 0));
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
let xt2 = TestXt::new(call_transfer(33, 0), sign_extra(1, 0, 0));
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
// Let's build some fake block.
|
||||
@@ -1101,12 +1031,7 @@ fn valid_inherents_position_works() {
|
||||
#[test]
|
||||
#[should_panic(expected = "A call was labelled as mandatory, but resulted in an Error.")]
|
||||
fn invalid_inherents_fail_block_execution() {
|
||||
let xt1 = UncheckedXt::new_signed(
|
||||
RuntimeCall::Custom(custom::Call::inherent {}),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(0, 0),
|
||||
);
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), sign_extra(1, 0, 0));
|
||||
|
||||
new_test_ext(1).execute_with(|| {
|
||||
Executive::execute_block(Block::new(
|
||||
@@ -1119,7 +1044,7 @@ fn invalid_inherents_fail_block_execution() {
|
||||
// Inherents are created by the runtime and don't need to be validated.
|
||||
#[test]
|
||||
fn inherents_fail_validate_block() {
|
||||
let xt1 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
|
||||
new_test_ext(1).execute_with(|| {
|
||||
assert_eq!(
|
||||
@@ -1133,7 +1058,7 @@ fn inherents_fail_validate_block() {
|
||||
/// Inherents still work while `initialize_block` forbids transactions.
|
||||
#[test]
|
||||
fn inherents_ok_while_exts_forbidden_works() {
|
||||
let xt1 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
Executive::initialize_block(&Header::new_from_number(1));
|
||||
@@ -1153,8 +1078,8 @@ fn inherents_ok_while_exts_forbidden_works() {
|
||||
#[test]
|
||||
#[should_panic = "Only inherents are allowed in this block"]
|
||||
fn transactions_in_only_inherents_block_errors() {
|
||||
let xt1 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let xt2 = UncheckedXt::new_signed(call_transfer(33, 0), 1, 1.into(), tx_ext(0, 0));
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
let xt2 = TestXt::new(call_transfer(33, 0), sign_extra(1, 0, 0));
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
Executive::initialize_block(&Header::new_from_number(1));
|
||||
@@ -1174,8 +1099,8 @@ fn transactions_in_only_inherents_block_errors() {
|
||||
/// Same as above but no error.
|
||||
#[test]
|
||||
fn transactions_in_normal_block_works() {
|
||||
let xt1 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let xt2 = UncheckedXt::new_signed(call_transfer(33, 0), 1, 1.into(), tx_ext(0, 0));
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
let xt2 = TestXt::new(call_transfer(33, 0), sign_extra(1, 0, 0));
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
Executive::initialize_block(&Header::new_from_number(1));
|
||||
@@ -1195,8 +1120,8 @@ fn transactions_in_normal_block_works() {
|
||||
#[test]
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn try_execute_block_works() {
|
||||
let xt1 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let xt2 = UncheckedXt::new_signed(call_transfer(33, 0), 1, 1.into(), tx_ext(0, 0));
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
let xt2 = TestXt::new(call_transfer(33, 0), sign_extra(1, 0, 0));
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
Executive::initialize_block(&Header::new_from_number(1));
|
||||
@@ -1223,8 +1148,8 @@ fn try_execute_block_works() {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
#[should_panic = "Only inherents allowed"]
|
||||
fn try_execute_tx_forbidden_errors() {
|
||||
let xt1 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let xt2 = UncheckedXt::new_signed(call_transfer(33, 0), 1, 1.into(), tx_ext(0, 0));
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
let xt2 = TestXt::new(call_transfer(33, 0), sign_extra(1, 0, 0));
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
// Let's build some fake block.
|
||||
@@ -1251,9 +1176,9 @@ fn try_execute_tx_forbidden_errors() {
|
||||
/// Check that `ensure_inherents_are_first` reports the correct indices.
|
||||
#[test]
|
||||
fn ensure_inherents_are_first_works() {
|
||||
let in1 = UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}));
|
||||
let in2 = UncheckedXt::new_bare(RuntimeCall::Custom2(custom2::Call::inherent {}));
|
||||
let xt2 = UncheckedXt::new_signed(call_transfer(33, 0), 1, 1.into(), tx_ext(0, 0));
|
||||
let in1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None);
|
||||
let in2 = TestXt::new(RuntimeCall::Custom2(custom2::Call::inherent {}), None);
|
||||
let xt2 = TestXt::new(call_transfer(33, 0), sign_extra(1, 0, 0));
|
||||
|
||||
// Mocked empty header:
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
@@ -1331,20 +1256,18 @@ fn callbacks_in_block_execution_works_inner(mbms_active: bool) {
|
||||
|
||||
for i in 0..n_in {
|
||||
let xt = if i % 2 == 0 {
|
||||
UncheckedXt::new_bare(RuntimeCall::Custom(custom::Call::inherent {}))
|
||||
TestXt::new(RuntimeCall::Custom(custom::Call::inherent {}), None)
|
||||
} else {
|
||||
UncheckedXt::new_bare(RuntimeCall::Custom2(custom2::Call::optional_inherent {}))
|
||||
TestXt::new(RuntimeCall::Custom2(custom2::Call::optional_inherent {}), None)
|
||||
};
|
||||
Executive::apply_extrinsic(xt.clone()).unwrap().unwrap();
|
||||
extrinsics.push(xt);
|
||||
}
|
||||
|
||||
for t in 0..n_tx {
|
||||
let xt = UncheckedXt::new_signed(
|
||||
let xt = TestXt::new(
|
||||
RuntimeCall::Custom2(custom2::Call::some_call {}),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(t as u64, 0),
|
||||
sign_extra(1, t as u64, 0),
|
||||
);
|
||||
// Extrinsics can be applied even when MBMs are active. Only the `execute_block`
|
||||
// will reject it.
|
||||
@@ -1384,13 +1307,8 @@ fn callbacks_in_block_execution_works_inner(mbms_active: bool) {
|
||||
|
||||
#[test]
|
||||
fn post_inherent_called_after_all_inherents() {
|
||||
let in1 = UncheckedXt::new_bare(RuntimeCall::Custom2(custom2::Call::inherent {}));
|
||||
let xt1 = UncheckedXt::new_signed(
|
||||
RuntimeCall::Custom2(custom2::Call::some_call {}),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(0, 0),
|
||||
);
|
||||
let in1 = TestXt::new(RuntimeCall::Custom2(custom2::Call::inherent {}), None);
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom2(custom2::Call::some_call {}), sign_extra(1, 0, 0));
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
// Let's build some fake block.
|
||||
@@ -1424,13 +1342,8 @@ fn post_inherent_called_after_all_inherents() {
|
||||
/// Regression test for AppSec finding #40.
|
||||
#[test]
|
||||
fn post_inherent_called_after_all_optional_inherents() {
|
||||
let in1 = UncheckedXt::new_bare(RuntimeCall::Custom2(custom2::Call::optional_inherent {}));
|
||||
let xt1 = UncheckedXt::new_signed(
|
||||
RuntimeCall::Custom2(custom2::Call::some_call {}),
|
||||
1,
|
||||
1.into(),
|
||||
tx_ext(0, 0),
|
||||
);
|
||||
let in1 = TestXt::new(RuntimeCall::Custom2(custom2::Call::optional_inherent {}), None);
|
||||
let xt1 = TestXt::new(RuntimeCall::Custom2(custom2::Call::some_call {}), sign_extra(1, 0, 0));
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
// Let's build some fake block.
|
||||
@@ -1463,14 +1376,14 @@ fn post_inherent_called_after_all_optional_inherents() {
|
||||
|
||||
#[test]
|
||||
fn is_inherent_works() {
|
||||
let ext = UncheckedXt::new_bare(RuntimeCall::Custom2(custom2::Call::inherent {}));
|
||||
let ext = TestXt::new(RuntimeCall::Custom2(custom2::Call::inherent {}), None);
|
||||
assert!(Runtime::is_inherent(&ext));
|
||||
let ext = UncheckedXt::new_bare(RuntimeCall::Custom2(custom2::Call::optional_inherent {}));
|
||||
let ext = TestXt::new(RuntimeCall::Custom2(custom2::Call::optional_inherent {}), None);
|
||||
assert!(Runtime::is_inherent(&ext));
|
||||
|
||||
let ext = UncheckedXt::new_signed(call_transfer(33, 0), 1, 1.into(), tx_ext(0, 0));
|
||||
let ext = TestXt::new(call_transfer(33, 0), sign_extra(1, 0, 0));
|
||||
assert!(!Runtime::is_inherent(&ext));
|
||||
|
||||
let ext = UncheckedXt::new_bare(RuntimeCall::Custom2(custom2::Call::allowed_unsigned {}));
|
||||
let ext = TestXt::new(RuntimeCall::Custom2(custom2::Call::allowed_unsigned {}), None);
|
||||
assert!(!Runtime::is_inherent(&ext), "Unsigned ext are not automatically inherents");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user