mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 02:07:56 +00:00
Rename Origin (#6020)
* Rename Origin
* fmt
* fixes
* more fixes
* fix
* more fixing
* small fixes
* last touches
* update lockfile for {"substrate"}
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -88,7 +88,7 @@ pub mod pallet {
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// Origin for assigning slots.
|
||||
type AssignSlotOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>;
|
||||
type AssignSlotOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
|
||||
|
||||
/// The type representing the leasing system.
|
||||
type Leaser: Leaser<
|
||||
@@ -592,7 +592,7 @@ mod tests {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
@@ -738,7 +738,10 @@ mod tests {
|
||||
run_to_block(1);
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),),
|
||||
AssignedSlots::assign_perm_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
),
|
||||
Error::<Test>::ParaDoesntExist
|
||||
);
|
||||
});
|
||||
@@ -750,7 +753,10 @@ mod tests {
|
||||
run_to_block(1);
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_perm_parachain_slot(Origin::signed(1), ParaId::from(1_u32),),
|
||||
AssignedSlots::assign_perm_parachain_slot(
|
||||
RuntimeOrigin::signed(1),
|
||||
ParaId::from(1_u32),
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
});
|
||||
@@ -770,7 +776,10 @@ mod tests {
|
||||
assert_ok!(TestRegistrar::<Test>::make_parachain(ParaId::from(1_u32)));
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),),
|
||||
AssignedSlots::assign_perm_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
),
|
||||
Error::<Test>::NotParathread
|
||||
);
|
||||
});
|
||||
@@ -792,18 +801,24 @@ mod tests {
|
||||
assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 1, 1));
|
||||
// Try to assign a perm slot in current period fails
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),),
|
||||
AssignedSlots::assign_perm_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
),
|
||||
Error::<Test>::OngoingLeaseExists
|
||||
);
|
||||
|
||||
// Cleanup
|
||||
assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into()));
|
||||
assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into()));
|
||||
|
||||
// Register lease for next lease period
|
||||
assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 2, 1));
|
||||
// Should be detected and also fail
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),),
|
||||
AssignedSlots::assign_perm_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
),
|
||||
Error::<Test>::OngoingLeaseExists
|
||||
);
|
||||
});
|
||||
@@ -836,17 +851,20 @@ mod tests {
|
||||
));
|
||||
|
||||
assert_ok!(AssignedSlots::assign_perm_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
));
|
||||
assert_ok!(AssignedSlots::assign_perm_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(2_u32),
|
||||
));
|
||||
assert_eq!(AssignedSlots::permanent_slot_count(), 2);
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(3_u32),),
|
||||
AssignedSlots::assign_perm_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(3_u32),
|
||||
),
|
||||
Error::<Test>::MaxPermanentSlotsExceeded
|
||||
);
|
||||
});
|
||||
@@ -868,7 +886,7 @@ mod tests {
|
||||
assert_eq!(AssignedSlots::permanent_slots(ParaId::from(1_u32)), None);
|
||||
|
||||
assert_ok!(AssignedSlots::assign_perm_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
));
|
||||
|
||||
@@ -901,7 +919,7 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
),
|
||||
@@ -917,7 +935,7 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
ParaId::from(1_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
),
|
||||
@@ -941,7 +959,7 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
),
|
||||
@@ -967,7 +985,7 @@ mod tests {
|
||||
// Try to assign a perm slot in current period fails
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
),
|
||||
@@ -975,14 +993,14 @@ mod tests {
|
||||
);
|
||||
|
||||
// Cleanup
|
||||
assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into()));
|
||||
assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into()));
|
||||
|
||||
// Register lease for next lease period
|
||||
assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 2, 1));
|
||||
// Should be detected and also fail
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
),
|
||||
@@ -1006,7 +1024,7 @@ mod tests {
|
||||
));
|
||||
|
||||
assert_ok!(AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(n as u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
));
|
||||
@@ -1023,7 +1041,7 @@ mod tests {
|
||||
));
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(7_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
),
|
||||
@@ -1047,7 +1065,7 @@ mod tests {
|
||||
assert_eq!(AssignedSlots::temporary_slots(ParaId::from(1_u32)), None);
|
||||
|
||||
assert_ok!(AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
));
|
||||
@@ -1122,7 +1140,7 @@ mod tests {
|
||||
));
|
||||
|
||||
assert_ok!(AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(n as u32),
|
||||
if (n % 2).is_zero() {
|
||||
SlotLeasePeriodStart::Current
|
||||
@@ -1214,7 +1232,7 @@ mod tests {
|
||||
run_to_block(1);
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),),
|
||||
AssignedSlots::unassign_parachain_slot(RuntimeOrigin::root(), ParaId::from(1_u32),),
|
||||
Error::<Test>::SlotNotAssigned
|
||||
);
|
||||
});
|
||||
@@ -1226,7 +1244,10 @@ mod tests {
|
||||
run_to_block(1);
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_perm_parachain_slot(Origin::signed(1), ParaId::from(1_u32),),
|
||||
AssignedSlots::assign_perm_parachain_slot(
|
||||
RuntimeOrigin::signed(1),
|
||||
ParaId::from(1_u32),
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
});
|
||||
@@ -1245,15 +1266,16 @@ mod tests {
|
||||
));
|
||||
|
||||
assert_ok!(AssignedSlots::assign_perm_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
));
|
||||
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true);
|
||||
|
||||
assert_ok!(
|
||||
AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),)
|
||||
);
|
||||
assert_ok!(AssignedSlots::unassign_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
));
|
||||
|
||||
assert_eq!(AssignedSlots::permanent_slot_count(), 0);
|
||||
assert_eq!(AssignedSlots::has_permanent_slot(ParaId::from(1_u32)), false);
|
||||
@@ -1276,16 +1298,17 @@ mod tests {
|
||||
));
|
||||
|
||||
assert_ok!(AssignedSlots::assign_temp_parachain_slot(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
));
|
||||
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true);
|
||||
|
||||
assert_ok!(
|
||||
AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),)
|
||||
);
|
||||
assert_ok!(AssignedSlots::unassign_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
));
|
||||
|
||||
assert_eq!(AssignedSlots::temporary_slot_count(), 0);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 0);
|
||||
|
||||
@@ -117,7 +117,7 @@ pub mod pallet {
|
||||
type Randomness: Randomness<Self::Hash, Self::BlockNumber>;
|
||||
|
||||
/// The origin which may initiate auctions.
|
||||
type InitiateOrigin: EnsureOrigin<Self::Origin>;
|
||||
type InitiateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// Weight Information for the Extrinsics in the Pallet
|
||||
type WeightInfo: WeightInfo;
|
||||
@@ -709,7 +709,7 @@ mod tests {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
@@ -955,8 +955,8 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_noop!(Auctions::new_auction(Origin::signed(1), 5, 1), BadOrigin);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_noop!(Auctions::new_auction(RuntimeOrigin::signed(1), 5, 1), BadOrigin);
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
|
||||
assert_eq!(AuctionCounter::<Test>::get(), 1);
|
||||
assert_eq!(
|
||||
@@ -970,8 +970,8 @@ mod tests {
|
||||
fn bidding_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
|
||||
|
||||
assert_eq!(Balances::reserved_balance(1), 5);
|
||||
assert_eq!(Balances::free_balance(1), 5);
|
||||
@@ -986,12 +986,12 @@ mod tests {
|
||||
fn under_bidding_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
|
||||
|
||||
assert_storage_noop!({
|
||||
assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 1, 4, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 1, 4, 1));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1000,9 +1000,9 @@ mod tests {
|
||||
fn over_bidding_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5));
|
||||
assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 1, 4, 6));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 1, 4, 6));
|
||||
|
||||
assert_eq!(Balances::reserved_balance(1), 0);
|
||||
assert_eq!(Balances::free_balance(1), 10);
|
||||
@@ -1020,7 +1020,7 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
|
||||
assert_eq!(AuctionCounter::<Test>::get(), 1);
|
||||
assert_eq!(
|
||||
@@ -1082,8 +1082,8 @@ mod tests {
|
||||
fn can_win_auction() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
|
||||
assert_eq!(Balances::reserved_balance(1), 1);
|
||||
assert_eq!(Balances::free_balance(1), 9);
|
||||
run_to_block(9);
|
||||
@@ -1105,8 +1105,8 @@ mod tests {
|
||||
fn can_win_auction_with_late_randomness() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
|
||||
assert_eq!(Balances::reserved_balance(1), 1);
|
||||
assert_eq!(Balances::free_balance(1), 9);
|
||||
assert_eq!(
|
||||
@@ -1159,8 +1159,8 @@ mod tests {
|
||||
fn can_win_incomplete_auction() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 4, 4, 5));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 4, 4, 5));
|
||||
run_to_block(9);
|
||||
|
||||
assert_eq!(leases(), vec![((0.into(), 4), LeaseData { leaser: 1, amount: 5 }),]);
|
||||
@@ -1172,11 +1172,11 @@ mod tests {
|
||||
fn should_choose_best_combination() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 2, 3, 4));
|
||||
assert_ok!(Auctions::bid(Origin::signed(3), 0.into(), 1, 4, 4, 2));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 1.into(), 1, 1, 4, 2));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 2, 3, 4));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), 0.into(), 1, 4, 4, 2));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1.into(), 1, 1, 4, 2));
|
||||
run_to_block(9);
|
||||
|
||||
assert_eq!(
|
||||
@@ -1199,15 +1199,15 @@ mod tests {
|
||||
fn gap_bid_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
|
||||
// User 1 will make a bid for period 1 and 4 for the same Para 0
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 4, 4, 4));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 4, 4, 4));
|
||||
|
||||
// User 2 and 3 will make a bid for para 1 on period 2 and 3 respectively
|
||||
assert_ok!(Auctions::bid(Origin::signed(2), 1.into(), 1, 2, 2, 2));
|
||||
assert_ok!(Auctions::bid(Origin::signed(3), 1.into(), 1, 3, 3, 3));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 1.into(), 1, 2, 2, 2));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), 1.into(), 1, 3, 3, 3));
|
||||
|
||||
// Total reserved should be the max of the two
|
||||
assert_eq!(Balances::reserved_balance(1), 4);
|
||||
@@ -1238,16 +1238,16 @@ mod tests {
|
||||
fn deposit_credit_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 5));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 5));
|
||||
assert_eq!(Balances::reserved_balance(1), 5);
|
||||
run_to_block(10);
|
||||
|
||||
assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]);
|
||||
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5);
|
||||
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 2));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 2, 2, 2, 6));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 2));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 2, 2, 6));
|
||||
// Only 1 reserved since we have a deposit credit of 5.
|
||||
assert_eq!(Balances::reserved_balance(1), 1);
|
||||
run_to_block(20);
|
||||
@@ -1267,16 +1267,16 @@ mod tests {
|
||||
fn deposit_credit_on_alt_para_should_not_count() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 5));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 5));
|
||||
assert_eq!(Balances::reserved_balance(1), 5);
|
||||
run_to_block(10);
|
||||
|
||||
assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]);
|
||||
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5);
|
||||
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 2));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 1.into(), 2, 2, 2, 6));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 2));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1.into(), 2, 2, 2, 6));
|
||||
// 6 reserved since we are bidding on a new para; only works because we don't
|
||||
assert_eq!(Balances::reserved_balance(1), 6);
|
||||
run_to_block(20);
|
||||
@@ -1298,11 +1298,11 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
|
||||
for i in 1..6u64 {
|
||||
run_to_block(i as _);
|
||||
assert_ok!(Auctions::bid(Origin::signed(i), 0.into(), 1, 1, 4, i));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(i), 0.into(), 1, 1, 4, i));
|
||||
for j in 1..6 {
|
||||
assert_eq!(Balances::reserved_balance(j), if j == i { j } else { 0 });
|
||||
assert_eq!(Balances::free_balance(j), if j == i { j * 9 } else { j * 10 });
|
||||
@@ -1327,11 +1327,11 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 0, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 0, 1));
|
||||
|
||||
for i in 1..6u64 {
|
||||
run_to_block(((i - 1) / 2 + 1) as _);
|
||||
assert_ok!(Auctions::bid(Origin::signed(i), 0.into(), 1, 1, 4, i));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(i), 0.into(), 1, 1, 4, i));
|
||||
for j in 1..6 {
|
||||
assert_eq!(Balances::reserved_balance(j), if j <= i { j } else { 0 });
|
||||
assert_eq!(Balances::free_balance(j), if j <= i { j * 9 } else { j * 10 });
|
||||
@@ -1405,19 +1405,19 @@ mod tests {
|
||||
fn lower_bids_are_correctly_refunded() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 1, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 1, 1));
|
||||
let para_1 = ParaId::from(1_u32);
|
||||
let para_2 = ParaId::from(2_u32);
|
||||
|
||||
// Make a bid and reserve a balance
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 1, 4, 10));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 10));
|
||||
assert_eq!(Balances::reserved_balance(1), 10);
|
||||
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), Some(10));
|
||||
assert_eq!(Balances::reserved_balance(2), 0);
|
||||
assert_eq!(ReservedAmounts::<Test>::get((2, para_2)), None);
|
||||
|
||||
// Bigger bid, reserves new balance and returns funds
|
||||
assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 1, 4, 20));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 1, 4, 20));
|
||||
assert_eq!(Balances::reserved_balance(1), 0);
|
||||
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), None);
|
||||
assert_eq!(Balances::reserved_balance(2), 20);
|
||||
@@ -1429,14 +1429,14 @@ mod tests {
|
||||
fn initialize_winners_in_ending_period_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 1));
|
||||
let para_1 = ParaId::from(1_u32);
|
||||
let para_2 = ParaId::from(2_u32);
|
||||
let para_3 = ParaId::from(3_u32);
|
||||
|
||||
// Make bids
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 1, 4, 10));
|
||||
assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 3, 4, 20));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 10));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 3, 4, 20));
|
||||
|
||||
assert_eq!(
|
||||
Auctions::auction_status(System::block_number()),
|
||||
@@ -1466,7 +1466,7 @@ mod tests {
|
||||
AuctionStatus::<u32>::EndingPeriod(1, 0)
|
||||
);
|
||||
assert_eq!(Auctions::winning(1), Some(winning));
|
||||
assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 3, 4, 30));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 3, 4, 30));
|
||||
|
||||
run_to_block(12);
|
||||
assert_eq!(
|
||||
@@ -1482,9 +1482,9 @@ mod tests {
|
||||
fn handle_bid_requires_registered_para() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_noop!(
|
||||
Auctions::bid(Origin::signed(1), 1337.into(), 1, 1, 4, 1),
|
||||
Auctions::bid(RuntimeOrigin::signed(1), 1337.into(), 1, 1, 4, 1),
|
||||
Error::<Test>::ParaNotRegistered
|
||||
);
|
||||
assert_ok!(TestRegistrar::<Test>::register(
|
||||
@@ -1493,7 +1493,7 @@ mod tests {
|
||||
dummy_head_data(),
|
||||
dummy_validation_code()
|
||||
));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 1337.into(), 1, 1, 4, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1337.into(), 1, 1, 4, 1));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1501,8 +1501,8 @@ mod tests {
|
||||
fn handle_bid_checks_existing_lease_periods() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 2, 3, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 2, 3, 1));
|
||||
assert_eq!(Balances::reserved_balance(1), 1);
|
||||
assert_eq!(Balances::free_balance(1), 9);
|
||||
run_to_block(9);
|
||||
@@ -1518,21 +1518,21 @@ mod tests {
|
||||
|
||||
// Para 1 just won an auction above and won some lease periods.
|
||||
// No bids can work which overlap these periods.
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_noop!(
|
||||
Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 4, 1),
|
||||
Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 4, 1),
|
||||
Error::<Test>::AlreadyLeasedOut,
|
||||
);
|
||||
assert_noop!(
|
||||
Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 2, 1),
|
||||
Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 2, 1),
|
||||
Error::<Test>::AlreadyLeasedOut,
|
||||
);
|
||||
assert_noop!(
|
||||
Auctions::bid(Origin::signed(1), 0.into(), 2, 3, 4, 1),
|
||||
Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 3, 4, 1),
|
||||
Error::<Test>::AlreadyLeasedOut,
|
||||
);
|
||||
// This is okay, not an overlapping bid.
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 1, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 1, 1));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1544,14 +1544,14 @@ mod tests {
|
||||
SampleLength::set(10);
|
||||
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 11));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 11));
|
||||
let para_1 = ParaId::from(1_u32);
|
||||
let para_2 = ParaId::from(2_u32);
|
||||
let para_3 = ParaId::from(3_u32);
|
||||
|
||||
// Make bids
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 11, 14, 10));
|
||||
assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 13, 14, 20));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 11, 14, 10));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 13, 14, 20));
|
||||
|
||||
assert_eq!(
|
||||
Auctions::auction_status(System::block_number()),
|
||||
@@ -1576,7 +1576,7 @@ mod tests {
|
||||
assert_eq!(Auctions::winning(0), Some(winning));
|
||||
|
||||
// New bids update the current winning
|
||||
assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 14, 14, 30));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 14, 14, 30));
|
||||
winning[SlotRange::ThreeThree as u8 as usize] = Some((3, para_3, 30));
|
||||
assert_eq!(Auctions::winning(0), Some(winning));
|
||||
|
||||
@@ -1588,7 +1588,7 @@ mod tests {
|
||||
assert_eq!(Auctions::winning(1), Some(winning));
|
||||
run_to_block(25);
|
||||
// Overbid mid sample
|
||||
assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 13, 14, 30));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 13, 14, 30));
|
||||
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 30));
|
||||
assert_eq!(Auctions::winning(1), Some(winning));
|
||||
|
||||
@@ -1629,7 +1629,7 @@ mod tests {
|
||||
);
|
||||
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 11));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 11));
|
||||
|
||||
run_to_block(9);
|
||||
assert_eq!(
|
||||
@@ -1704,13 +1704,13 @@ mod tests {
|
||||
fn can_cancel_auction() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1));
|
||||
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
|
||||
assert_eq!(Balances::reserved_balance(1), 1);
|
||||
assert_eq!(Balances::free_balance(1), 9);
|
||||
|
||||
assert_noop!(Auctions::cancel_auction(Origin::signed(6)), BadOrigin);
|
||||
assert_ok!(Auctions::cancel_auction(Origin::root()));
|
||||
assert_noop!(Auctions::cancel_auction(RuntimeOrigin::signed(6)), BadOrigin);
|
||||
assert_ok!(Auctions::cancel_auction(RuntimeOrigin::root()));
|
||||
|
||||
assert!(AuctionInfo::<Test>::get().is_none());
|
||||
assert_eq!(Balances::reserved_balance(1), 0);
|
||||
@@ -1784,7 +1784,7 @@ mod benchmarking {
|
||||
let duration = T::BlockNumber::max_value();
|
||||
let lease_period_index = LeasePeriodOf::<T>::max_value();
|
||||
let origin = T::InitiateOrigin::successful_origin();
|
||||
}: _<T::Origin>(origin, duration, lease_period_index)
|
||||
}: _<T::RuntimeOrigin>(origin, duration, lease_period_index)
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::AuctionStarted {
|
||||
auction_index: AuctionCounter::<T>::get(),
|
||||
|
||||
@@ -176,7 +176,7 @@ pub mod pallet {
|
||||
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = Self::BlockNumber>;
|
||||
#[pallet::constant]
|
||||
type Prefix: Get<&'static [u8]>;
|
||||
type MoveClaimOrigin: EnsureOrigin<Self::Origin>;
|
||||
type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ mod tests {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
@@ -885,7 +885,7 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(Balances::free_balance(42), 0);
|
||||
assert_ok!(Claims::claim(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&alice(), &42u64.encode(), &[][..])
|
||||
));
|
||||
@@ -900,16 +900,25 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(Balances::free_balance(42), 0);
|
||||
assert_noop!(
|
||||
Claims::move_claim(Origin::signed(1), eth(&alice()), eth(&bob()), None),
|
||||
Claims::move_claim(RuntimeOrigin::signed(1), eth(&alice()), eth(&bob()), None),
|
||||
BadOrigin
|
||||
);
|
||||
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&alice()), eth(&bob()), None));
|
||||
assert_ok!(Claims::move_claim(
|
||||
RuntimeOrigin::signed(6),
|
||||
eth(&alice()),
|
||||
eth(&bob()),
|
||||
None
|
||||
));
|
||||
assert_noop!(
|
||||
Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])),
|
||||
Claims::claim(
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&alice(), &42u64.encode(), &[][..])
|
||||
),
|
||||
Error::<Test>::SignerHasNoClaim
|
||||
);
|
||||
assert_ok!(Claims::claim(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&bob(), &42u64.encode(), &[][..])
|
||||
));
|
||||
@@ -922,10 +931,15 @@ mod tests {
|
||||
#[test]
|
||||
fn claim_attest_moving_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&dave()), eth(&bob()), None));
|
||||
assert_ok!(Claims::move_claim(
|
||||
RuntimeOrigin::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(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
s,
|
||||
StatementKind::Regular.to_text().to_vec()
|
||||
@@ -937,8 +951,16 @@ mod tests {
|
||||
#[test]
|
||||
fn attest_moving_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&eve()), eth(&bob()), Some(42)));
|
||||
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec()));
|
||||
assert_ok!(Claims::move_claim(
|
||||
RuntimeOrigin::signed(6),
|
||||
eth(&eve()),
|
||||
eth(&bob()),
|
||||
Some(42)
|
||||
));
|
||||
assert_ok!(Claims::attest(
|
||||
RuntimeOrigin::signed(42),
|
||||
StatementKind::Saft.to_text().to_vec()
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&42), 300);
|
||||
});
|
||||
}
|
||||
@@ -947,20 +969,28 @@ mod tests {
|
||||
fn claiming_does_not_bypass_signing() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Claims::claim(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&alice(), &42u64.encode(), &[][..])
|
||||
));
|
||||
assert_noop!(
|
||||
Claims::claim(Origin::none(), 42, sig::<Test>(&dave(), &42u64.encode(), &[][..])),
|
||||
Claims::claim(
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&dave(), &42u64.encode(), &[][..])
|
||||
),
|
||||
Error::<Test>::InvalidStatement,
|
||||
);
|
||||
assert_noop!(
|
||||
Claims::claim(Origin::none(), 42, sig::<Test>(&eve(), &42u64.encode(), &[][..])),
|
||||
Claims::claim(
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&eve(), &42u64.encode(), &[][..])
|
||||
),
|
||||
Error::<Test>::InvalidStatement,
|
||||
);
|
||||
assert_ok!(Claims::claim(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&frank(), &42u64.encode(), &[][..])
|
||||
));
|
||||
@@ -973,7 +1003,7 @@ mod tests {
|
||||
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(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
s.clone(),
|
||||
StatementKind::Saft.to_text().to_vec(),
|
||||
@@ -981,7 +1011,7 @@ mod tests {
|
||||
assert_noop!(r, Error::<Test>::InvalidStatement);
|
||||
|
||||
let r = Claims::claim_attest(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
s,
|
||||
StatementKind::Regular.to_text().to_vec(),
|
||||
@@ -992,7 +1022,7 @@ mod tests {
|
||||
|
||||
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
|
||||
assert_ok!(Claims::claim_attest(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
s,
|
||||
StatementKind::Regular.to_text().to_vec()
|
||||
@@ -1002,7 +1032,7 @@ mod tests {
|
||||
|
||||
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
|
||||
let r = Claims::claim_attest(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
s,
|
||||
StatementKind::Regular.to_text().to_vec(),
|
||||
@@ -1016,14 +1046,20 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(Balances::free_balance(42), 0);
|
||||
assert_noop!(
|
||||
Claims::attest(Origin::signed(69), StatementKind::Saft.to_text().to_vec()),
|
||||
Claims::attest(RuntimeOrigin::signed(69), StatementKind::Saft.to_text().to_vec()),
|
||||
Error::<Test>::SenderHasNoClaim
|
||||
);
|
||||
assert_noop!(
|
||||
Claims::attest(Origin::signed(42), StatementKind::Regular.to_text().to_vec()),
|
||||
Claims::attest(
|
||||
RuntimeOrigin::signed(42),
|
||||
StatementKind::Regular.to_text().to_vec()
|
||||
),
|
||||
Error::<Test>::InvalidStatement
|
||||
);
|
||||
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec()));
|
||||
assert_ok!(Claims::attest(
|
||||
RuntimeOrigin::signed(42),
|
||||
StatementKind::Saft.to_text().to_vec()
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&42), 300);
|
||||
assert_eq!(Claims::total(), total_claims() - 300);
|
||||
});
|
||||
@@ -1035,13 +1071,16 @@ mod tests {
|
||||
assert_eq!(Balances::free_balance(42), 0);
|
||||
// Alice's claim is 100
|
||||
assert_ok!(Claims::claim(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::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()));
|
||||
assert_ok!(Claims::attest(
|
||||
RuntimeOrigin::signed(42),
|
||||
StatementKind::Saft.to_text().to_vec()
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&42), 100 + 300);
|
||||
assert_eq!(Claims::total(), total_claims() - 400);
|
||||
});
|
||||
@@ -1085,7 +1124,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(RuntimeOrigin::none(), 42, s.clone());
|
||||
assert_noop!(r, Error::<Test>::InvalidStatement);
|
||||
});
|
||||
}
|
||||
@@ -1094,18 +1133,22 @@ mod tests {
|
||||
fn add_claim_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
Claims::mint_claim(Origin::signed(42), eth(&bob()), 200, None, None),
|
||||
Claims::mint_claim(RuntimeOrigin::signed(42), eth(&bob()), 200, None, None),
|
||||
sp_runtime::traits::BadOrigin,
|
||||
);
|
||||
assert_eq!(Balances::free_balance(42), 0);
|
||||
assert_noop!(
|
||||
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
|
||||
Claims::claim(
|
||||
RuntimeOrigin::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(RuntimeOrigin::root(), eth(&bob()), 200, None, None));
|
||||
assert_eq!(Claims::total(), total_claims() + 200);
|
||||
assert_ok!(Claims::claim(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
69,
|
||||
sig::<Test>(&bob(), &69u64.encode(), &[][..])
|
||||
));
|
||||
@@ -1119,23 +1162,33 @@ mod tests {
|
||||
fn add_claim_with_vesting_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
Claims::mint_claim(Origin::signed(42), eth(&bob()), 200, Some((50, 10, 1)), None),
|
||||
Claims::mint_claim(
|
||||
RuntimeOrigin::signed(42),
|
||||
eth(&bob()),
|
||||
200,
|
||||
Some((50, 10, 1)),
|
||||
None
|
||||
),
|
||||
sp_runtime::traits::BadOrigin,
|
||||
);
|
||||
assert_eq!(Balances::free_balance(42), 0);
|
||||
assert_noop!(
|
||||
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
|
||||
Claims::claim(
|
||||
RuntimeOrigin::none(),
|
||||
69,
|
||||
sig::<Test>(&bob(), &69u64.encode(), &[][..])
|
||||
),
|
||||
Error::<Test>::SignerHasNoClaim,
|
||||
);
|
||||
assert_ok!(Claims::mint_claim(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
eth(&bob()),
|
||||
200,
|
||||
Some((50, 10, 1)),
|
||||
None
|
||||
));
|
||||
assert_ok!(Claims::claim(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
69,
|
||||
sig::<Test>(&bob(), &69u64.encode(), &[][..])
|
||||
));
|
||||
@@ -1160,7 +1213,7 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
Claims::mint_claim(
|
||||
Origin::signed(42),
|
||||
RuntimeOrigin::signed(42),
|
||||
eth(&bob()),
|
||||
200,
|
||||
None,
|
||||
@@ -1172,7 +1225,7 @@ mod tests {
|
||||
let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text());
|
||||
assert_noop!(
|
||||
Claims::claim_attest(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
69,
|
||||
signature.clone(),
|
||||
StatementKind::Regular.to_text().to_vec()
|
||||
@@ -1180,18 +1233,18 @@ mod tests {
|
||||
Error::<Test>::SignerHasNoClaim
|
||||
);
|
||||
assert_ok!(Claims::mint_claim(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
eth(&bob()),
|
||||
200,
|
||||
None,
|
||||
Some(StatementKind::Regular)
|
||||
));
|
||||
assert_noop!(
|
||||
Claims::claim_attest(Origin::none(), 69, signature.clone(), vec![],),
|
||||
Claims::claim_attest(RuntimeOrigin::none(), 69, signature.clone(), vec![],),
|
||||
Error::<Test>::SignerHasNoClaim
|
||||
);
|
||||
assert_ok!(Claims::claim_attest(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
69,
|
||||
signature.clone(),
|
||||
StatementKind::Regular.to_text().to_vec()
|
||||
@@ -1206,7 +1259,7 @@ mod tests {
|
||||
assert_eq!(Balances::free_balance(42), 0);
|
||||
assert_err!(
|
||||
Claims::claim(
|
||||
Origin::signed(42),
|
||||
RuntimeOrigin::signed(42),
|
||||
42,
|
||||
sig::<Test>(&alice(), &42u64.encode(), &[][..])
|
||||
),
|
||||
@@ -1220,12 +1273,16 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(Balances::free_balance(42), 0);
|
||||
assert_ok!(Claims::claim(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&alice(), &42u64.encode(), &[][..])
|
||||
));
|
||||
assert_noop!(
|
||||
Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])),
|
||||
Claims::claim(
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&alice(), &42u64.encode(), &[][..])
|
||||
),
|
||||
Error::<Test>::SignerHasNoClaim
|
||||
);
|
||||
});
|
||||
@@ -1244,7 +1301,7 @@ mod tests {
|
||||
CurrencyOf::<Test>::make_free_balance_be(&69, total_claims());
|
||||
assert_eq!(Balances::free_balance(69), total_claims());
|
||||
assert_ok!(Claims::mint_claim(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
eth(&bob()),
|
||||
200,
|
||||
Some((50, 10, 1)),
|
||||
@@ -1255,7 +1312,11 @@ mod tests {
|
||||
|
||||
// They should not be able to claim
|
||||
assert_noop!(
|
||||
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
|
||||
Claims::claim(
|
||||
RuntimeOrigin::none(),
|
||||
69,
|
||||
sig::<Test>(&bob(), &69u64.encode(), &[][..])
|
||||
),
|
||||
Error::<Test>::VestedBalanceExists,
|
||||
);
|
||||
});
|
||||
@@ -1266,7 +1327,11 @@ 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(
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&alice(), &69u64.encode(), &[][..])
|
||||
),
|
||||
Error::<Test>::SignerHasNoClaim
|
||||
);
|
||||
});
|
||||
@@ -1277,7 +1342,11 @@ 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(
|
||||
RuntimeOrigin::none(),
|
||||
42,
|
||||
sig::<Test>(&bob(), &69u64.encode(), &[][..])
|
||||
),
|
||||
Error::<Test>::SignerHasNoClaim
|
||||
);
|
||||
});
|
||||
|
||||
@@ -892,7 +892,7 @@ mod tests {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
@@ -1168,7 +1168,7 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
let para = new_para();
|
||||
// Now try to create a crowdloan campaign
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None));
|
||||
// This is what the initial `fund_info` should look like
|
||||
let fund_info = FundInfo {
|
||||
depositor: 1,
|
||||
@@ -1201,7 +1201,7 @@ mod tests {
|
||||
let para = new_para();
|
||||
// Now try to create a crowdloan campaign
|
||||
assert_ok!(Crowdloan::create(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para,
|
||||
1000,
|
||||
1,
|
||||
@@ -1241,12 +1241,15 @@ mod tests {
|
||||
let para = new_para();
|
||||
|
||||
let e = Error::<Test>::InvalidParaId;
|
||||
assert_noop!(Crowdloan::create(Origin::signed(1), 1.into(), 1000, 1, 4, 9, None), e);
|
||||
assert_noop!(
|
||||
Crowdloan::create(RuntimeOrigin::signed(1), 1.into(), 1000, 1, 4, 9, None),
|
||||
e
|
||||
);
|
||||
// Cannot create a crowdloan with bad lease periods
|
||||
let e = Error::<Test>::LastPeriodBeforeFirstPeriod;
|
||||
assert_noop!(Crowdloan::create(Origin::signed(1), para, 1000, 4, 1, 9, None), e);
|
||||
assert_noop!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 4, 1, 9, None), e);
|
||||
let e = Error::<Test>::LastPeriodTooFarInFuture;
|
||||
assert_noop!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 9, 9, None), e);
|
||||
assert_noop!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 9, 9, None), e);
|
||||
|
||||
// Cannot create a crowdloan without some deposit funds
|
||||
assert_ok!(TestRegistrar::<Test>::register(
|
||||
@@ -1257,14 +1260,22 @@ mod tests {
|
||||
));
|
||||
let e = BalancesError::<Test, _>::InsufficientBalance;
|
||||
assert_noop!(
|
||||
Crowdloan::create(Origin::signed(1337), ParaId::from(1234), 1000, 1, 3, 9, None),
|
||||
Crowdloan::create(
|
||||
RuntimeOrigin::signed(1337),
|
||||
ParaId::from(1234),
|
||||
1000,
|
||||
1,
|
||||
3,
|
||||
9,
|
||||
None
|
||||
),
|
||||
e
|
||||
);
|
||||
|
||||
// Cannot create a crowdloan with nonsense end date
|
||||
// This crowdloan would end in lease period 2, but is bidding for some slot that starts in lease period 1.
|
||||
assert_noop!(
|
||||
Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 41, None),
|
||||
Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 41, None),
|
||||
Error::<Test>::EndTooFarInFuture
|
||||
);
|
||||
});
|
||||
@@ -1277,13 +1288,13 @@ mod tests {
|
||||
let index = NextFundIndex::<Test>::get();
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None));
|
||||
|
||||
// No contributions yet
|
||||
assert_eq!(Crowdloan::contribution_get(u32::from(para), &1).0, 0);
|
||||
|
||||
// User 1 contributes to their own crowdloan
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 49, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None));
|
||||
// User 1 has spent some funds to do this, transfer fees **are** taken
|
||||
assert_eq!(Balances::free_balance(1), 950);
|
||||
// Contributions are stored in the trie
|
||||
@@ -1309,7 +1320,7 @@ mod tests {
|
||||
let pubkey = crypto::create_ed25519_pubkey(b"//verifier".to_vec());
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para,
|
||||
1000,
|
||||
1,
|
||||
@@ -1323,7 +1334,7 @@ mod tests {
|
||||
|
||||
// Missing signature
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para, 49, None),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None),
|
||||
Error::<Test>::InvalidSignature
|
||||
);
|
||||
|
||||
@@ -1335,23 +1346,33 @@ mod tests {
|
||||
|
||||
// Invalid signature
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para, 49, Some(invalid_signature)),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, Some(invalid_signature)),
|
||||
Error::<Test>::InvalidSignature
|
||||
);
|
||||
|
||||
// Valid signature wrong parameter
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para, 50, Some(valid_signature.clone())),
|
||||
Crowdloan::contribute(
|
||||
RuntimeOrigin::signed(1),
|
||||
para,
|
||||
50,
|
||||
Some(valid_signature.clone())
|
||||
),
|
||||
Error::<Test>::InvalidSignature
|
||||
);
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(2), para, 49, Some(valid_signature.clone())),
|
||||
Crowdloan::contribute(
|
||||
RuntimeOrigin::signed(2),
|
||||
para,
|
||||
49,
|
||||
Some(valid_signature.clone())
|
||||
),
|
||||
Error::<Test>::InvalidSignature
|
||||
);
|
||||
|
||||
// Valid signature
|
||||
assert_ok!(Crowdloan::contribute(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para,
|
||||
49,
|
||||
Some(valid_signature.clone())
|
||||
@@ -1359,7 +1380,7 @@ mod tests {
|
||||
|
||||
// Reuse valid signature
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para, 49, Some(valid_signature)),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, Some(valid_signature)),
|
||||
Error::<Test>::InvalidSignature
|
||||
);
|
||||
|
||||
@@ -1367,7 +1388,12 @@ mod tests {
|
||||
let valid_signature_2 = crypto::create_ed25519_signature(&payload_2.encode(), pubkey);
|
||||
|
||||
// New valid signature
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 10, Some(valid_signature_2)));
|
||||
assert_ok!(Crowdloan::contribute(
|
||||
RuntimeOrigin::signed(1),
|
||||
para,
|
||||
10,
|
||||
Some(valid_signature_2)
|
||||
));
|
||||
|
||||
// Contributions appear in free balance of crowdloan
|
||||
assert_eq!(Balances::free_balance(Crowdloan::fund_account_id(index)), 59);
|
||||
@@ -1385,22 +1411,22 @@ mod tests {
|
||||
|
||||
// Cannot contribute to non-existing fund
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para, 49, None),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None),
|
||||
Error::<Test>::InvalidParaId
|
||||
);
|
||||
// Cannot contribute below minimum contribution
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para, 9, None),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(1), para, 9, None),
|
||||
Error::<Test>::ContributionTooSmall
|
||||
);
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 101, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 101, None));
|
||||
|
||||
// Cannot contribute past the limit
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(2), para, 900, None),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(2), para, 900, None),
|
||||
Error::<Test>::CapExceeded
|
||||
);
|
||||
|
||||
@@ -1409,31 +1435,31 @@ mod tests {
|
||||
|
||||
// Cannot contribute to ended fund
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para, 49, None),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None),
|
||||
Error::<Test>::ContributionPeriodOver
|
||||
);
|
||||
|
||||
// If a crowdloan has already won, it should not allow contributions.
|
||||
let para_2 = new_para();
|
||||
let index = NextFundIndex::<Test>::get();
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para_2, 1000, 1, 4, 40, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_2, 1000, 1, 4, 40, None));
|
||||
// Emulate a win by leasing out and putting a deposit. Slots pallet would normally do this.
|
||||
let crowdloan_account = Crowdloan::fund_account_id(index);
|
||||
set_winner(para_2, crowdloan_account, true);
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para_2, 49, None),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(1), para_2, 49, None),
|
||||
Error::<Test>::BidOrLeaseActive
|
||||
);
|
||||
|
||||
// Move past lease period 1, should not be allowed to have further contributions with a crowdloan
|
||||
// that has starting period 1.
|
||||
let para_3 = new_para();
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para_3, 1000, 1, 4, 40, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_3, 1000, 1, 4, 40, None));
|
||||
run_to_block(40);
|
||||
let now = System::block_number();
|
||||
assert_eq!(TestAuctioneer::lease_period_index(now).unwrap().0, 2);
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(1), para_3, 49, None),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(1), para_3, 49, None),
|
||||
Error::<Test>::ContributionPeriodOver
|
||||
);
|
||||
});
|
||||
@@ -1452,7 +1478,7 @@ mod tests {
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para,
|
||||
1000,
|
||||
first_period,
|
||||
@@ -1464,20 +1490,20 @@ mod tests {
|
||||
run_to_block(8);
|
||||
// Can def contribute when auction is running.
|
||||
assert!(TestAuctioneer::auction_status(System::block_number()).is_ending().is_some());
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None));
|
||||
|
||||
run_to_block(10);
|
||||
// Can't contribute when auction is in the VRF delay period.
|
||||
assert!(TestAuctioneer::auction_status(System::block_number()).is_vrf());
|
||||
assert_noop!(
|
||||
Crowdloan::contribute(Origin::signed(2), para, 250, None),
|
||||
Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None),
|
||||
Error::<Test>::VrfDelayInProgress
|
||||
);
|
||||
|
||||
run_to_block(15);
|
||||
// Its fine to contribute when no auction is running.
|
||||
assert!(!TestAuctioneer::auction_status(System::block_number()).is_in_progress());
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None));
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1493,7 +1519,7 @@ mod tests {
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para,
|
||||
1000,
|
||||
first_period,
|
||||
@@ -1505,13 +1531,13 @@ mod tests {
|
||||
|
||||
// Fund crowdloan
|
||||
run_to_block(1);
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
|
||||
run_to_block(3);
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 150, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 150, None));
|
||||
run_to_block(5);
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(4), para, 200, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(4), para, 200, None));
|
||||
run_to_block(8);
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None));
|
||||
run_to_block(10);
|
||||
|
||||
assert_eq!(
|
||||
@@ -1535,9 +1561,9 @@ mod tests {
|
||||
let index = NextFundIndex::<Test>::get();
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
|
||||
|
||||
run_to_block(10);
|
||||
let account_id = Crowdloan::fund_account_id(index);
|
||||
@@ -1548,11 +1574,11 @@ mod tests {
|
||||
assert_eq!(Balances::free_balance(2), 1900);
|
||||
assert_eq!(Balances::free_balance(3), 2950);
|
||||
|
||||
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para));
|
||||
assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para));
|
||||
assert_eq!(Balances::free_balance(&account_id), 50);
|
||||
assert_eq!(Balances::free_balance(2), 2000);
|
||||
|
||||
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 3, para));
|
||||
assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 3, para));
|
||||
assert_eq!(Balances::free_balance(&account_id), 0);
|
||||
assert_eq!(Balances::free_balance(3), 3000);
|
||||
});
|
||||
@@ -1565,26 +1591,26 @@ mod tests {
|
||||
let index = NextFundIndex::<Test>::get();
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
|
||||
|
||||
run_to_block(10);
|
||||
let account_id = Crowdloan::fund_account_id(index);
|
||||
|
||||
// user sends the crowdloan funds trying to make an accounting error
|
||||
assert_ok!(Balances::transfer(Origin::signed(1), account_id, 10));
|
||||
assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), account_id, 10));
|
||||
|
||||
// overfunded now
|
||||
assert_eq!(Balances::free_balance(&account_id), 110);
|
||||
assert_eq!(Balances::free_balance(2), 1900);
|
||||
|
||||
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para));
|
||||
assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para));
|
||||
assert_eq!(Balances::free_balance(2), 2000);
|
||||
|
||||
// Some funds are left over
|
||||
assert_eq!(Balances::free_balance(&account_id), 10);
|
||||
// They wil be left in the account at the end
|
||||
assert_ok!(Crowdloan::dissolve(Origin::signed(1), para));
|
||||
assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para));
|
||||
assert_eq!(Balances::free_balance(&account_id), 10);
|
||||
});
|
||||
}
|
||||
@@ -1597,23 +1623,23 @@ mod tests {
|
||||
let account_id = Crowdloan::fund_account_id(index);
|
||||
|
||||
// Set up a crowdloan ending on 9
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
// Make some contributions
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 200, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 300, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 200, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 300, None));
|
||||
|
||||
assert_eq!(Balances::free_balance(account_id), 600);
|
||||
|
||||
// Can't refund before the crowdloan it has ended
|
||||
assert_noop!(
|
||||
Crowdloan::refund(Origin::signed(1337), para),
|
||||
Crowdloan::refund(RuntimeOrigin::signed(1337), para),
|
||||
Error::<Test>::FundNotEnded,
|
||||
);
|
||||
|
||||
// Move to the end of the crowdloan
|
||||
run_to_block(10);
|
||||
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
|
||||
assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para));
|
||||
|
||||
// Funds are returned
|
||||
assert_eq!(Balances::free_balance(account_id), 0);
|
||||
@@ -1632,12 +1658,12 @@ mod tests {
|
||||
let account_id = Crowdloan::fund_account_id(index);
|
||||
|
||||
// Set up a crowdloan ending on 9
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 100000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 100000, 1, 1, 9, None));
|
||||
// Make more contributions than our limit
|
||||
for i in 1..=RemoveKeysLimit::get() * 2 {
|
||||
Balances::make_free_balance_be(&i.into(), (1000 * i).into());
|
||||
assert_ok!(Crowdloan::contribute(
|
||||
Origin::signed(i.into()),
|
||||
RuntimeOrigin::signed(i.into()),
|
||||
para,
|
||||
(i * 100).into(),
|
||||
None
|
||||
@@ -1648,7 +1674,7 @@ mod tests {
|
||||
|
||||
// Move to the end of the crowdloan
|
||||
run_to_block(10);
|
||||
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
|
||||
assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para));
|
||||
assert_eq!(
|
||||
last_event(),
|
||||
super::Event::<Test>::PartiallyRefunded { para_id: para }.into()
|
||||
@@ -1658,7 +1684,7 @@ mod tests {
|
||||
assert!(!Balances::free_balance(account_id).is_zero());
|
||||
|
||||
// Call again
|
||||
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
|
||||
assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para));
|
||||
assert_eq!(last_event(), super::Event::<Test>::AllRefunded { para_id: para }.into());
|
||||
|
||||
// Funds are returned
|
||||
@@ -1677,16 +1703,16 @@ mod tests {
|
||||
let issuance = Balances::total_issuance();
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
|
||||
|
||||
run_to_block(10);
|
||||
// All funds are refunded
|
||||
assert_ok!(Crowdloan::refund(Origin::signed(2), para));
|
||||
assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(2), para));
|
||||
|
||||
// Now that `fund.raised` is zero, it can be dissolved.
|
||||
assert_ok!(Crowdloan::dissolve(Origin::signed(1), para));
|
||||
assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para));
|
||||
assert_eq!(Balances::free_balance(1), 1000);
|
||||
assert_eq!(Balances::free_balance(2), 2000);
|
||||
assert_eq!(Balances::free_balance(3), 3000);
|
||||
@@ -1701,13 +1727,13 @@ mod tests {
|
||||
let issuance = Balances::total_issuance();
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
|
||||
|
||||
// Can't dissolve before it ends
|
||||
assert_noop!(
|
||||
Crowdloan::dissolve(Origin::signed(1), para),
|
||||
Crowdloan::dissolve(RuntimeOrigin::signed(1), para),
|
||||
Error::<Test>::NotReadyToDissolve
|
||||
);
|
||||
|
||||
@@ -1715,22 +1741,22 @@ mod tests {
|
||||
set_winner(para, 1, true);
|
||||
// Can't dissolve when it won.
|
||||
assert_noop!(
|
||||
Crowdloan::dissolve(Origin::signed(1), para),
|
||||
Crowdloan::dissolve(RuntimeOrigin::signed(1), para),
|
||||
Error::<Test>::NotReadyToDissolve
|
||||
);
|
||||
set_winner(para, 1, false);
|
||||
|
||||
// Can't dissolve while it still has user funds
|
||||
assert_noop!(
|
||||
Crowdloan::dissolve(Origin::signed(1), para),
|
||||
Crowdloan::dissolve(RuntimeOrigin::signed(1), para),
|
||||
Error::<Test>::NotReadyToDissolve
|
||||
);
|
||||
|
||||
// All funds are refunded
|
||||
assert_ok!(Crowdloan::refund(Origin::signed(2), para));
|
||||
assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(2), para));
|
||||
|
||||
// Now that `fund.raised` is zero, it can be dissolved.
|
||||
assert_ok!(Crowdloan::dissolve(Origin::signed(1), para));
|
||||
assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para));
|
||||
assert_eq!(Balances::free_balance(1), 1000);
|
||||
assert_eq!(Balances::free_balance(2), 2000);
|
||||
assert_eq!(Balances::free_balance(3), 3000);
|
||||
@@ -1746,17 +1772,17 @@ mod tests {
|
||||
let account_id = Crowdloan::fund_account_id(index);
|
||||
|
||||
// Set up a crowdloan
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
|
||||
|
||||
// Fund crowdloans.
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
|
||||
// simulate the reserving of para's funds. this actually happens in the Slots pallet.
|
||||
assert_ok!(Balances::reserve(&account_id, 150));
|
||||
|
||||
run_to_block(19);
|
||||
assert_noop!(
|
||||
Crowdloan::withdraw(Origin::signed(2), 2, para),
|
||||
Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para),
|
||||
Error::<Test>::BidOrLeaseActive
|
||||
);
|
||||
|
||||
@@ -1772,11 +1798,11 @@ mod tests {
|
||||
assert_eq!(Balances::free_balance(2), 1900);
|
||||
assert_eq!(Balances::free_balance(3), 2950);
|
||||
|
||||
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para));
|
||||
assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para));
|
||||
assert_eq!(Balances::free_balance(&account_id), 50);
|
||||
assert_eq!(Balances::free_balance(2), 2000);
|
||||
|
||||
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 3, para));
|
||||
assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 3, para));
|
||||
assert_eq!(Balances::free_balance(&account_id), 0);
|
||||
assert_eq!(Balances::free_balance(3), 3000);
|
||||
});
|
||||
@@ -1789,11 +1815,11 @@ mod tests {
|
||||
let para_2 = new_para();
|
||||
|
||||
// Set up crowdloans
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para_2, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_2, 1000, 1, 1, 9, None));
|
||||
// Different contributions
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(3), para_2, 50, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para_2, 50, None));
|
||||
// Original state
|
||||
assert_eq!(Funds::<Test>::get(para_1).unwrap().raised, 100);
|
||||
assert_eq!(Funds::<Test>::get(para_2).unwrap().raised, 50);
|
||||
@@ -1810,10 +1836,10 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
let para_1 = new_para();
|
||||
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
// Cannot create a fund again
|
||||
assert_noop!(
|
||||
Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None),
|
||||
Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None),
|
||||
Error::<Test>::FundNotEnded,
|
||||
);
|
||||
});
|
||||
@@ -1824,11 +1850,11 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
let para_1 = new_para();
|
||||
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None));
|
||||
let old_crowdloan = Crowdloan::funds(para_1).unwrap();
|
||||
|
||||
assert_ok!(Crowdloan::edit(Origin::root(), para_1, 1234, 2, 3, 4, None));
|
||||
assert_ok!(Crowdloan::edit(RuntimeOrigin::root(), para_1, 1234, 2, 3, 4, None));
|
||||
let new_crowdloan = Crowdloan::funds(para_1).unwrap();
|
||||
|
||||
// Some things stay the same
|
||||
@@ -1848,25 +1874,29 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
let para_1 = new_para();
|
||||
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
// Cant add a memo before you have contributed.
|
||||
assert_noop!(
|
||||
Crowdloan::add_memo(Origin::signed(1), para_1, b"hello, world".to_vec()),
|
||||
Crowdloan::add_memo(RuntimeOrigin::signed(1), para_1, b"hello, world".to_vec()),
|
||||
Error::<Test>::NoContributions,
|
||||
);
|
||||
// Make a contribution. Initially no memo.
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(1), para_1, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para_1, 100, None));
|
||||
assert_eq!(Crowdloan::contribution_get(0u32, &1), (100, vec![]));
|
||||
// Can't place a memo that is too large.
|
||||
assert_noop!(
|
||||
Crowdloan::add_memo(Origin::signed(1), para_1, vec![123; 123]),
|
||||
Crowdloan::add_memo(RuntimeOrigin::signed(1), para_1, vec![123; 123]),
|
||||
Error::<Test>::MemoTooLarge,
|
||||
);
|
||||
// Adding a memo to an existing contribution works
|
||||
assert_ok!(Crowdloan::add_memo(Origin::signed(1), para_1, b"hello, world".to_vec()));
|
||||
assert_ok!(Crowdloan::add_memo(
|
||||
RuntimeOrigin::signed(1),
|
||||
para_1,
|
||||
b"hello, world".to_vec()
|
||||
));
|
||||
assert_eq!(Crowdloan::contribution_get(0u32, &1), (100, b"hello, world".to_vec()));
|
||||
// Can contribute again and data persists
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(1), para_1, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para_1, 100, None));
|
||||
assert_eq!(Crowdloan::contribution_get(0u32, &1), (200, b"hello, world".to_vec()));
|
||||
});
|
||||
}
|
||||
@@ -1877,18 +1907,18 @@ mod tests {
|
||||
let para_1 = new_para();
|
||||
|
||||
assert_ok!(TestAuctioneer::new_auction(5, 0));
|
||||
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
// Should fail when no contributions.
|
||||
assert_noop!(
|
||||
Crowdloan::poke(Origin::signed(1), para_1),
|
||||
Crowdloan::poke(RuntimeOrigin::signed(1), para_1),
|
||||
Error::<Test>::NoContributions
|
||||
);
|
||||
assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None));
|
||||
run_to_block(6);
|
||||
assert_ok!(Crowdloan::poke(Origin::signed(1), para_1));
|
||||
assert_ok!(Crowdloan::poke(RuntimeOrigin::signed(1), para_1));
|
||||
assert_eq!(Crowdloan::new_raise(), vec![para_1]);
|
||||
assert_noop!(
|
||||
Crowdloan::poke(Origin::signed(1), para_1),
|
||||
Crowdloan::poke(RuntimeOrigin::signed(1), para_1),
|
||||
Error::<Test>::AlreadyInNewRaise
|
||||
);
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ mod tests {
|
||||
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -61,9 +61,9 @@ fn account_id(i: u32) -> AccountId32 {
|
||||
array.into()
|
||||
}
|
||||
|
||||
fn signed(i: u32) -> Origin {
|
||||
fn signed(i: u32) -> RuntimeOrigin {
|
||||
let account_id = account_id(i);
|
||||
Origin::signed(account_id)
|
||||
RuntimeOrigin::signed(account_id)
|
||||
}
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
@@ -112,7 +112,7 @@ impl frame_system::Config for Test {
|
||||
type BlockWeights = BlockWeights;
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
@@ -218,7 +218,7 @@ impl paras_registrar::Config for Test {
|
||||
type ParaDeposit = ParaDeposit;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type Currency = Balances;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type WeightInfo = crate::paras_registrar::TestWeightInfo;
|
||||
}
|
||||
|
||||
@@ -389,7 +389,11 @@ fn basic_end_to_end_works() {
|
||||
// Start a new auction in the future
|
||||
let duration = 99u32 + offset;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// 2 sessions later they are parathreads
|
||||
run_to_session(2);
|
||||
@@ -557,7 +561,11 @@ fn basic_errors_fail() {
|
||||
// Start an auction
|
||||
let duration = 99u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// Cannot create a crowdloan if you do not own the para
|
||||
assert_noop!(
|
||||
@@ -600,7 +608,11 @@ fn competing_slots() {
|
||||
// Start a new auction in the future
|
||||
let duration = 149u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// Paras should be onboarded
|
||||
run_to_block(20); // session 2
|
||||
@@ -697,7 +709,11 @@ fn competing_bids() {
|
||||
let starting_block = System::block_number();
|
||||
let duration = 99u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
for n in 1..=3 {
|
||||
// Create a crowdloan for each para
|
||||
@@ -799,7 +815,11 @@ fn basic_swap_works() {
|
||||
// Start a new auction in the future
|
||||
let duration = 99u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// 2 sessions later they are parathreads
|
||||
run_to_session(2);
|
||||
@@ -955,7 +975,11 @@ fn parachain_swap_works() {
|
||||
let unique_id = winner - 1999u32;
|
||||
let starting_block = System::block_number();
|
||||
let duration = 99u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// 2 sessions later they are parathreads
|
||||
run_to_block(starting_block + 20);
|
||||
@@ -1106,7 +1130,11 @@ fn crowdloan_ending_period_bid() {
|
||||
// Start a new auction in the future
|
||||
let duration = 99u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// 2 sessions later they are parathreads
|
||||
run_to_session(2);
|
||||
@@ -1182,7 +1210,11 @@ fn auction_bid_requires_registered_para() {
|
||||
// Start a new auction in the future
|
||||
let duration = 99u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// Can't bid with non-registered paras
|
||||
Balances::make_free_balance_be(&account_id(1), 1_000_000_000);
|
||||
@@ -1244,7 +1276,11 @@ fn gap_bids_work() {
|
||||
// Start a new auction in the future
|
||||
let duration = 99u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
Balances::make_free_balance_be(&account_id(1), 1_000_000_000);
|
||||
Balances::make_free_balance_be(&account_id(2), 1_000_000_000);
|
||||
|
||||
@@ -1432,7 +1468,11 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
let starting_block = System::block_number();
|
||||
let duration = 99u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// 2 sessions later they are parathreads
|
||||
run_to_session(2);
|
||||
@@ -1480,7 +1520,11 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
let starting_block = System::block_number();
|
||||
let duration = 99u32;
|
||||
let lease_period_index_start = 4u32;
|
||||
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
|
||||
assert_ok!(Auctions::new_auction(
|
||||
RuntimeOrigin::root(),
|
||||
duration,
|
||||
lease_period_index_start
|
||||
));
|
||||
|
||||
// Poke the crowdloan into `NewRaise`
|
||||
assert_ok!(Crowdloan::poke(signed(1), ParaId::from(2000)));
|
||||
@@ -1492,7 +1536,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
// Bids cannot be made which intersect
|
||||
assert_noop!(
|
||||
Auctions::bid(
|
||||
Origin::signed(crowdloan_account.clone()),
|
||||
RuntimeOrigin::signed(crowdloan_account.clone()),
|
||||
ParaId::from(2000),
|
||||
2,
|
||||
lease_period_index_start + 0,
|
||||
@@ -1504,7 +1548,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
|
||||
assert_noop!(
|
||||
Auctions::bid(
|
||||
Origin::signed(crowdloan_account.clone()),
|
||||
RuntimeOrigin::signed(crowdloan_account.clone()),
|
||||
ParaId::from(2000),
|
||||
2,
|
||||
lease_period_index_start + 1,
|
||||
@@ -1516,7 +1560,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
|
||||
assert_noop!(
|
||||
Auctions::bid(
|
||||
Origin::signed(crowdloan_account.clone()),
|
||||
RuntimeOrigin::signed(crowdloan_account.clone()),
|
||||
ParaId::from(2000),
|
||||
2,
|
||||
lease_period_index_start - 1,
|
||||
@@ -1528,7 +1572,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
|
||||
assert_noop!(
|
||||
Auctions::bid(
|
||||
Origin::signed(crowdloan_account.clone()),
|
||||
RuntimeOrigin::signed(crowdloan_account.clone()),
|
||||
ParaId::from(2000),
|
||||
2,
|
||||
lease_period_index_start + 0,
|
||||
@@ -1540,7 +1584,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
|
||||
assert_noop!(
|
||||
Auctions::bid(
|
||||
Origin::signed(crowdloan_account.clone()),
|
||||
RuntimeOrigin::signed(crowdloan_account.clone()),
|
||||
ParaId::from(2000),
|
||||
2,
|
||||
lease_period_index_start + 1,
|
||||
@@ -1552,7 +1596,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
|
||||
assert_noop!(
|
||||
Auctions::bid(
|
||||
Origin::signed(crowdloan_account.clone()),
|
||||
RuntimeOrigin::signed(crowdloan_account.clone()),
|
||||
ParaId::from(2000),
|
||||
2,
|
||||
lease_period_index_start - 1,
|
||||
@@ -1564,7 +1608,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
|
||||
// Will work when not overlapping
|
||||
assert_ok!(Auctions::bid(
|
||||
Origin::signed(crowdloan_account.clone()),
|
||||
RuntimeOrigin::signed(crowdloan_account.clone()),
|
||||
ParaId::from(2000),
|
||||
2,
|
||||
lease_period_index_start + 2,
|
||||
|
||||
@@ -102,8 +102,8 @@ pub mod pallet {
|
||||
/// infallibly convert between this origin and the system origin, but in reality, they're the
|
||||
/// same type, we just can't express that to the Rust type system without writing a `where`
|
||||
/// clause everywhere.
|
||||
type Origin: From<<Self as frame_system::Config>::Origin>
|
||||
+ Into<result::Result<Origin, <Self as Config>::Origin>>;
|
||||
type RuntimeOrigin: From<<Self as frame_system::Config>::RuntimeOrigin>
|
||||
+ Into<result::Result<Origin, <Self as Config>::RuntimeOrigin>>;
|
||||
|
||||
/// The system's currency for parathread payment.
|
||||
type Currency: ReservableCurrency<Self::AccountId>;
|
||||
@@ -456,7 +456,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// Ensure the origin is one of Root, the `para` owner, or the `para` itself.
|
||||
/// If the origin is the `para` owner, the `para` must be unlocked.
|
||||
fn ensure_root_para_or_owner(
|
||||
origin: <T as frame_system::Config>::Origin,
|
||||
origin: <T as frame_system::Config>::RuntimeOrigin,
|
||||
id: ParaId,
|
||||
) -> DispatchResult {
|
||||
ensure_signed(origin.clone())
|
||||
@@ -469,7 +469,8 @@ impl<T: Config> Pallet<T> {
|
||||
})
|
||||
.or_else(|_| -> DispatchResult {
|
||||
// Else check if para origin...
|
||||
let caller_id = ensure_parachain(<T as Config>::Origin::from(origin.clone()))?;
|
||||
let caller_id =
|
||||
ensure_parachain(<T as Config>::RuntimeOrigin::from(origin.clone()))?;
|
||||
ensure!(caller_id == id, Error::<T>::NotOwner);
|
||||
Ok(())
|
||||
})
|
||||
@@ -648,7 +649,7 @@ mod tests {
|
||||
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
@@ -715,8 +716,8 @@ mod tests {
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type Currency = Balances;
|
||||
type OnSwap = MockSwap;
|
||||
type ParaDeposit = ParaDeposit;
|
||||
@@ -800,7 +801,7 @@ mod tests {
|
||||
ValidationCode(validation_code)
|
||||
}
|
||||
|
||||
fn para_origin(id: ParaId) -> Origin {
|
||||
fn para_origin(id: ParaId) -> RuntimeOrigin {
|
||||
runtime_parachains::Origin::Parachain(id).into()
|
||||
}
|
||||
|
||||
@@ -828,9 +829,9 @@ mod tests {
|
||||
// first para is not yet registered
|
||||
assert!(!Parachains::is_parathread(para_id));
|
||||
// We register the Para ID
|
||||
assert_ok!(Registrar::reserve(Origin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_id,
|
||||
test_genesis_head(32),
|
||||
test_validation_code(32),
|
||||
@@ -851,7 +852,7 @@ mod tests {
|
||||
assert!(Parachains::is_parathread(para_id));
|
||||
assert!(!Parachains::is_parachain(para_id));
|
||||
// Deregister it
|
||||
assert_ok!(Registrar::deregister(Origin::root(), para_id,));
|
||||
assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id,));
|
||||
run_to_session(8);
|
||||
// It is nothing
|
||||
assert!(!Parachains::is_parathread(para_id));
|
||||
@@ -865,10 +866,10 @@ mod tests {
|
||||
run_to_block(1);
|
||||
let para_id = LOWEST_PUBLIC_ID;
|
||||
assert!(!Parachains::is_parathread(para_id));
|
||||
assert_ok!(Registrar::reserve(Origin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
|
||||
assert_eq!(Balances::reserved_balance(&1), <Test as Config>::ParaDeposit::get());
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_id,
|
||||
test_genesis_head(32),
|
||||
test_validation_code(32),
|
||||
@@ -890,7 +891,7 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_id,
|
||||
test_genesis_head(max_head_size() as usize),
|
||||
test_validation_code(max_code_size() as usize),
|
||||
@@ -899,11 +900,11 @@ mod tests {
|
||||
);
|
||||
|
||||
// Successfully register para
|
||||
assert_ok!(Registrar::reserve(Origin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
|
||||
|
||||
assert_noop!(
|
||||
Registrar::register(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
para_id,
|
||||
test_genesis_head(max_head_size() as usize),
|
||||
test_validation_code(max_code_size() as usize),
|
||||
@@ -912,7 +913,7 @@ mod tests {
|
||||
);
|
||||
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_id,
|
||||
test_genesis_head(max_head_size() as usize),
|
||||
test_validation_code(max_code_size() as usize),
|
||||
@@ -920,12 +921,12 @@ mod tests {
|
||||
|
||||
run_to_session(2);
|
||||
|
||||
assert_ok!(Registrar::deregister(Origin::root(), para_id));
|
||||
assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id));
|
||||
|
||||
// Can't do it again
|
||||
assert_noop!(
|
||||
Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_id,
|
||||
test_genesis_head(max_head_size() as usize),
|
||||
test_validation_code(max_code_size() as usize),
|
||||
@@ -934,10 +935,10 @@ mod tests {
|
||||
);
|
||||
|
||||
// Head Size Check
|
||||
assert_ok!(Registrar::reserve(Origin::signed(2)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2)));
|
||||
assert_noop!(
|
||||
Registrar::register(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
para_id + 1,
|
||||
test_genesis_head((max_head_size() + 1) as usize),
|
||||
test_validation_code(max_code_size() as usize),
|
||||
@@ -948,7 +949,7 @@ mod tests {
|
||||
// Code Size Check
|
||||
assert_noop!(
|
||||
Registrar::register(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
para_id + 1,
|
||||
test_genesis_head(max_head_size() as usize),
|
||||
test_validation_code((max_code_size() + 1) as usize),
|
||||
@@ -958,7 +959,7 @@ mod tests {
|
||||
|
||||
// Needs enough funds for deposit
|
||||
assert_noop!(
|
||||
Registrar::reserve(Origin::signed(1337)),
|
||||
Registrar::reserve(RuntimeOrigin::signed(1337)),
|
||||
BalancesError::<Test, _>::InsufficientBalance
|
||||
);
|
||||
});
|
||||
@@ -970,16 +971,16 @@ mod tests {
|
||||
run_to_block(1);
|
||||
let para_id = LOWEST_PUBLIC_ID;
|
||||
assert!(!Parachains::is_parathread(para_id));
|
||||
assert_ok!(Registrar::reserve(Origin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_id,
|
||||
test_genesis_head(32),
|
||||
test_validation_code(32),
|
||||
));
|
||||
run_to_session(2);
|
||||
assert!(Parachains::is_parathread(para_id));
|
||||
assert_ok!(Registrar::deregister(Origin::root(), para_id,));
|
||||
assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id,));
|
||||
run_to_session(4);
|
||||
assert!(paras::Pallet::<Test>::lifecycle(para_id).is_none());
|
||||
assert_eq!(Balances::reserved_balance(&1), 0);
|
||||
@@ -992,9 +993,9 @@ mod tests {
|
||||
run_to_block(1);
|
||||
let para_id = LOWEST_PUBLIC_ID;
|
||||
assert!(!Parachains::is_parathread(para_id));
|
||||
assert_ok!(Registrar::reserve(Origin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_id,
|
||||
test_genesis_head(32),
|
||||
test_validation_code(32),
|
||||
@@ -1002,12 +1003,12 @@ mod tests {
|
||||
run_to_session(2);
|
||||
assert!(Parachains::is_parathread(para_id));
|
||||
// Owner check
|
||||
assert_noop!(Registrar::deregister(Origin::signed(2), para_id,), BadOrigin);
|
||||
assert_noop!(Registrar::deregister(RuntimeOrigin::signed(2), para_id,), BadOrigin);
|
||||
assert_ok!(Registrar::make_parachain(para_id));
|
||||
run_to_session(4);
|
||||
// Cant directly deregister parachain
|
||||
assert_noop!(
|
||||
Registrar::deregister(Origin::root(), para_id,),
|
||||
Registrar::deregister(RuntimeOrigin::root(), para_id,),
|
||||
Error::<Test>::NotParathread
|
||||
);
|
||||
});
|
||||
@@ -1019,16 +1020,16 @@ mod tests {
|
||||
// Successfully register first two parachains
|
||||
let para_1 = LOWEST_PUBLIC_ID;
|
||||
let para_2 = LOWEST_PUBLIC_ID + 1;
|
||||
assert_ok!(Registrar::reserve(Origin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_1,
|
||||
test_genesis_head(max_head_size() as usize),
|
||||
test_validation_code(max_code_size() as usize),
|
||||
));
|
||||
assert_ok!(Registrar::reserve(Origin::signed(2)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2)));
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
para_2,
|
||||
test_genesis_head(max_head_size() as usize),
|
||||
test_validation_code(max_code_size() as usize),
|
||||
@@ -1075,17 +1076,17 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_ok!(Registrar::reserve(Origin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
|
||||
let para_id = LOWEST_PUBLIC_ID;
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_id,
|
||||
vec![1; 3].into(),
|
||||
vec![1, 2, 3].into(),
|
||||
));
|
||||
|
||||
// Owner can call swap
|
||||
assert_ok!(Registrar::swap(Origin::signed(1), para_id, para_id + 1));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::signed(1), para_id, para_id + 1));
|
||||
|
||||
// 2 session changes to fully onboard.
|
||||
run_to_session(2);
|
||||
@@ -1095,7 +1096,10 @@ mod tests {
|
||||
assert_ok!(Registrar::make_parachain(para_id));
|
||||
|
||||
// Owner cannot call swap anymore
|
||||
assert_noop!(Registrar::swap(Origin::signed(1), para_id, para_id + 2), BadOrigin);
|
||||
assert_noop!(
|
||||
Registrar::swap(RuntimeOrigin::signed(1), para_id, para_id + 2),
|
||||
BadOrigin
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1111,30 +1115,30 @@ mod tests {
|
||||
|
||||
// Cannot even start a swap
|
||||
assert_noop!(
|
||||
Registrar::swap(Origin::root(), para_1, para_2),
|
||||
Registrar::swap(RuntimeOrigin::root(), para_1, para_2),
|
||||
Error::<Test>::NotRegistered
|
||||
);
|
||||
|
||||
// We register Paras 1 and 2
|
||||
assert_ok!(Registrar::reserve(Origin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(Origin::signed(2)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
|
||||
assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2)));
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
para_1,
|
||||
test_genesis_head(32),
|
||||
test_validation_code(32),
|
||||
));
|
||||
assert_ok!(Registrar::register(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
para_2,
|
||||
test_genesis_head(32),
|
||||
test_validation_code(32),
|
||||
));
|
||||
|
||||
// Cannot swap
|
||||
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
|
||||
assert_noop!(
|
||||
Registrar::swap(Origin::root(), para_2, para_1),
|
||||
Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
|
||||
Error::<Test>::CannotSwap
|
||||
);
|
||||
|
||||
@@ -1145,9 +1149,9 @@ mod tests {
|
||||
assert!(Parachains::is_parathread(para_2));
|
||||
|
||||
// Cannot swap
|
||||
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
|
||||
assert_noop!(
|
||||
Registrar::swap(Origin::root(), para_2, para_1),
|
||||
Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
|
||||
Error::<Test>::CannotSwap
|
||||
);
|
||||
|
||||
@@ -1155,18 +1159,18 @@ mod tests {
|
||||
assert_ok!(Registrar::make_parachain(para_1));
|
||||
|
||||
// Cannot swap
|
||||
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
|
||||
assert_noop!(
|
||||
Registrar::swap(Origin::root(), para_2, para_1),
|
||||
Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
|
||||
Error::<Test>::CannotSwap
|
||||
);
|
||||
|
||||
run_to_session(3);
|
||||
|
||||
// Cannot swap
|
||||
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
|
||||
assert_noop!(
|
||||
Registrar::swap(Origin::root(), para_2, para_1),
|
||||
Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
|
||||
Error::<Test>::CannotSwap
|
||||
);
|
||||
|
||||
@@ -1177,15 +1181,15 @@ mod tests {
|
||||
assert!(Parachains::is_parathread(para_2));
|
||||
|
||||
// Swap works here.
|
||||
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2));
|
||||
assert_ok!(Registrar::swap(Origin::root(), para_2, para_1));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_2, para_1));
|
||||
|
||||
run_to_session(5);
|
||||
|
||||
// Cannot swap
|
||||
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
|
||||
assert_noop!(
|
||||
Registrar::swap(Origin::root(), para_2, para_1),
|
||||
Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
|
||||
Error::<Test>::CannotSwap
|
||||
);
|
||||
|
||||
@@ -1201,9 +1205,9 @@ mod tests {
|
||||
run_to_session(7);
|
||||
|
||||
// Cannot swap
|
||||
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2));
|
||||
assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
|
||||
assert_noop!(
|
||||
Registrar::swap(Origin::root(), para_2, para_1),
|
||||
Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
|
||||
Error::<Test>::CannotSwap
|
||||
);
|
||||
|
||||
@@ -1261,7 +1265,7 @@ mod benchmarking {
|
||||
}
|
||||
|
||||
benchmarks! {
|
||||
where_clause { where ParaOrigin: Into<<T as frame_system::Config>::Origin> }
|
||||
where_clause { where ParaOrigin: Into<<T as frame_system::Config>::RuntimeOrigin> }
|
||||
|
||||
reserve {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
|
||||
@@ -111,10 +111,10 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// The origin allowed to set account status.
|
||||
type ValidityOrigin: EnsureOrigin<Self::Origin>;
|
||||
type ValidityOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The origin allowed to make configurations to the pallet.
|
||||
type ConfigurationOrigin: EnsureOrigin<Self::Origin>;
|
||||
type ConfigurationOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The maximum statement length for the statement users to sign when creating an account.
|
||||
#[pallet::constant]
|
||||
@@ -510,7 +510,7 @@ mod tests {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
@@ -596,10 +596,14 @@ mod tests {
|
||||
fn setup() {
|
||||
let statement = b"Hello, World".to_vec();
|
||||
let unlock_block = 100;
|
||||
Purchase::set_statement(Origin::signed(configuration_origin()), statement).unwrap();
|
||||
Purchase::set_unlock_block(Origin::signed(configuration_origin()), unlock_block).unwrap();
|
||||
Purchase::set_payment_account(Origin::signed(configuration_origin()), payment_account())
|
||||
Purchase::set_statement(RuntimeOrigin::signed(configuration_origin()), statement).unwrap();
|
||||
Purchase::set_unlock_block(RuntimeOrigin::signed(configuration_origin()), unlock_block)
|
||||
.unwrap();
|
||||
Purchase::set_payment_account(
|
||||
RuntimeOrigin::signed(configuration_origin()),
|
||||
payment_account(),
|
||||
)
|
||||
.unwrap();
|
||||
Balances::make_free_balance_be(&payment_account(), 100_000);
|
||||
}
|
||||
|
||||
@@ -665,18 +669,21 @@ mod tests {
|
||||
let statement = b"Test Set Statement".to_vec();
|
||||
// Invalid origin
|
||||
assert_noop!(
|
||||
Purchase::set_statement(Origin::signed(alice()), statement.clone()),
|
||||
Purchase::set_statement(RuntimeOrigin::signed(alice()), statement.clone()),
|
||||
BadOrigin,
|
||||
);
|
||||
// Too Long
|
||||
let long_statement = [0u8; 10_000].to_vec();
|
||||
assert_noop!(
|
||||
Purchase::set_statement(Origin::signed(configuration_origin()), long_statement),
|
||||
Purchase::set_statement(
|
||||
RuntimeOrigin::signed(configuration_origin()),
|
||||
long_statement
|
||||
),
|
||||
Error::<Test>::InvalidStatement,
|
||||
);
|
||||
// Just right...
|
||||
assert_ok!(Purchase::set_statement(
|
||||
Origin::signed(configuration_origin()),
|
||||
RuntimeOrigin::signed(configuration_origin()),
|
||||
statement.clone()
|
||||
));
|
||||
assert_eq!(Statement::<Test>::get(), statement);
|
||||
@@ -689,7 +696,7 @@ mod tests {
|
||||
let unlock_block = 69;
|
||||
// Invalid origin
|
||||
assert_noop!(
|
||||
Purchase::set_unlock_block(Origin::signed(alice()), unlock_block),
|
||||
Purchase::set_unlock_block(RuntimeOrigin::signed(alice()), unlock_block),
|
||||
BadOrigin,
|
||||
);
|
||||
// Block Number in Past
|
||||
@@ -697,14 +704,14 @@ mod tests {
|
||||
System::set_block_number(bad_unlock_block);
|
||||
assert_noop!(
|
||||
Purchase::set_unlock_block(
|
||||
Origin::signed(configuration_origin()),
|
||||
RuntimeOrigin::signed(configuration_origin()),
|
||||
bad_unlock_block
|
||||
),
|
||||
Error::<Test>::InvalidUnlockBlock,
|
||||
);
|
||||
// Just right...
|
||||
assert_ok!(Purchase::set_unlock_block(
|
||||
Origin::signed(configuration_origin()),
|
||||
RuntimeOrigin::signed(configuration_origin()),
|
||||
unlock_block
|
||||
));
|
||||
assert_eq!(UnlockBlock::<Test>::get(), unlock_block);
|
||||
@@ -717,12 +724,15 @@ mod tests {
|
||||
let payment_account: AccountId = [69u8; 32].into();
|
||||
// Invalid Origin
|
||||
assert_noop!(
|
||||
Purchase::set_payment_account(Origin::signed(alice()), payment_account.clone()),
|
||||
Purchase::set_payment_account(
|
||||
RuntimeOrigin::signed(alice()),
|
||||
payment_account.clone()
|
||||
),
|
||||
BadOrigin,
|
||||
);
|
||||
// Just right...
|
||||
assert_ok!(Purchase::set_payment_account(
|
||||
Origin::signed(configuration_origin()),
|
||||
RuntimeOrigin::signed(configuration_origin()),
|
||||
payment_account.clone()
|
||||
));
|
||||
assert_eq!(PaymentAccount::<Test>::get(), Some(payment_account));
|
||||
@@ -753,7 +763,7 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert!(!Accounts::<Test>::contains_key(alice()));
|
||||
assert_ok!(Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
alice_signature().to_vec(),
|
||||
));
|
||||
@@ -776,7 +786,7 @@ mod tests {
|
||||
// Wrong Origin
|
||||
assert_noop!(
|
||||
Purchase::create_account(
|
||||
Origin::signed(alice()),
|
||||
RuntimeOrigin::signed(alice()),
|
||||
alice(),
|
||||
alice_signature().to_vec()
|
||||
),
|
||||
@@ -786,7 +796,7 @@ mod tests {
|
||||
// Wrong Account/Signature
|
||||
assert_noop!(
|
||||
Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
bob_signature().to_vec()
|
||||
),
|
||||
@@ -802,7 +812,7 @@ mod tests {
|
||||
));
|
||||
assert_noop!(
|
||||
Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
alice_signature().to_vec()
|
||||
),
|
||||
@@ -811,13 +821,13 @@ mod tests {
|
||||
|
||||
// Duplicate Purchasing Account
|
||||
assert_ok!(Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
bob(),
|
||||
bob_signature().to_vec()
|
||||
));
|
||||
assert_noop!(
|
||||
Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
bob(),
|
||||
bob_signature().to_vec()
|
||||
),
|
||||
@@ -831,19 +841,19 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Alice account is created.
|
||||
assert_ok!(Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
alice_signature().to_vec(),
|
||||
));
|
||||
// She submits KYC, and we update the status to `Pending`.
|
||||
assert_ok!(Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::Pending,
|
||||
));
|
||||
// KYC comes back negative, so we mark the account invalid.
|
||||
assert_ok!(Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::Invalid,
|
||||
));
|
||||
@@ -859,7 +869,7 @@ mod tests {
|
||||
);
|
||||
// She fixes it, we mark her account valid.
|
||||
assert_ok!(Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::ValidLow,
|
||||
));
|
||||
@@ -882,7 +892,7 @@ mod tests {
|
||||
// Wrong Origin
|
||||
assert_noop!(
|
||||
Purchase::update_validity_status(
|
||||
Origin::signed(alice()),
|
||||
RuntimeOrigin::signed(alice()),
|
||||
alice(),
|
||||
AccountValidity::Pending,
|
||||
),
|
||||
@@ -891,7 +901,7 @@ mod tests {
|
||||
// Inactive Account
|
||||
assert_noop!(
|
||||
Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::Pending,
|
||||
),
|
||||
@@ -899,18 +909,18 @@ mod tests {
|
||||
);
|
||||
// Already Completed
|
||||
assert_ok!(Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
alice_signature().to_vec(),
|
||||
));
|
||||
assert_ok!(Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::Completed,
|
||||
));
|
||||
assert_noop!(
|
||||
Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::Pending,
|
||||
),
|
||||
@@ -924,19 +934,19 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Alice account is created
|
||||
assert_ok!(Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
alice_signature().to_vec()
|
||||
));
|
||||
// And approved for basic contribution
|
||||
assert_ok!(Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::ValidLow,
|
||||
));
|
||||
// We set a balance on the user based on the payment they made. 50 locked, 50 free.
|
||||
assert_ok!(Purchase::update_balance(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
50,
|
||||
50,
|
||||
@@ -954,7 +964,7 @@ mod tests {
|
||||
);
|
||||
// We can update the balance based on new information.
|
||||
assert_ok!(Purchase::update_balance(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
25,
|
||||
50,
|
||||
@@ -978,13 +988,19 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Wrong Origin
|
||||
assert_noop!(
|
||||
Purchase::update_balance(Origin::signed(alice()), alice(), 50, 50, Permill::zero(),),
|
||||
Purchase::update_balance(
|
||||
RuntimeOrigin::signed(alice()),
|
||||
alice(),
|
||||
50,
|
||||
50,
|
||||
Permill::zero(),
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
// Inactive Account
|
||||
assert_noop!(
|
||||
Purchase::update_balance(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
50,
|
||||
50,
|
||||
@@ -995,7 +1011,7 @@ mod tests {
|
||||
// Overflow
|
||||
assert_noop!(
|
||||
Purchase::update_balance(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
u64::MAX,
|
||||
u64::MAX,
|
||||
@@ -1011,45 +1027,45 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Alice and Bob accounts are created
|
||||
assert_ok!(Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
alice_signature().to_vec()
|
||||
));
|
||||
assert_ok!(Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
bob(),
|
||||
bob_signature().to_vec()
|
||||
));
|
||||
// Alice is approved for basic contribution
|
||||
assert_ok!(Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::ValidLow,
|
||||
));
|
||||
// Bob is approved for high contribution
|
||||
assert_ok!(Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
bob(),
|
||||
AccountValidity::ValidHigh,
|
||||
));
|
||||
// We set a balance on the users based on the payment they made. 50 locked, 50 free.
|
||||
assert_ok!(Purchase::update_balance(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
50,
|
||||
50,
|
||||
Permill::zero(),
|
||||
));
|
||||
assert_ok!(Purchase::update_balance(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
bob(),
|
||||
100,
|
||||
150,
|
||||
Permill::zero(),
|
||||
));
|
||||
// Now we call payout for Alice and Bob.
|
||||
assert_ok!(Purchase::payout(Origin::signed(payment_account()), alice(),));
|
||||
assert_ok!(Purchase::payout(Origin::signed(payment_account()), bob(),));
|
||||
assert_ok!(Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),));
|
||||
assert_ok!(Purchase::payout(RuntimeOrigin::signed(payment_account()), bob(),));
|
||||
// Payment is made.
|
||||
assert_eq!(<Test as Config>::Currency::free_balance(&payment_account()), 99_650);
|
||||
assert_eq!(<Test as Config>::Currency::free_balance(&alice()), 100);
|
||||
@@ -1082,13 +1098,13 @@ mod tests {
|
||||
// Vesting lock is removed in whole on block 101 (100 blocks after block 1)
|
||||
System::set_block_number(100);
|
||||
let vest_call = RuntimeCall::Vesting(pallet_vesting::Call::<Test>::vest {});
|
||||
assert_ok!(vest_call.clone().dispatch(Origin::signed(alice())));
|
||||
assert_ok!(vest_call.clone().dispatch(Origin::signed(bob())));
|
||||
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice())));
|
||||
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob())));
|
||||
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), Some(45));
|
||||
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), Some(140));
|
||||
System::set_block_number(101);
|
||||
assert_ok!(vest_call.clone().dispatch(Origin::signed(alice())));
|
||||
assert_ok!(vest_call.clone().dispatch(Origin::signed(bob())));
|
||||
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice())));
|
||||
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob())));
|
||||
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), None);
|
||||
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), None);
|
||||
});
|
||||
@@ -1098,45 +1114,45 @@ mod tests {
|
||||
fn payout_handles_basic_errors() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Wrong Origin
|
||||
assert_noop!(Purchase::payout(Origin::signed(alice()), alice(),), BadOrigin);
|
||||
assert_noop!(Purchase::payout(RuntimeOrigin::signed(alice()), alice(),), BadOrigin);
|
||||
// Account with Existing Vesting Schedule
|
||||
assert_ok!(
|
||||
<Test as Config>::VestingSchedule::add_vesting_schedule(&bob(), 100, 1, 50,)
|
||||
);
|
||||
assert_noop!(
|
||||
Purchase::payout(Origin::signed(payment_account()), bob(),),
|
||||
Purchase::payout(RuntimeOrigin::signed(payment_account()), bob(),),
|
||||
Error::<Test>::VestingScheduleExists
|
||||
);
|
||||
// Invalid Account (never created)
|
||||
assert_noop!(
|
||||
Purchase::payout(Origin::signed(payment_account()), alice(),),
|
||||
Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
|
||||
Error::<Test>::InvalidAccount
|
||||
);
|
||||
// Invalid Account (created, but not valid)
|
||||
assert_ok!(Purchase::create_account(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
alice_signature().to_vec()
|
||||
));
|
||||
assert_noop!(
|
||||
Purchase::payout(Origin::signed(payment_account()), alice(),),
|
||||
Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
|
||||
Error::<Test>::InvalidAccount
|
||||
);
|
||||
// Not enough funds in payment account
|
||||
assert_ok!(Purchase::update_validity_status(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
AccountValidity::ValidHigh,
|
||||
));
|
||||
assert_ok!(Purchase::update_balance(
|
||||
Origin::signed(validity_origin()),
|
||||
RuntimeOrigin::signed(validity_origin()),
|
||||
alice(),
|
||||
100_000,
|
||||
100_000,
|
||||
Permill::zero(),
|
||||
));
|
||||
assert_noop!(
|
||||
Purchase::payout(Origin::signed(payment_account()), alice(),),
|
||||
Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
|
||||
BalancesError::<Test, _>::InsufficientBalance
|
||||
);
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ pub mod pallet {
|
||||
type LeaseOffset: Get<Self::BlockNumber>;
|
||||
|
||||
/// The origin which may forcibly create or clear leases. Root can always do this.
|
||||
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>;
|
||||
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
|
||||
|
||||
/// Weight Information for the Extrinsics in the Pallet
|
||||
type WeightInfo: WeightInfo;
|
||||
@@ -529,7 +529,7 @@ mod tests {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
@@ -847,7 +847,7 @@ mod tests {
|
||||
assert_eq!(Balances::reserved_balance(j), j * 10);
|
||||
}
|
||||
|
||||
assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into()));
|
||||
assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into()));
|
||||
|
||||
// Balances cleaned up correctly
|
||||
for i in 1u32..=max_num {
|
||||
@@ -925,21 +925,21 @@ mod tests {
|
||||
|
||||
// Para 1 should fail cause they don't have any leases
|
||||
assert_noop!(
|
||||
Slots::trigger_onboard(Origin::signed(1), 1.into()),
|
||||
Slots::trigger_onboard(RuntimeOrigin::signed(1), 1.into()),
|
||||
Error::<Test>::ParaNotOnboarding
|
||||
);
|
||||
|
||||
// Para 2 should succeed
|
||||
assert_ok!(Slots::trigger_onboard(Origin::signed(1), 2.into()));
|
||||
assert_ok!(Slots::trigger_onboard(RuntimeOrigin::signed(1), 2.into()));
|
||||
|
||||
// Para 3 should fail cause their lease is in the future
|
||||
assert_noop!(
|
||||
Slots::trigger_onboard(Origin::signed(1), 3.into()),
|
||||
Slots::trigger_onboard(RuntimeOrigin::signed(1), 3.into()),
|
||||
Error::<Test>::ParaNotOnboarding
|
||||
);
|
||||
|
||||
// Trying Para 2 again should fail cause they are not currently a parathread
|
||||
assert!(Slots::trigger_onboard(Origin::signed(1), 2.into()).is_err());
|
||||
assert!(Slots::trigger_onboard(RuntimeOrigin::signed(1), 2.into()).is_err());
|
||||
|
||||
assert_eq!(TestRegistrar::<Test>::operations(), vec![(2.into(), 1, true),]);
|
||||
});
|
||||
@@ -1025,7 +1025,7 @@ mod benchmarking {
|
||||
let period_begin = 69u32.into();
|
||||
let period_count = 3u32.into();
|
||||
let origin = T::ForceOrigin::successful_origin();
|
||||
}: _<T::Origin>(origin, para, leaser.clone(), amount, period_begin, period_count)
|
||||
}: _<T::RuntimeOrigin>(origin, para, leaser.clone(), amount, period_begin, period_count)
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::Leased {
|
||||
para_id: para,
|
||||
@@ -1119,7 +1119,7 @@ mod benchmarking {
|
||||
}
|
||||
|
||||
let origin = T::ForceOrigin::successful_origin();
|
||||
}: _<T::Origin>(origin, para)
|
||||
}: _<T::RuntimeOrigin>(origin, para)
|
||||
verify {
|
||||
for i in 0 .. max_people {
|
||||
let leaser = account("lease_deposit", i, 0);
|
||||
|
||||
Reference in New Issue
Block a user