cargo +nightly fmt (#3540)

* cargo +nightly fmt

* add cargo-fmt check to ci

* update ci

* fmt

* fmt

* skip macro

* ignore bridges
This commit is contained in:
Shawn Tabrizi
2021-08-02 12:47:33 +02:00
committed by GitHub
parent 30e3012270
commit ff5d56fb76
350 changed files with 20617 additions and 21266 deletions
+219 -155
View File
@@ -16,33 +16,28 @@
//! Mocking utilities for testing with real pallets.
use sp_std::sync::Arc;
use sp_io::TestExternalities;
use sp_core::{H256, crypto::KeyTypeId};
use sp_runtime::{
traits::{
BlakeTwo256, IdentityLookup, One,
},
use crate::{
auctions, crowdloan, paras_registrar,
slot_range::SlotRange,
slots,
traits::{AuctionStatus, Auctioneer, Registrar as RegistrarT},
};
use sp_keystore::{KeystoreExt, testing::KeyStore};
use primitives::v1::{BlockNumber, Header, Id as ParaId, ValidationCode, HeadData, LOWEST_PUBLIC_ID};
use frame_support::{
parameter_types, assert_ok, assert_noop, PalletId,
traits::{Currency, OnInitialize, OnFinalize, KeyOwnerProofSystem, GenesisBuild},
};
use frame_system::EnsureRoot;
use runtime_parachains::{
ParaLifecycle, Origin as ParaOrigin,
paras, configuration, shared,
assert_noop, assert_ok, parameter_types,
traits::{Currency, GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize},
PalletId,
};
use frame_support_test::TestRandomness;
use crate::{
auctions, crowdloan, slots, paras_registrar,
slot_range::SlotRange,
traits::{
Registrar as RegistrarT, Auctioneer, AuctionStatus,
},
use frame_system::EnsureRoot;
use primitives::v1::{
BlockNumber, HeadData, Header, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID,
};
use runtime_parachains::{configuration, paras, shared, Origin as ParaOrigin, ParaLifecycle};
use sp_core::{crypto::KeyTypeId, H256};
use sp_io::TestExternalities;
use sp_keystore::{testing::KeyStore, KeystoreExt};
use sp_runtime::traits::{BlakeTwo256, IdentityLookup, One};
use sp_std::sync::Arc;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
@@ -75,8 +70,7 @@ frame_support::construct_runtime!(
}
);
use crate::crowdloan::Error as CrowdloanError;
use crate::auctions::Error as AuctionsError;
use crate::{auctions::Error as AuctionsError, crowdloan::Error as CrowdloanError};
parameter_types! {
pub const BlockHashCount: u32 = 250;
@@ -121,8 +115,10 @@ impl pallet_babe::Config for Test {
type ExpectedBlockTime = ExpectedBlockTime;
type EpochChangeTrigger = pallet_babe::ExternalTrigger;
type KeyOwnerProofSystem = ();
type KeyOwnerProof =
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
KeyTypeId,
pallet_babe::AuthorityId,
)>>::Proof;
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
KeyTypeId,
pallet_babe::AuthorityId,
@@ -159,9 +155,9 @@ impl pallet_balances::Config for Test {
type ReserveIdentifier = [u8; 8];
}
impl configuration::Config for Test { }
impl configuration::Config for Test {}
impl shared::Config for Test { }
impl shared::Config for Test {}
impl paras::Config for Test {
type Origin = Origin;
@@ -236,14 +232,15 @@ pub fn new_test_ext() -> TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
GenesisBuild::<Test>::assimilate_storage(
&configuration::GenesisConfig {
config: configuration::HostConfiguration {
max_code_size: 2 * 1024 * 1024, // 2 MB
max_head_data_size: 1 * 1024 * 1024, // 1 MB
..Default::default()
}
config: configuration::HostConfiguration {
max_code_size: 2 * 1024 * 1024, // 2 MB
max_head_data_size: 1 * 1024 * 1024, // 1 MB
..Default::default()
},
&mut t
).unwrap();
},
&mut t,
)
.unwrap();
let keystore = KeyStore::new();
let mut ext: sp_io::TestExternalities = t.into();
ext.register_extension(KeystoreExt(Arc::new(keystore)));
@@ -255,9 +252,7 @@ const BLOCKS_PER_SESSION: u32 = 10;
fn maybe_new_session(n: u32) {
if n % BLOCKS_PER_SESSION == 0 {
shared::Pallet::<Test>::set_session_index(
shared::Pallet::<Test>::session_index() + 1
);
shared::Pallet::<Test>::set_session_index(shared::Pallet::<Test>::session_index() + 1);
Paras::test_on_new_session();
}
}
@@ -343,10 +338,10 @@ fn basic_end_to_end_works() {
assert_ok!(Crowdloan::create(
Origin::signed(2),
ParaId::from(para_2),
1_000, // Cap
1_000, // Cap
lease_period_index_start + 2, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End
200, // Block End
None,
));
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(para_2));
@@ -361,10 +356,10 @@ fn basic_end_to_end_works() {
assert_ok!(Auctions::bid(
Origin::signed(10),
ParaId::from(para_1),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
910, // Amount
910, // Amount
));
// User 2 will be a contribute to crowdloan for parachain 2
@@ -378,10 +373,7 @@ fn basic_end_to_end_works() {
crowdloan::Event::<Test>::HandleBidResult(ParaId::from(para_2), Ok(())).into(),
);
run_to_block(110);
assert_eq!(
last_event(),
auctions::Event::<Test>::AuctionClosed(1).into(),
);
assert_eq!(last_event(), auctions::Event::<Test>::AuctionClosed(1).into(),);
// Paras should have won slots
assert_eq!(
@@ -392,19 +384,33 @@ fn basic_end_to_end_works() {
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(para_2)),
// -- 1 --- 2 --- 3 --- 4 --- 5 ---------------- 6 --------------------------- 7 ----------------
vec![None, None, None, None, None, Some((crowdloan_account, 920)), Some((crowdloan_account, 920))],
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_000_000);
assert_noop!(Crowdloan::contribute(Origin::signed(3), ParaId::from(2001), 10, None), CrowdloanError::<Test>::BidOrLeaseActive);
assert_noop!(
Crowdloan::contribute(Origin::signed(3), ParaId::from(2001), 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(para_1)), Some(ParaLifecycle::UpgradingParathread));
assert_eq!(
Paras::lifecycle(ParaId::from(para_1)),
Some(ParaLifecycle::UpgradingParathread)
);
assert_eq!(Paras::lifecycle(ParaId::from(para_2)), Some(ParaLifecycle::Parathread));
// Two sessions later, it has upgraded
@@ -419,8 +425,14 @@ fn basic_end_to_end_works() {
// 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(para_1)), Some(ParaLifecycle::DowngradingParachain));
assert_eq!(Paras::lifecycle(ParaId::from(para_2)), Some(ParaLifecycle::UpgradingParathread));
assert_eq!(
Paras::lifecycle(ParaId::from(para_1)),
Some(ParaLifecycle::DowngradingParachain)
);
assert_eq!(
Paras::lifecycle(ParaId::from(para_2)),
Some(ParaLifecycle::UpgradingParathread)
);
// Two sessions later, they have transitioned
run_to_block(lease_start_block + 220);
@@ -435,7 +447,10 @@ fn basic_end_to_end_works() {
// Fifth slot, Para 2 is downgrading
run_to_block(lease_start_block + 400);
assert_eq!(Paras::lifecycle(ParaId::from(para_1)), Some(ParaLifecycle::Parathread));
assert_eq!(Paras::lifecycle(ParaId::from(para_2)), Some(ParaLifecycle::DowngradingParachain));
assert_eq!(
Paras::lifecycle(ParaId::from(para_2)),
Some(ParaLifecycle::DowngradingParachain)
);
// Two sessions later, Para 2 is downgraded
run_to_block(lease_start_block + 420);
@@ -463,12 +478,10 @@ fn basic_errors_fail() {
validation_code.clone(),
));
assert_ok!(Registrar::reserve(Origin::signed(2)));
assert_noop!(Registrar::register(
Origin::signed(2),
para_id,
genesis_head,
validation_code,
), paras_registrar::Error::<Test>::NotOwner);
assert_noop!(
Registrar::register(Origin::signed(2), para_id, genesis_head, validation_code,),
paras_registrar::Error::<Test>::NotOwner
);
// Start an auction
let duration = 99u32;
@@ -476,15 +489,18 @@ fn basic_errors_fail() {
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
// Cannot create a crowdloan if you do not own the para
assert_noop!(Crowdloan::create(
Origin::signed(2),
para_id,
1_000, // Cap
lease_period_index_start + 2, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End
None,
), crowdloan::Error::<Test>::InvalidOrigin);
assert_noop!(
Crowdloan::create(
Origin::signed(2),
para_id,
1_000, // Cap
lease_period_index_start + 2, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End
None,
),
crowdloan::Error::<Test>::InvalidOrigin
);
});
}
@@ -497,7 +513,7 @@ fn competing_slots() {
let para_id = LOWEST_PUBLIC_ID;
// Create n paras and owners
for n in 1 ..= max_bids {
for n in 1..=max_bids {
Balances::make_free_balance_be(&n, 1_000_000_000);
let genesis_head = Registrar::worst_head_data();
let validation_code = Registrar::worst_validation_code();
@@ -518,22 +534,22 @@ fn competing_slots() {
// Paras should be onboarded
run_to_block(20); // session 2
for n in 1 ..= max_bids {
for n in 1..=max_bids {
// Increment block number
run_to_block(System::block_number() + 10);
Balances::make_free_balance_be(&(n * 10), n * 1_000);
let (start, end) = match n {
1 => (0, 0),
2 => (0, 1),
3 => (0, 2),
4 => (0, 3),
5 => (1, 1),
6 => (1, 2),
7 => (1, 3),
8 => (2, 2),
9 => (2, 3),
1 => (0, 0),
2 => (0, 1),
3 => (0, 2),
4 => (0, 3),
5 => (1, 1),
6 => (1, 2),
7 => (1, 3),
8 => (2, 2),
9 => (2, 3),
10 => (3, 3),
_ => panic!("test not meant for this"),
};
@@ -542,10 +558,10 @@ fn competing_slots() {
assert_ok!(Auctions::bid(
Origin::signed(n * 10),
para_id + n - 1,
1, // Auction Index
1, // Auction Index
lease_period_index_start + start, // First Slot
lease_period_index_start + end, // Last slot
n * 900, // Amount
lease_period_index_start + end, // Last slot
n * 900, // Amount
));
}
@@ -582,7 +598,7 @@ fn competing_bids() {
let start_para = LOWEST_PUBLIC_ID - 1;
// Create 3 paras and owners
for n in 1 ..= 3 {
for n in 1..=3 {
Balances::make_free_balance_be(&n, 1_000_000_000);
let genesis_head = Registrar::worst_head_data();
let validation_code = Registrar::worst_validation_code();
@@ -604,20 +620,20 @@ fn competing_bids() {
let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start));
for n in 1 ..= 3 {
for n in 1..=3 {
// Create a crowdloan for each para
assert_ok!(Crowdloan::create(
Origin::signed(n),
ParaId::from(start_para + n),
100_000, // Cap
100_000, // Cap
lease_period_index_start + 2, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End,
200, // Block End,
None,
));
}
for n in 1 ..= 9 {
for n in 1..=9 {
// Increment block number
run_to_block(starting_block + n * 10);
@@ -630,10 +646,10 @@ fn competing_bids() {
assert_ok!(Auctions::bid(
Origin::signed(n * 10),
ParaId::from(para),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
n * 900, // Amount
n * 900, // Amount
));
} else {
// User 20 will be a contribute to crowdloan for parachain 2
@@ -654,7 +670,15 @@ fn competing_bids() {
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(2000)),
// -- 1 --- 2 --- 3 --- 4 --- 5 ------------- 6 ------------------------ 7 -------------
vec![None, None, None, None, None, Some((crowdloan_2, 1812)), Some((crowdloan_2, 1812))],
vec![
None,
None,
None,
None,
None,
Some((crowdloan_2, 1812)),
Some((crowdloan_2, 1812))
],
);
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(2002)),
@@ -669,7 +693,7 @@ fn basic_swap_works() {
// This test will test a swap between a parachain and parathread works successfully.
new_test_ext().execute_with(|| {
assert!(System::block_number().is_one()); // So events are emitted
// User 1 and 2 will own paras
// User 1 and 2 will own paras
Balances::make_free_balance_be(&1, 1_000_000_000);
Balances::make_free_balance_be(&2, 1_000_000_000);
// First register 2 parathreads with different data
@@ -706,17 +730,17 @@ fn basic_swap_works() {
assert_ok!(Crowdloan::create(
Origin::signed(1),
ParaId::from(2000),
1_000_000, // Cap
1_000_000, // Cap
lease_period_index_start + 0, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End
200, // Block End
None,
));
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(2000));
// Bunch of contributions
let mut total = 0;
for i in 10 .. 20 {
for i in 10..20 {
Balances::make_free_balance_be(&i, 1_000_000_000);
assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(2000), 900 - i, None));
total += 900 - i;
@@ -750,8 +774,16 @@ fn basic_swap_works() {
assert_eq!(Paras::lifecycle(ParaId::from(2001)), Some(ParaLifecycle::Parathread));
// Initiate a swap
assert_ok!(Registrar::swap(para_origin(2000).into(), ParaId::from(2000), ParaId::from(2001)));
assert_ok!(Registrar::swap(para_origin(2001).into(), ParaId::from(2001), ParaId::from(2000)));
assert_ok!(Registrar::swap(
para_origin(2000).into(),
ParaId::from(2000),
ParaId::from(2001)
));
assert_ok!(Registrar::swap(
para_origin(2001).into(),
ParaId::from(2001),
ParaId::from(2000)
));
assert_eq!(Paras::lifecycle(ParaId::from(2000)), Some(ParaLifecycle::DowngradingParachain));
assert_eq!(Paras::lifecycle(ParaId::from(2001)), Some(ParaLifecycle::UpgradingParathread));
@@ -774,15 +806,21 @@ fn basic_swap_works() {
assert!(!Slots::lease(ParaId::from(2001)).is_empty());
// Cant dissolve
assert_noop!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(2000)), CrowdloanError::<Test>::InvalidParaId);
assert_noop!(Crowdloan::dissolve(Origin::signed(2), ParaId::from(2001)), CrowdloanError::<Test>::NotReadyToDissolve);
assert_noop!(
Crowdloan::dissolve(Origin::signed(1), ParaId::from(2000)),
CrowdloanError::<Test>::InvalidParaId
);
assert_noop!(
Crowdloan::dissolve(Origin::signed(2), ParaId::from(2001)),
CrowdloanError::<Test>::NotReadyToDissolve
);
// Go way in the future when the para is offboarded
run_to_block(lease_start_block + 1000);
// Withdraw of contributions works
assert_eq!(Balances::free_balance(&crowdloan_account), total);
for i in 10 .. 20 {
for i in 10..20 {
assert_ok!(Crowdloan::withdraw(Origin::signed(i), i, ParaId::from(2001)));
}
assert_eq!(Balances::free_balance(&crowdloan_account), 0);
@@ -802,7 +840,7 @@ fn basic_swap_works() {
fn crowdloan_ending_period_bid() {
new_test_ext().execute_with(|| {
assert!(System::block_number().is_one()); // So events are emitted
// User 1 and 2 will own paras
// User 1 and 2 will own paras
Balances::make_free_balance_be(&1, 1_000_000_000);
Balances::make_free_balance_be(&2, 1_000_000_000);
// First register 2 parathreads
@@ -839,17 +877,17 @@ fn crowdloan_ending_period_bid() {
assert_ok!(Crowdloan::create(
Origin::signed(1),
ParaId::from(2000),
1_000_000, // Cap
1_000_000, // Cap
lease_period_index_start + 0, // First Slot
lease_period_index_start + 3, // Last Slot
200, // Block End
200, // Block End
None,
));
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(2000));
// Bunch of contributions
let mut total = 0;
for i in 10 .. 20 {
for i in 10..20 {
Balances::make_free_balance_be(&i, 1_000_000_000);
assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(2000), 900 - i, None));
total += 900 - i;
@@ -862,10 +900,10 @@ fn crowdloan_ending_period_bid() {
assert_ok!(Auctions::bid(
Origin::signed(2),
ParaId::from(2001),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
900, // Amount
900, // Amount
));
// Go to beginning of ending period
@@ -874,7 +912,8 @@ fn crowdloan_ending_period_bid() {
assert_eq!(Auctions::auction_status(100), AuctionStatus::<u32>::EndingPeriod(0, 0));
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroOne as u8 as usize] = Some((2, ParaId::from(2001), 900));
winning[SlotRange::ZeroThree as u8 as usize] = Some((crowdloan_account, ParaId::from(2000), total));
winning[SlotRange::ZeroThree as u8 as usize] =
Some((crowdloan_account, ParaId::from(2000), total));
assert_eq!(Auctions::winning(0), Some(winning));
@@ -887,7 +926,8 @@ fn crowdloan_ending_period_bid() {
run_to_block(102);
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroOne as u8 as usize] = Some((2, ParaId::from(2001), 900));
winning[SlotRange::ZeroThree as u8 as usize] = Some((crowdloan_account, ParaId::from(2000), total + 900));
winning[SlotRange::ZeroThree as u8 as usize] =
Some((crowdloan_account, ParaId::from(2000), total + 900));
assert_eq!(Auctions::winning(2), Some(winning));
})
}
@@ -904,14 +944,17 @@ fn auction_bid_requires_registered_para() {
// Can't bid with non-registered paras
Balances::make_free_balance_be(&1, 1_000_000_000);
assert_noop!(Auctions::bid(
Origin::signed(1),
ParaId::from(2000),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
900, // Amount
), AuctionsError::<Test>::ParaNotRegistered);
assert_noop!(
Auctions::bid(
Origin::signed(1),
ParaId::from(2000),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
900, // Amount
),
AuctionsError::<Test>::ParaNotRegistered
);
// Now we register the para
assert_ok!(Registrar::reserve(Origin::signed(1)));
@@ -923,14 +966,17 @@ fn auction_bid_requires_registered_para() {
));
// Still can't bid until it is fully onboarded
assert_noop!(Auctions::bid(
Origin::signed(1),
ParaId::from(2000),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
900, // Amount
), AuctionsError::<Test>::ParaNotRegistered);
assert_noop!(
Auctions::bid(
Origin::signed(1),
ParaId::from(2000),
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
900, // Amount
),
AuctionsError::<Test>::ParaNotRegistered
);
// Onboarded on Session 2
run_to_session(2);
@@ -940,10 +986,10 @@ fn auction_bid_requires_registered_para() {
assert_ok!(Auctions::bid(
Origin::signed(1),
ParaId::from(2000),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last slot
900, // Amount
900, // Amount
));
});
}
@@ -986,29 +1032,29 @@ fn gap_bids_work() {
assert_ok!(Auctions::bid(
Origin::signed(10),
ParaId::from(2000),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 0, // First Slot
lease_period_index_start + 0, // Last slot
100, // Amount
100, // Amount
));
// Slot 4 for 400 from 10
assert_ok!(Auctions::bid(
Origin::signed(10),
ParaId::from(2000),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 3, // First Slot
lease_period_index_start + 3, // Last slot
400, // Amount
400, // Amount
));
// A bid for another para is counted separately.
assert_ok!(Auctions::bid(
Origin::signed(10),
ParaId::from(2001),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 1, // First Slot
lease_period_index_start + 1, // Last slot
555, // Amount
555, // Amount
));
assert_eq!(Balances::reserved_balance(&10), 400 + 555);
@@ -1016,19 +1062,19 @@ fn gap_bids_work() {
assert_ok!(Auctions::bid(
Origin::signed(20),
ParaId::from(2000),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 1, // First Slot
lease_period_index_start + 1, // Last slot
800, // Amount
800, // Amount
));
// Slot 3 for 200 from 20
assert_ok!(Auctions::bid(
Origin::signed(20),
ParaId::from(2000),
1, // Auction Index
1, // Auction Index
lease_period_index_start + 2, // First Slot
lease_period_index_start + 2, // Last slot
200, // Amount
200, // Amount
));
// Finish the auction
@@ -1038,7 +1084,15 @@ fn gap_bids_work() {
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(2000)),
// -- 1 --- 2 --- 3 ---------- 4 -------------- 5 -------------- 6 -------------- 7 -------
vec![None, None, None, Some((10, 100)), Some((20, 800)), Some((20, 200)), Some((10, 400))],
vec![
None,
None,
None,
Some((10, 100)),
Some((20, 800)),
Some((20, 200)),
Some((10, 400))
],
);
// Appropriate amount is reserved (largest of the values)
assert_eq!(Balances::reserved_balance(&10), 400);
@@ -1125,17 +1179,17 @@ fn cant_bid_on_existing_lease_periods() {
assert_ok!(Crowdloan::create(
Origin::signed(1),
ParaId::from(2000),
1_000_000, // Cap
1_000_000, // Cap
lease_period_index_start + 0, // First Slot
lease_period_index_start + 1, // Last Slot
400, // Long block end
400, // Long block end
None,
));
let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(2000));
// Bunch of contributions
let mut total = 0;
for i in 10 .. 20 {
for i in 10..20 {
Balances::make_free_balance_be(&i, 1_000_000_000);
assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(2000), 900 - i, None));
total += 900 - i;
@@ -1150,7 +1204,13 @@ fn cant_bid_on_existing_lease_periods() {
assert_eq!(
slots::Leases::<Test>::get(ParaId::from(2000)),
// -- 1 --- 2 --- 3 ------------- 4 ------------------------ 5 -------------
vec![None, None, None, Some((crowdloan_account, 8855)), Some((crowdloan_account, 8855))],
vec![
None,
None,
None,
Some((crowdloan_account, 8855)),
Some((crowdloan_account, 8855))
],
);
// Let's start another auction for the same range
@@ -1175,7 +1235,8 @@ fn cant_bid_on_existing_lease_periods() {
lease_period_index_start + 0,
lease_period_index_start + 1,
100,
), AuctionsError::<Test>::AlreadyLeasedOut,
),
AuctionsError::<Test>::AlreadyLeasedOut,
);
assert_noop!(
@@ -1186,7 +1247,8 @@ fn cant_bid_on_existing_lease_periods() {
lease_period_index_start + 1,
lease_period_index_start + 2,
100,
), AuctionsError::<Test>::AlreadyLeasedOut,
),
AuctionsError::<Test>::AlreadyLeasedOut,
);
assert_noop!(
@@ -1197,7 +1259,8 @@ fn cant_bid_on_existing_lease_periods() {
lease_period_index_start - 1,
lease_period_index_start + 0,
100,
), AuctionsError::<Test>::AlreadyLeasedOut,
),
AuctionsError::<Test>::AlreadyLeasedOut,
);
assert_noop!(
@@ -1208,7 +1271,8 @@ fn cant_bid_on_existing_lease_periods() {
lease_period_index_start + 0,
lease_period_index_start + 0,
100,
), AuctionsError::<Test>::AlreadyLeasedOut,
),
AuctionsError::<Test>::AlreadyLeasedOut,
);
assert_noop!(
@@ -1219,7 +1283,8 @@ fn cant_bid_on_existing_lease_periods() {
lease_period_index_start + 1,
lease_period_index_start + 1,
100,
), AuctionsError::<Test>::AlreadyLeasedOut,
),
AuctionsError::<Test>::AlreadyLeasedOut,
);
assert_noop!(
@@ -1230,19 +1295,18 @@ fn cant_bid_on_existing_lease_periods() {
lease_period_index_start - 1,
lease_period_index_start + 5,
100,
), AuctionsError::<Test>::AlreadyLeasedOut,
),
AuctionsError::<Test>::AlreadyLeasedOut,
);
// Will work when not overlapping
assert_ok!(
Auctions::bid(
Origin::signed(crowdloan_account),
ParaId::from(2000),
2,
lease_period_index_start + 2,
lease_period_index_start + 3,
100,
)
);
assert_ok!(Auctions::bid(
Origin::signed(crowdloan_account),
ParaId::from(2000),
2,
lease_period_index_start + 2,
lease_period_index_start + 3,
100,
));
});
}