Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
xlc committed Nov 7, 2023
commit e7022ea1a860f21712cc74fe94dc135211b2933d
2 changes: 2 additions & 0 deletions Cargo.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ serde = { version = "1.0.189" }
parity-scale-codec = { version = "3.6.5", default-features = false, features = ["max-encoded-len"] }

cumulus-pallet-dmp-queue = { version = "0.4.0", default-features = false }
cumulus-pallet-parachain-system = { version = "0.4.0", default-features = false }
cumulus-pallet-xcm = { version = "0.4.0", default-features = false }
cumulus-pallet-xcmp-queue = { version = "0.4.0", default-features = false }
cumulus-primitives-core = { version = "0.4.0", default-features = false }
Expand All @@ -62,6 +63,7 @@ parachain-info = { package = "staging-parachain-info", version = "0.4.0", defaul
polkadot-core-primitives = { version = "4.0.0", default-features = false }
polkadot-parachain-primitives = { version = "3.0.0", default-features = false }
polkadot-primitives = { version = "4.0.0", default-features = false }
polkadot-runtime-common = { version = "4.0.0", default-features = false }
polkadot-runtime-parachains = { version = "4.0.0", default-features = false }
sp-api = { version = "23.0.0", default-features = false }
sp-application-crypto = { version = "27.0.0", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ cumulus-primitives-core = { workspace = true, features = ["std"] }
cumulus-pallet-dmp-queue = { workspace = true, features = ["std"] }
cumulus-pallet-xcmp-queue = { workspace = true, features = ["std"] }
cumulus-pallet-xcm = { workspace = true, features = ["std"] }
cumulus-pallet-parachain-system = { workspace = true, features = ["std"] }
parachain-info = { workspace = true, features = ["std"] }

# polkadot
polkadot-parachain-primitives = { workspace = true, features = ["std"] }
polkadot-runtime-parachains = { workspace = true, features = ["std"] }
polkadot-runtime-common = { workspace = true, features = ["std"] }
xcm-simulator = { workspace = true }

# orml
Expand Down Expand Up @@ -78,6 +80,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
30 changes: 18 additions & 12 deletions asset-registry/src/mock/para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use super::{Amount, Balance, CurrencyId, CurrencyIdConvert, ParachainXcmRouter};

use crate as orml_asset_registry;

use cumulus_primitives_core::{ChannelStatus, GetChannelInfo, ParaId};
use cumulus_pallet_parachain_system::AnyRelayNumber;
use cumulus_primitives_core::ParaId;
use frame_support::traits::{EnsureOrigin, EnsureOriginWithArg};
use frame_support::{
construct_runtime, match_types, ord_parameter_types, parameter_types,
Expand All @@ -20,6 +21,7 @@ use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset}
use pallet_xcm::XcmPassthrough;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
use sp_core::H256;
use sp_runtime::{
traits::{AccountIdConversion, Convert, IdentityLookup},
Expand Down Expand Up @@ -57,7 +59,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = Everything;
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Runtime>;
type MaxConsumers = ConstU32<16>;
}

Expand All @@ -72,6 +74,7 @@ impl pallet_balances::Config for Runtime {
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = [u8; 8];
type MaxHolds = ();
type MaxFreezes = ();
Expand Down Expand Up @@ -261,26 +264,28 @@ impl Config for XcmConfig {
type Aliasers = Nothing;
}

pub struct ChannelInfo;
impl GetChannelInfo for ChannelInfo {
fn get_channel_status(_id: ParaId) -> ChannelStatus {
ChannelStatus::Ready(10, 10)
}
fn get_channel_max(_id: ParaId) -> Option<usize> {
Some(usize::max_value())
}
impl cumulus_pallet_parachain_system::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
type SelfParaId = ();
type OutboundXcmpMessageSource = XcmpQueue;
type DmpMessageHandler = ();
type ReservedDmpWeight = ();
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ();
type CheckAssociatedRelayNumber = AnyRelayNumber;
}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ChannelInfo;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type ControllerOrigin = EnsureRoot<AccountId>;
type ControllerOriginConverter = XcmOriginToCallOrigin;
type WeightInfo = ();
type PriceForSiblingDelivery = ();
type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
Expand Down Expand Up @@ -397,6 +402,7 @@ construct_runtime!(
Balances: pallet_balances,

ParachainInfo: parachain_info,
ParachainSystem: cumulus_pallet_parachain_system,
XcmpQueue: cumulus_pallet_xcmp_queue,
DmpQueue: cumulus_pallet_dmp_queue,
CumulusXcm: cumulus_pallet_xcm,
Expand Down
1 change: 1 addition & 0 deletions asset-registry/src/mock/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl pallet_balances::Config for Runtime {
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = [u8; 8];
type MaxHolds = ();
type MaxFreezes = ();
Expand Down
2 changes: 1 addition & 1 deletion authority/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sp-std = { workspace = true }
[dev-dependencies]
pallet-preimage = { workspace = true, features = ["std"] }
pallet-scheduler = { workspace = true, features = ["std"] }
# pallet-root-testing = { workspace = true, features = ["std"] }
pallet-root-testing = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }

[features]
Expand Down
3 changes: 1 addition & 2 deletions authority/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ impl pallet_preimage::Config for Runtime {
type WeightInfo = ();
type Currency = ();
type ManagerOrigin = EnsureRoot<u128>;
type BaseDeposit = ();
type ByteDeposit = ();
type Consideration = ();
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions currencies/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl pallet_balances::Config for Runtime {
type ReserveIdentifier = ReserveIdentifier;
type WeightInfo = ();
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = [u8; 8];
type MaxHolds = ();
type MaxFreezes = ();
Expand Down
26 changes: 18 additions & 8 deletions tokens/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
use super::*;
use frame_support::{
construct_runtime, parameter_types,
traits::{ChangeMembers, ConstU32, ConstU64, ContainsLengthBound, Everything, SortedMembers},
traits::{
tokens::{PayFromAccount, UnityAssetBalanceConversion},
ChangeMembers, ConstU32, ConstU64, ContainsLengthBound, Everything, SortedMembers,
},
PalletId,
};
use orml_traits::parameter_type_with_key;
Expand Down Expand Up @@ -106,6 +109,7 @@ parameter_types! {
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const GetTokenId: CurrencyId = DOT;
pub const MaxApprovals: u32 = 100;
pub TreasuryAccount: AccountId = Treasury::account_id();
}

pub type MockCurrencyAdapter = CurrencyAdapter<Runtime, GetTokenId>;
Expand All @@ -117,15 +121,21 @@ impl pallet_treasury::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type SpendPeriod = SpendPeriod;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = ();
type SpendFunds = ();
type BurnDestination = (); // Just gets burned.
type WeightInfo = ();
type MaxApprovals = MaxApprovals;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
type SpendFunds = ();
type MaxApprovals = ConstU32<100>;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<u64>;
type AssetKind = ();
type Beneficiary = Self::AccountId;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Paymaster = PayFromAccount<MockCurrencyAdapter, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = ConstU64<10>;
}

thread_local! {
Expand Down
1 change: 1 addition & 0 deletions vesting/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl pallet_balances::Config for Runtime {
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = [u8; 8];
type MaxHolds = ();
type MaxFreezes = ();
Expand Down
43 changes: 32 additions & 11 deletions vesting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,29 @@ fn claim_works() {

MockBlockNumberProvider::set(11);
// remain locked if not claimed
assert!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 10).is_err());
assert!(PalletBalances::transfer(&BOB, &ALICE, 10, ExistenceRequirement::AllowDeath).is_err());
// unlocked after claiming
assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB)));
assert!(VestingSchedules::<Runtime>::contains_key(BOB));
assert_ok!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 10));
assert_ok!(PalletBalances::transfer(
&BOB,
&ALICE,
10,
ExistenceRequirement::AllowDeath
));
// more are still locked
assert!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 1).is_err());
assert!(PalletBalances::transfer(&BOB, &ALICE, 1, ExistenceRequirement::AllowDeath).is_err());

MockBlockNumberProvider::set(21);
// claim more
assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB)));
assert!(!VestingSchedules::<Runtime>::contains_key(BOB));
assert_ok!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 10));
assert_ok!(PalletBalances::transfer(
&BOB,
&ALICE,
10,
ExistenceRequirement::AllowDeath
));
// all used up
assert_eq!(PalletBalances::free_balance(BOB), 0);

Expand Down Expand Up @@ -355,11 +365,16 @@ fn update_vesting_schedules_works() {

MockBlockNumberProvider::set(11);
assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB)));
assert!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 1).is_err());
assert!(PalletBalances::transfer(&BOB, &ALICE, 1, ExistenceRequirement::AllowDeath).is_err());

MockBlockNumberProvider::set(21);
assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB)));
assert_ok!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 10));
assert_ok!(PalletBalances::transfer(
&BOB,
&ALICE,
10,
ExistenceRequirement::AllowDeath
));

// empty vesting schedules cleanup the storage and unlock the fund
assert!(VestingSchedules::<Runtime>::contains_key(BOB));
Expand All @@ -380,7 +395,12 @@ fn update_vesting_schedules_works() {
#[test]
fn update_vesting_schedules_fails_if_unexpected_existing_locks() {
ExtBuilder::build().execute_with(|| {
assert_ok!(PalletBalances::transfer(RuntimeOrigin::signed(ALICE), BOB, 1));
assert_ok!(PalletBalances::transfer(
&ALICE,
&BOB,
1,
ExistenceRequirement::AllowDeath
));
PalletBalances::set_lock(*b"prelocks", &BOB, 0u64, WithdrawReasons::all());
});
}
Expand Down Expand Up @@ -518,7 +538,7 @@ fn cliff_vesting_works() {
assert_eq!(PalletBalances::free_balance(BOB), VESTING_AMOUNT);
assert_eq!(PalletBalances::locks(&BOB), vec![balance_lock.clone()]);
assert_noop!(
PalletBalances::transfer(RuntimeOrigin::signed(BOB), CHARLIE, VESTING_AMOUNT),
PalletBalances::transfer(&BOB, &CHARLIE, VESTING_AMOUNT, ExistenceRequirement::AllowDeath),
TokenError::Frozen,
);
}
Expand All @@ -527,9 +547,10 @@ fn cliff_vesting_works() {
assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB)));
assert!(PalletBalances::locks(&BOB).is_empty());
assert_ok!(PalletBalances::transfer(
RuntimeOrigin::signed(BOB),
CHARLIE,
VESTING_AMOUNT
&BOB,
&CHARLIE,
VESTING_AMOUNT,
ExistenceRequirement::AllowDeath,
));
});
}
3 changes: 3 additions & 0 deletions xtokens/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ cumulus-pallet-dmp-queue = { workspace = true, features = ["std"] }
cumulus-pallet-xcm = { workspace = true, features = ["std"] }
cumulus-pallet-xcmp-queue = { workspace = true, features = ["std"] }
cumulus-primitives-core = { workspace = true, features = ["std"] }
cumulus-pallet-parachain-system = { workspace = true, features = ["std"] }
parachain-info = { workspace = true, features = ["std"] }

# polkadot
polkadot-parachain-primitives = { workspace = true, features = ["std"] }
polkadot-runtime-parachains = { workspace = true, features = ["std"] }
polkadot-runtime-common = { workspace = true, features = ["std"] }
xcm-builder = { workspace = true, features = ["std"] }
xcm-simulator = { workspace = true }

Expand Down Expand Up @@ -81,6 +83,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
Loading