Unverified Commit f1c42ce6 authored by Shawn Tabrizi's avatar Shawn Tabrizi Committed by GitHub
Browse files

Introduce System Parachains into Registrar (#2858)

* initial stuff

* adjust deposit

* remove unused

* weight stuff

* Update integration_tests.rs

* Update paras_registrar.rs

* Update paras_registrar.rs

* add test

* Update paras_registrar.rs

Co-authored-by: parity-processbot <>
parent 11a9afa9
Pipeline #133855 failed with stages
in 20 minutes and 55 seconds
......@@ -131,11 +131,6 @@ impl Id {
pub const fn new(id: u32) -> Self {
Self(id)
}
/// Returns `true` if this parachain runs with system-level privileges.
/// Use IsSystem instead.
#[deprecated]
pub fn is_system(&self) -> bool { self.0 < USER_INDEX_START }
}
pub trait IsSystem {
......
......@@ -300,20 +300,20 @@ fn basic_end_to_end_works() {
let validation_code = Registrar::worst_validation_code();
assert_ok!(Registrar::register(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
genesis_head.clone(),
validation_code.clone(),
));
assert_ok!(Registrar::register(
Origin::signed(2),
ParaId::from(2),
ParaId::from(1002),
genesis_head,
validation_code,
));
// Paras should be onboarding
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Onboarding));
// Start a new auction in the future
let duration = 99u32;
......@@ -322,21 +322,21 @@ fn basic_end_to_end_works() {
// 2 sessions later they are parathreads
run_to_session(2);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread));
// Para 1 will bid directly for slot 1, 2
// Open a crowdloan for Para 2 for slot 3, 4
assert_ok!(Crowdloan::create(
Origin::signed(2),
ParaId::from(2),
ParaId::from(1002),
1_000, // Cap
lease_period_index_start + 2, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End
None,
));
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(2));
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1002));
// Auction ending begins on block 100, so we make a bid before then.
run_to_block(90);
......@@ -347,7 +347,7 @@ fn basic_end_to_end_works() {
// User 10 will bid directly for parachain 1
assert_ok!(Auctions::bid(
Origin::signed(10),
ParaId::from(1),
ParaId::from(1001),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
......@@ -356,13 +356,13 @@ fn basic_end_to_end_works() {
// User 2 will be a contribute to crowdloan for parachain 2
Balances::make_free_balance_be(&2, 1_000);
assert_ok!(Crowdloan::contribute(Origin::signed(2), ParaId::from(2), 920, None));
assert_ok!(Crowdloan::contribute(Origin::signed(2), ParaId::from(1002), 920, None));
// Auction ends at block 110
run_to_block(109);
assert_eq!(
last_event(),
crowdloan::RawEvent::HandleBidResult(ParaId::from(2), Ok(())).into(),
crowdloan::RawEvent::HandleBidResult(ParaId::from(1002), Ok(())).into(),
);
run_to_block(110);
assert_eq!(
......@@ -372,62 +372,62 @@ fn basic_end_to_end_works() {
// Paras should have won slots
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(1)),
slots::Leases::<Test>::get(ParaId::from(1001)),
// -- 1 --- 2 --- 3 --------- 4 ------------ 5 --------
vec![None, None, None, Some((10, 910)), Some((10, 910))],
);
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(2)),
slots::Leases::<Test>::get(ParaId::from(1002)),
// -- 1 --- 2 --- 3 --- 4 --- 5 ---------------- 6 --------------------------- 7 ----------------
vec![None, None, None, None, None, Some((crowdloan_account, 920)), Some((crowdloan_account, 920))],
);
// Should not be able to contribute to a winning crowdloan
Balances::make_free_balance_be(&3, 1_000);
assert_noop!(Crowdloan::contribute(Origin::signed(3), ParaId::from(2), 10, None), CrowdloanError::<Test>::BidOrLeaseActive);
assert_noop!(Crowdloan::contribute(Origin::signed(3), ParaId::from(1002), 10, None), CrowdloanError::<Test>::BidOrLeaseActive);
// New leases will start on block 400
let lease_start_block = 400;
run_to_block(lease_start_block);
// First slot, Para 1 should be transitioning to Parachain
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::UpgradingParathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::UpgradingParathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread));
// Two sessions later, it has upgraded
run_to_block(lease_start_block + 20);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread));
// Second slot nothing happens :)
run_to_block(lease_start_block + 100);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread));
// Third slot, Para 2 should be upgrading, and Para 1 is downgrading
run_to_block(lease_start_block + 200);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::DowngradingParachain));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::UpgradingParathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::DowngradingParachain));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::UpgradingParathread));
// Two sessions later, they have transitioned
run_to_block(lease_start_block + 220);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parachain));
// Fourth slot nothing happens :)
run_to_block(lease_start_block + 300);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parachain));
// Fifth slot, Para 2 is downgrading
run_to_block(lease_start_block + 400);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::DowngradingParachain));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::DowngradingParachain));
// Two sessions later, Para 2 is downgraded
run_to_block(lease_start_block + 420);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread));
});
}
......@@ -443,13 +443,13 @@ fn basic_errors_fail() {
let validation_code = Registrar::worst_validation_code();
assert_ok!(Registrar::register(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
genesis_head.clone(),
validation_code.clone(),
));
assert_noop!(Registrar::register(
Origin::signed(2),
ParaId::from(1),
ParaId::from(1001),
genesis_head,
validation_code,
), paras_registrar::Error::<Test>::AlreadyRegistered);
......@@ -462,7 +462,7 @@ fn basic_errors_fail() {
// Cannot create a crowdloan if you do not own the para
assert_noop!(Crowdloan::create(
Origin::signed(2),
ParaId::from(1),
ParaId::from(1001),
1_000, // Cap
lease_period_index_start + 2, // First Slot
lease_period_index_start + 3, // Last Slot
......@@ -486,7 +486,7 @@ fn competing_slots() {
let validation_code = Registrar::worst_validation_code();
assert_ok!(Registrar::register(
Origin::signed(n),
ParaId::from(n),
ParaId::from(1000 + n),
genesis_head,
validation_code,
));
......@@ -523,7 +523,7 @@ fn competing_slots() {
// Users will bid directly for parachain
assert_ok!(Auctions::bid(
Origin::signed(n * 10),
ParaId::from(n),
ParaId::from(1000 + n),
1, // Auction Index
lease_period_index_start + start, // First Slot
lease_period_index_start + end, // Last slot
......@@ -543,18 +543,18 @@ fn competing_slots() {
// 900 + 4500 + 2x 8100 = 21,600
// 900 + 4500 + 7200 + 9000 = 21,600
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(1)),
slots::Leases::<Test>::get(ParaId::from(1001)),
// -- 1 --- 2 --- 3 ---------- 4 ------
vec![None, None, None, Some((10, 900))],
);
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(5)),
slots::Leases::<Test>::get(ParaId::from(1005)),
// -- 1 --- 2 --- 3 --- 4 ---------- 5 -------
vec![None, None, None, None, Some((50, 4500))],
);
// TODO: Is this right?
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(9)),
slots::Leases::<Test>::get(ParaId::from(1009)),
// -- 1 --- 2 --- 3 --- 4 --- 5 ---------- 6 --------------- 7 -------
vec![None, None, None, None, None, Some((90, 8100)), Some((90, 8100))],
);
......@@ -578,7 +578,7 @@ fn competing_bids() {
let validation_code = Registrar::worst_validation_code();
assert_ok!(Registrar::register(
Origin::signed(n),
ParaId::from(n),
ParaId::from(1000 + n),
genesis_head,
validation_code,
));
......@@ -586,7 +586,7 @@ fn competing_bids() {
// Create a crowdloan for each para
assert_ok!(Crowdloan::create(
Origin::signed(n),
ParaId::from(n),
ParaId::from(1000 + n),
100_000, // Cap
lease_period_index_start + 2, // First Slot
lease_period_index_start + 3, // Last Slot
......@@ -601,7 +601,7 @@ fn competing_bids() {
Balances::make_free_balance_be(&(n * 10), n * 1_000);
let para = n % 3 + 1;
let para = n % 3 + 1001;
if n % 2 == 0 {
// User 10 will bid directly for parachain 1
......@@ -628,14 +628,14 @@ fn competing_bids() {
run_to_block(110);
// Appropriate Paras should have won slots
let crowdloan_2 = Crowdloan::fund_account_id(ParaId::from(2));
let crowdloan_2 = Crowdloan::fund_account_id(ParaId::from(1002));
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(1)),
slots::Leases::<Test>::get(ParaId::from(1001)),
// -- 1 --- 2 --- 3 --- 4 --- 5 ------------- 6 ------------------------ 7 -------------
vec![None, None, None, None, None, Some((crowdloan_2, 1812)), Some((crowdloan_2, 1812))],
);
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(3)),
slots::Leases::<Test>::get(ParaId::from(1003)),
// -- 1 --- 2 --- 3 ---------- 4 --------------- 5 -------
vec![None, None, None, Some((80, 7200)), Some((80, 7200))],
);
......@@ -653,20 +653,20 @@ fn basic_swap_works() {
// First register 2 parathreads with different data
assert_ok!(Registrar::register(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
test_genesis_head(10),
test_validation_code(10),
));
assert_ok!(Registrar::register(
Origin::signed(2),
ParaId::from(2),
ParaId::from(1002),
test_genesis_head(20),
test_validation_code(20),
));
// Paras should be onboarding
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Onboarding));
// Start a new auction in the future
let duration = 99u32;
......@@ -675,27 +675,26 @@ fn basic_swap_works() {
// 2 sessions later they are parathreads
run_to_session(2);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread));
// Open a crowdloan for Para 1 for slots 0-3
assert_ok!(Crowdloan::create(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
1_000_000, // Cap
lease_period_index_start + 0, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End
None,
));
// TODO: Check why this is the same for all paras
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1));
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1001));
// Bunch of contributions
let mut total = 0;
for i in 10 .. 20 {
Balances::make_free_balance_be(&i, 1_000);
assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(1), 900 - i, None));
assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(1001), 900 - i, None));
total += 900 - i;
}
assert!(total > 0);
......@@ -710,49 +709,49 @@ fn basic_swap_works() {
assert_eq!(Balances::reserved_balance(&2), 500 + 20 * 2 * 1);
assert_eq!(Balances::reserved_balance(&crowdloan_account), total);
// Crowdloan is appropriately set
assert!(Crowdloan::funds(ParaId::from(1)).is_some());
assert!(Crowdloan::funds(ParaId::from(2)).is_none());
assert!(Crowdloan::funds(ParaId::from(1001)).is_some());
assert!(Crowdloan::funds(ParaId::from(1002)).is_none());
// New leases will start on block 400
let lease_start_block = 400;
run_to_block(lease_start_block);
// Slots are won by Para 1
assert!(!Slots::lease(ParaId::from(1)).is_empty());
assert!(Slots::lease(ParaId::from(2)).is_empty());
assert!(!Slots::lease(ParaId::from(1001)).is_empty());
assert!(Slots::lease(ParaId::from(1002)).is_empty());
// 2 sessions later it is a parachain
run_to_block(lease_start_block + 20);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread));
// Initiate a swap
assert_ok!(Registrar::swap(para_origin(1).into(), ParaId::from(1), ParaId::from(2)));
assert_ok!(Registrar::swap(para_origin(2).into(), ParaId::from(2), ParaId::from(1)));
assert_ok!(Registrar::swap(para_origin(1001).into(), ParaId::from(1001), ParaId::from(1002)));
assert_ok!(Registrar::swap(para_origin(1002).into(), ParaId::from(1002), ParaId::from(1001)));
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::DowngradingParachain));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::UpgradingParathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::DowngradingParachain));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::UpgradingParathread));
// 2 session later they have swapped
run_to_block(lease_start_block + 40);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parachain));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parachain));
// Deregister parathread
assert_ok!(Registrar::deregister(para_origin(1).into(), ParaId::from(1)));
assert_ok!(Registrar::deregister(para_origin(1001).into(), ParaId::from(1001)));
// Correct deposit is unreserved
assert_eq!(Balances::reserved_balance(&1), 100); // crowdloan deposit left over
assert_eq!(Balances::reserved_balance(&2), 500 + 20 * 2 * 1);
// Crowdloan ownership is swapped
assert!(Crowdloan::funds(ParaId::from(1)).is_none());
assert!(Crowdloan::funds(ParaId::from(2)).is_some());
assert!(Crowdloan::funds(ParaId::from(1001)).is_none());
assert!(Crowdloan::funds(ParaId::from(1002)).is_some());
// Slot is swapped
assert!(Slots::lease(ParaId::from(1)).is_empty());
assert!(!Slots::lease(ParaId::from(2)).is_empty());
assert!(Slots::lease(ParaId::from(1001)).is_empty());
assert!(!Slots::lease(ParaId::from(1002)).is_empty());
// Cant dissolve
assert_noop!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(1)), CrowdloanError::<Test>::InvalidParaId);
assert_noop!(Crowdloan::dissolve(Origin::signed(2), ParaId::from(2)), CrowdloanError::<Test>::NotReadyToDissolve);
assert_noop!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(1001)), CrowdloanError::<Test>::InvalidParaId);
assert_noop!(Crowdloan::dissolve(Origin::signed(2), ParaId::from(1002)), CrowdloanError::<Test>::NotReadyToDissolve);
// Go way in the future when the para is offboarded
run_to_block(lease_start_block + 1000);
......@@ -760,17 +759,17 @@ fn basic_swap_works() {
// Withdraw of contributions works
assert_eq!(Balances::free_balance(&crowdloan_account), total);
for i in 10 .. 20 {
assert_ok!(Crowdloan::withdraw(Origin::signed(i), i, ParaId::from(2)));
assert_ok!(Crowdloan::withdraw(Origin::signed(i), i, ParaId::from(1002)));
}
assert_eq!(Balances::free_balance(&crowdloan_account), 0);
// Dissolve returns the balance of the person who put a deposit for crowdloan
assert_ok!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(2)));
assert_ok!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(1002)));
assert_eq!(Balances::reserved_balance(&1), 0);
assert_eq!(Balances::reserved_balance(&2), 500 + 20 * 2 * 1);
// Final deregister sets everything back to the start
assert_ok!(Registrar::deregister(para_origin(2).into(), ParaId::from(2)));
assert_ok!(Registrar::deregister(para_origin(1002).into(), ParaId::from(1002)));
assert_eq!(Balances::reserved_balance(&2), 0);
})
}
......@@ -785,20 +784,20 @@ fn crowdloan_ending_period_bid() {
// First register 2 parathreads
assert_ok!(Registrar::register(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
test_genesis_head(10),
test_validation_code(10),
));
assert_ok!(Registrar::register(
Origin::signed(2),
ParaId::from(2),
ParaId::from(1002),
test_genesis_head(20),
test_validation_code(20),
));
// Paras should be onboarding
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Onboarding));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Onboarding));
// Start a new auction in the future
let duration = 99u32;
......@@ -807,27 +806,26 @@ fn crowdloan_ending_period_bid() {
// 2 sessions later they are parathreads
run_to_session(2);
assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread));
// Open a crowdloan for Para 1 for slots 0-3
assert_ok!(Crowdloan::create(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
1_000_000, // Cap
lease_period_index_start + 0, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End
None,
));
// TODO: Check why this is the same for all paras
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1));
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1001));
// Bunch of contributions
let mut total = 0;
for i in 10 .. 20 {
Balances::make_free_balance_be(&i, 1_000);
assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(1), 900 - i, None));
assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(1001), 900 - i, None));
total += 900 - i;
}
assert!(total > 0);
......@@ -837,7 +835,7 @@ fn crowdloan_ending_period_bid() {
Balances::make_free_balance_be(&2, 1_000);
assert_ok!(Auctions::bid(
Origin::signed(2),
ParaId::from(2),
ParaId::from(1002),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
......@@ -852,9 +850,9 @@ fn crowdloan_ending_period_bid() {
assert_eq!(Auctions::winning(0), Some(
[
None, // 0-0
Some((2, ParaId::from(2), 900)), // 0-1
Some((2, ParaId::from(1002), 900)), // 0-1
None, // 0-2
Some((crowdloan_account, ParaId::from(1), total)), // 0-3
Some((crowdloan_account, ParaId::from(1001), total)), // 0-3
None, // 1-1
None, // 1-2
None, // 1-3
......@@ -867,16 +865,16 @@ fn crowdloan_ending_period_bid() {
run_to_block(101);
Balances::make_free_balance_be(&1234, 1_000);
assert_ok!(Crowdloan::contribute(Origin::signed(1234), ParaId::from(1), 900, None));
assert_ok!(Crowdloan::contribute(Origin::signed(1234), ParaId::from(1001), 900, None));
// Data propagates correctly
run_to_block(102);
assert_eq!(Auctions::winning(2), Some(
[
None, // 0-0
Some((2, ParaId::from(2), 900)), // 0-1
Some((2, ParaId::from(1002), 900)), // 0-1
None, // 0-2
Some((crowdloan_account, ParaId::from(1), total + 900)), // 0-3
Some((crowdloan_account, ParaId::from(1001), total + 900)), // 0-3
None, // 1-1
None, // 1-2
None, // 1-3
......@@ -902,7 +900,7 @@ fn auction_bid_requires_registered_para() {
Balances::make_free_balance_be(&1, 1_000);
assert_noop!(Auctions::bid(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
......@@ -912,7 +910,7 @@ fn auction_bid_requires_registered_para() {
// Now we register the para
assert_ok!(Registrar::register(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
test_genesis_head(10),
test_validation_code(10),
));
......@@ -920,7 +918,7 @@ fn auction_bid_requires_registered_para() {
// Still can't bid until it is fully onboarded
assert_noop!(Auctions::bid(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
......@@ -934,7 +932,7 @@ fn auction_bid_requires_registered_para() {
Balances::make_free_balance_be(&1, 1_000);
assert_ok!(Auctions::bid(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
......@@ -958,13 +956,13 @@ fn gap_bids_work() {
// Now register 2 paras
assert_ok!(Registrar::register(
Origin::signed(1),
ParaId::from(1),
ParaId::from(1001),
test_genesis_head(10),
test_validation_code(10),
));
assert_ok!(Registrar::register(
Origin::signed(2),
ParaId::from(2),
ParaId::from(1002),
test_genesis_head(10),
test_validation_code(10),
));
......@@ -978,7 +976,7 @@ fn gap_bids_work() {
// Slot 1 for 100 from 10
assert_ok!(Auctions::bid(
Origin::signed(10),
ParaId::from(1),
ParaId::from(1001),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 0, // Last slot
......@@ -987,7 +985,7 @@ fn gap_bids_work() {
// Slot 4 for 400 from 10
assert_ok!(Auctions::bid(
Origin::signed(10),
ParaId::from(1),
ParaId::from(1001),
1, // Auction Index
lease_period_index_start + 3, // First Slot
lease_period_index_start + 3, // Last slot
......@@ -997,7 +995,7 @@ fn gap_bids_work() {
// A bid for another para is counted separately.