mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 07:48:00 +00:00
Check Parachain is Fully Registered Before Starting a Crowdloan (#3018)
* Add check that parachain is fully registered before starting crowdloan * fix tests * fix benchmarks
This commit is contained in:
@@ -323,6 +323,7 @@ decl_module! {
|
||||
|
||||
let manager = T::Registrar::manager_of(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
ensure!(depositor == manager, Error::<T>::InvalidOrigin);
|
||||
ensure!(T::Registrar::is_registered(index), Error::<T>::InvalidParaId);
|
||||
|
||||
let trie_index = Self::next_trie_index();
|
||||
let new_trie_index = trie_index.checked_add(1).ok_or(Error::<T>::Overflow)?;
|
||||
@@ -1644,6 +1645,7 @@ mod benchmarking {
|
||||
|
||||
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?;
|
||||
T::Registrar::execute_pending_transitions();
|
||||
|
||||
}: _(RawOrigin::Signed(caller), para_id, cap, first_period, last_period, end, Some(verifier))
|
||||
verify {
|
||||
@@ -1721,6 +1723,7 @@ mod benchmarking {
|
||||
|
||||
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?;
|
||||
T::Registrar::execute_pending_transitions();
|
||||
|
||||
Crowdloan::<T>::create(
|
||||
RawOrigin::Signed(caller).into(),
|
||||
|
||||
@@ -570,10 +570,6 @@ fn competing_bids() {
|
||||
// This test will verify that competing bids, from different sources will resolve appropriately.
|
||||
new_test_ext().execute_with(|| {
|
||||
assert!(System::block_number().is_one());
|
||||
// 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));
|
||||
|
||||
let start_para = LOWEST_PUBLIC_ID - 1;
|
||||
// Create 3 paras and owners
|
||||
@@ -588,7 +584,18 @@ fn competing_bids() {
|
||||
genesis_head,
|
||||
validation_code,
|
||||
));
|
||||
}
|
||||
|
||||
// Finish registration of paras.
|
||||
run_to_session(2);
|
||||
|
||||
// Start a new auction in the future
|
||||
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));
|
||||
|
||||
for n in 1 ..= 3 {
|
||||
// Create a crowdloan for each para
|
||||
assert_ok!(Crowdloan::create(
|
||||
Origin::signed(n),
|
||||
@@ -603,7 +610,7 @@ fn competing_bids() {
|
||||
|
||||
for n in 1 ..= 9 {
|
||||
// Increment block number
|
||||
run_to_block(n * 10);
|
||||
run_to_block(starting_block + n * 10);
|
||||
|
||||
Balances::make_free_balance_be(&(n * 10), n * 1_000);
|
||||
|
||||
@@ -631,7 +638,7 @@ fn competing_bids() {
|
||||
}
|
||||
|
||||
// Auction should be done
|
||||
run_to_block(110);
|
||||
run_to_block(starting_block + 110);
|
||||
|
||||
// Appropriate Paras should have won slots
|
||||
let crowdloan_2 = Crowdloan::fund_account_id(ParaId::from(2001));
|
||||
|
||||
Reference in New Issue
Block a user