Change Auctions to Eight Lease Periods Per Slot (#2862)

* initial patch

* fix tests

* fix benchmarks

* expose `SlotRange` consts

* Update Cargo.lock

* fix tests

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
Shawn Tabrizi
2021-04-10 10:20:53 +02:00
committed by GitHub
parent 6a15b6995f
commit 2c9a26e192
7 changed files with 110 additions and 220 deletions
@@ -39,6 +39,7 @@ use runtime_parachains::{
use frame_support_test::TestRandomness;
use crate::{
auctions, crowdloan, slots, paras_registrar,
slot_range::SlotRange,
traits::{
Registrar as RegistrarT, Auctioneer,
},
@@ -531,11 +532,6 @@ fn competing_slots() {
));
}
// All winner slots are filled by bids
for winner in &auctions::Winning::<Test>::get(0).unwrap() {
assert!(winner.is_some());
}
// Auction should be done after ending period
run_to_block(160);
@@ -846,21 +842,11 @@ fn crowdloan_ending_period_bid() {
run_to_block(100);
assert_eq!(Auctions::is_ending(100), Some(0));
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroOne as u8 as usize] = Some((2, ParaId::from(1002), 900));
winning[SlotRange::ZeroThree as u8 as usize] = Some((crowdloan_account, ParaId::from(1001), total));
assert_eq!(Auctions::winning(0), Some(
[
None, // 0-0
Some((2, ParaId::from(1002), 900)), // 0-1
None, // 0-2
Some((crowdloan_account, ParaId::from(1001), total)), // 0-3
None, // 1-1
None, // 1-2
None, // 1-3
None, // 2-2
None, // 2-3
None, // 3-3
]
));
assert_eq!(Auctions::winning(0), Some(winning));
run_to_block(101);
@@ -869,20 +855,10 @@ fn crowdloan_ending_period_bid() {
// Data propagates correctly
run_to_block(102);
assert_eq!(Auctions::winning(2), Some(
[
None, // 0-0
Some((2, ParaId::from(1002), 900)), // 0-1
None, // 0-2
Some((crowdloan_account, ParaId::from(1001), total + 900)), // 0-3
None, // 1-1
None, // 1-2
None, // 1-3
None, // 2-2
None, // 2-3
None, // 3-3
]
));
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroOne as u8 as usize] = Some((2, ParaId::from(1002), 900));
winning[SlotRange::ZeroThree as u8 as usize] = Some((crowdloan_account, ParaId::from(1001), total + 900));
assert_eq!(Auctions::winning(2), Some(winning));
})
}