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

Add Many Sanity Checks to Crowdloans (#2745)

* Add many sanity checks to Crowdloans

* fix tests

* test contribution block in integration test

* fix rococo build

* remove leaser from crowdloans

* fix docs and terms

* fix compile
parent 1ccdacaf
Pipeline #131552 failed with stages
in 26 minutes and 44 seconds
......@@ -54,7 +54,7 @@ pub trait Config: frame_system::Config {
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
/// The number of blocks over which a single period lasts.
/// The type representing the leasing system.
type Leaser: Leaser<AccountId=Self::AccountId, LeasePeriod=Self::BlockNumber>;
/// The parachain registrar type.
......@@ -332,6 +332,14 @@ impl<T: Config> Auctioneer for Module<T> {
fn lease_period_index() -> Self::LeasePeriod {
T::Leaser::lease_period_index()
}
fn lease_period() -> Self::LeasePeriod {
T::Leaser::lease_period()
}
fn has_won_an_auction(para: ParaId, bidder: &T::AccountId) -> bool {
!T::Leaser::deposit_held(para, bidder).is_zero()
}
}
impl<T: Config> Module<T> {
......
This diff is collapsed.
......@@ -360,7 +360,7 @@ fn basic_end_to_end_works() {
910, // Amount
));
// User 2 will be a contribute to crowdfund for parachain 2
// 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));
......@@ -388,6 +388,10 @@ fn basic_end_to_end_works() {
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);
// New leases will start on block 400
let lease_start_block = 400;
run_to_block(lease_start_block);
......@@ -616,7 +620,7 @@ fn competing_bids() {
n * 900, // Amount
));
} else {
// User 20 will be a contribute to crowdfund for parachain 2
// User 20 will be a contribute to crowdloan for parachain 2
assert_ok!(Crowdloan::contribute(
Origin::signed(n * 10),
ParaId::from(para),
......
......@@ -174,6 +174,12 @@ pub trait Auctioneer {
/// Returns the current lease period.
fn lease_period_index() -> Self::LeasePeriod;
/// Returns the length of a lease period.
fn lease_period() -> Self::LeasePeriod;
/// Check if the para and user combination has won an auction in the past.
fn has_won_an_auction(para: ParaId, bidder: &Self::AccountId) -> bool;
}
/// Runtime hook for when we swap a parachain and parathread.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment