Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Rename Origin (#6020)
Browse files Browse the repository at this point in the history
* 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 <>
  • Loading branch information
2 people authored and bredamatt committed Sep 27, 2022
1 parent bf90472 commit eab56e6
Show file tree
Hide file tree
Showing 46 changed files with 1,176 additions and 910 deletions.
344 changes: 172 additions & 172 deletions Cargo.lock

Large diffs are not rendered by default.

87 changes: 55 additions & 32 deletions runtime/common/src/assigned_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
});
Expand All @@ -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
);
});
Expand All @@ -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
);
});
Expand All @@ -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
);
});
Expand Down Expand Up @@ -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
);
});
Expand All @@ -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),
));

Expand Down Expand Up @@ -901,7 +919,7 @@ mod tests {

assert_noop!(
AssignedSlots::assign_temp_parachain_slot(
Origin::root(),
RuntimeOrigin::root(),
ParaId::from(1_u32),
SlotLeasePeriodStart::Current
),
Expand All @@ -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
),
Expand All @@ -941,7 +959,7 @@ mod tests {

assert_noop!(
AssignedSlots::assign_temp_parachain_slot(
Origin::root(),
RuntimeOrigin::root(),
ParaId::from(1_u32),
SlotLeasePeriodStart::Current
),
Expand All @@ -967,22 +985,22 @@ 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
),
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_temp_parachain_slot(
Origin::root(),
RuntimeOrigin::root(),
ParaId::from(1_u32),
SlotLeasePeriodStart::Current
),
Expand All @@ -1006,7 +1024,7 @@ mod tests {
));

assert_ok!(AssignedSlots::assign_temp_parachain_slot(
Origin::root(),
RuntimeOrigin::root(),
ParaId::from(n as u32),
SlotLeasePeriodStart::Current
));
Expand All @@ -1023,7 +1041,7 @@ mod tests {
));
assert_noop!(
AssignedSlots::assign_temp_parachain_slot(
Origin::root(),
RuntimeOrigin::root(),
ParaId::from(7_u32),
SlotLeasePeriodStart::Current
),
Expand All @@ -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
));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
);
});
Expand All @@ -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
);
});
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit eab56e6

Please sign in to comment.