mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 10:51:10 +00:00
Update to latest Substrate master (#472)
* Update to latest Substrate master * Fix * Fix compilation
This commit is contained in:
committed by
Gavin Wood
parent
b1558157cb
commit
0efa39ce06
Generated
+304
-304
File diff suppressed because it is too large
Load Diff
@@ -114,4 +114,5 @@ std = [
|
|||||||
"babe/std",
|
"babe/std",
|
||||||
"babe-primitives/std",
|
"babe-primitives/std",
|
||||||
"substrate-session/std",
|
"substrate-session/std",
|
||||||
|
"randomness-collective-flip/std",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ use serde::{self, Serialize, Deserialize, Serializer, Deserializer};
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use sr_primitives::traits::Zero;
|
use sr_primitives::traits::Zero;
|
||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
weights::SimpleDispatchInfo,
|
weights::SimpleDispatchInfo, traits::ValidateUnsigned,
|
||||||
traits::ValidateUnsigned,
|
|
||||||
transaction_validity::{
|
transaction_validity::{
|
||||||
TransactionLongevity, TransactionValidity, ValidTransaction, InvalidTransaction
|
TransactionLongevity, TransactionValidity, ValidTransaction, InvalidTransaction
|
||||||
},
|
},
|
||||||
@@ -237,8 +236,7 @@ mod tests {
|
|||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use sr_io::with_externalities;
|
use substrate_primitives::H256;
|
||||||
use substrate_primitives::{H256, Blake2Hasher};
|
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
// The testing primitives are very useful for avoiding having to work with signatures
|
// The testing primitives are very useful for avoiding having to work with signatures
|
||||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||||
@@ -348,7 +346,7 @@ mod tests {
|
|||||||
|
|
||||||
// This function basically just builds a genesis storage key/value store according to
|
// This function basically just builds a genesis storage key/value store according to
|
||||||
// our desired mockup.
|
// our desired mockup.
|
||||||
fn new_test_ext() -> sr_io::TestExternalities<Blake2Hasher> {
|
fn new_test_ext() -> sr_io::TestExternalities {
|
||||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||||
// We use default for brevity, but you can configure as desired if needed.
|
// We use default for brevity, but you can configure as desired if needed.
|
||||||
balances::GenesisConfig::<Test>::default().assimilate_storage(&mut t).unwrap();
|
balances::GenesisConfig::<Test>::default().assimilate_storage(&mut t).unwrap();
|
||||||
@@ -360,7 +358,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_setup_works() {
|
fn basic_setup_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Claims::total(), 100);
|
assert_eq!(Claims::total(), 100);
|
||||||
assert_eq!(Claims::claims(&alice_eth()), Some(100));
|
assert_eq!(Claims::claims(&alice_eth()), Some(100));
|
||||||
assert_eq!(Claims::claims(&EthereumAddress::default()), None);
|
assert_eq!(Claims::claims(&EthereumAddress::default()), None);
|
||||||
@@ -378,7 +376,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn claiming_works() {
|
fn claiming_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(&42), 0);
|
assert_eq!(Balances::free_balance(&42), 0);
|
||||||
assert_ok!(Claims::claim(Origin::NONE, 42, alice_sig(&42u64.encode())));
|
assert_ok!(Claims::claim(Origin::NONE, 42, alice_sig(&42u64.encode())));
|
||||||
assert_eq!(Balances::free_balance(&42), 100);
|
assert_eq!(Balances::free_balance(&42), 100);
|
||||||
@@ -387,7 +385,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn origin_signed_claiming_fail() {
|
fn origin_signed_claiming_fail() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(&42), 0);
|
assert_eq!(Balances::free_balance(&42), 0);
|
||||||
assert_err!(
|
assert_err!(
|
||||||
Claims::claim(Origin::signed(42), 42, alice_sig(&42u64.encode())),
|
Claims::claim(Origin::signed(42), 42, alice_sig(&42u64.encode())),
|
||||||
@@ -398,7 +396,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn double_claiming_doesnt_work() {
|
fn double_claiming_doesnt_work() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(&42), 0);
|
assert_eq!(Balances::free_balance(&42), 0);
|
||||||
assert_ok!(Claims::claim(Origin::NONE, 42, alice_sig(&42u64.encode())));
|
assert_ok!(Claims::claim(Origin::NONE, 42, alice_sig(&42u64.encode())));
|
||||||
assert_noop!(Claims::claim(Origin::NONE, 42, alice_sig(&42u64.encode())), "Ethereum address has no claim");
|
assert_noop!(Claims::claim(Origin::NONE, 42, alice_sig(&42u64.encode())), "Ethereum address has no claim");
|
||||||
@@ -407,7 +405,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn non_sender_sig_doesnt_work() {
|
fn non_sender_sig_doesnt_work() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(&42), 0);
|
assert_eq!(Balances::free_balance(&42), 0);
|
||||||
assert_noop!(Claims::claim(Origin::NONE, 42, alice_sig(&69u64.encode())), "Ethereum address has no claim");
|
assert_noop!(Claims::claim(Origin::NONE, 42, alice_sig(&69u64.encode())), "Ethereum address has no claim");
|
||||||
});
|
});
|
||||||
@@ -415,7 +413,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn non_claimant_doesnt_work() {
|
fn non_claimant_doesnt_work() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(&42), 0);
|
assert_eq!(Balances::free_balance(&42), 0);
|
||||||
assert_noop!(Claims::claim(Origin::NONE, 42, bob_sig(&69u64.encode())), "Ethereum address has no claim");
|
assert_noop!(Claims::claim(Origin::NONE, 42, bob_sig(&69u64.encode())), "Ethereum address has no claim");
|
||||||
});
|
});
|
||||||
@@ -423,7 +421,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn real_eth_sig_works() {
|
fn real_eth_sig_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// "Pay RUSTs to the TEST account:2a00000000000000"
|
// "Pay RUSTs to the TEST account:2a00000000000000"
|
||||||
let sig = hex!["444023e89b67e67c0562ed0305d252a5dd12b2af5ac51d6d3cb69a0b486bc4b3191401802dc29d26d586221f7256cd3329fe82174bdf659baea149a40e1c495d1c"];
|
let sig = hex!["444023e89b67e67c0562ed0305d252a5dd12b2af5ac51d6d3cb69a0b486bc4b3191401802dc29d26d586221f7256cd3329fe82174bdf659baea149a40e1c495d1c"];
|
||||||
let sig = EcdsaSignature(sig);
|
let sig = EcdsaSignature(sig);
|
||||||
@@ -435,7 +433,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn validate_unsigned_works() {
|
fn validate_unsigned_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<Module<Test>>::validate_unsigned(&Call::claim(1, alice_sig(&1u64.encode()))),
|
<Module<Test>>::validate_unsigned(&Call::claim(1, alice_sig(&1u64.encode()))),
|
||||||
Ok(ValidTransaction {
|
Ok(ValidTransaction {
|
||||||
|
|||||||
@@ -502,9 +502,8 @@ mod tests {
|
|||||||
|
|
||||||
use std::{collections::HashMap, cell::RefCell};
|
use std::{collections::HashMap, cell::RefCell};
|
||||||
use srml_support::{impl_outer_origin, assert_ok, assert_noop, parameter_types};
|
use srml_support::{impl_outer_origin, assert_ok, assert_noop, parameter_types};
|
||||||
use sr_io::with_externalities;
|
use substrate_primitives::H256;
|
||||||
use substrate_primitives::{H256, Blake2Hasher};
|
use primitives::parachain::{Info as ParaInfo, Id as ParaId};
|
||||||
use primitives::parachain::Info as ParaInfo;
|
|
||||||
// The testing primitives are very useful for avoiding having to work with signatures
|
// The testing primitives are very useful for avoiding having to work with signatures
|
||||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
|
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
|
||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
@@ -639,6 +638,7 @@ mod tests {
|
|||||||
type Parachains = TestParachains;
|
type Parachains = TestParachains;
|
||||||
type LeasePeriod = LeasePeriod;
|
type LeasePeriod = LeasePeriod;
|
||||||
type EndingPeriod = EndingPeriod;
|
type EndingPeriod = EndingPeriod;
|
||||||
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
}
|
}
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const SubmissionDeposit: u64 = 1;
|
pub const SubmissionDeposit: u64 = 1;
|
||||||
@@ -658,10 +658,11 @@ mod tests {
|
|||||||
type Slots = slots::Module<Test>;
|
type Slots = slots::Module<Test>;
|
||||||
type Treasury = treasury::Module<Test>;
|
type Treasury = treasury::Module<Test>;
|
||||||
type Crowdfund = Module<Test>;
|
type Crowdfund = Module<Test>;
|
||||||
|
type RandomnessCollectiveFlip = randomness_collective_flip::Module<Test>;
|
||||||
|
|
||||||
// This function basically just builds a genesis storage key/value store according to
|
// This function basically just builds a genesis storage key/value store according to
|
||||||
// our desired mockup.
|
// our desired mockup.
|
||||||
fn new_test_ext() -> sr_io::TestExternalities<Blake2Hasher> {
|
fn new_test_ext() -> sr_io::TestExternalities {
|
||||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||||
balances::GenesisConfig::<Test>{
|
balances::GenesisConfig::<Test>{
|
||||||
balances: vec![(1, 1000), (2, 2000), (3, 3000), (4, 4000)],
|
balances: vec![(1, 1000), (2, 2000), (3, 3000), (4, 4000)],
|
||||||
@@ -688,7 +689,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_setup_works() {
|
fn basic_setup_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(System::block_number(), 1);
|
assert_eq!(System::block_number(), 1);
|
||||||
assert_eq!(Crowdfund::fund_count(), 0);
|
assert_eq!(Crowdfund::fund_count(), 0);
|
||||||
assert_eq!(Crowdfund::funds(0), None);
|
assert_eq!(Crowdfund::funds(0), None);
|
||||||
@@ -701,7 +702,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn create_works() {
|
fn create_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Now try to create a crowdfund campaign
|
// Now try to create a crowdfund campaign
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
assert_eq!(Crowdfund::fund_count(), 1);
|
assert_eq!(Crowdfund::fund_count(), 1);
|
||||||
@@ -732,7 +733,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn create_handles_basic_errors() {
|
fn create_handles_basic_errors() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Cannot create a crowdfund with bad slots
|
// Cannot create a crowdfund with bad slots
|
||||||
assert_noop!(Crowdfund::create(Origin::signed(1), 1000, 4, 1, 9), "last slot must be greater than first slot");
|
assert_noop!(Crowdfund::create(Origin::signed(1), 1000, 4, 1, 9), "last slot must be greater than first slot");
|
||||||
assert_noop!(Crowdfund::create(Origin::signed(1), 1000, 1, 5, 9), "last slot cannot be more then 3 more than first slot");
|
assert_noop!(Crowdfund::create(Origin::signed(1), 1000, 1, 5, 9), "last slot cannot be more then 3 more than first slot");
|
||||||
@@ -744,7 +745,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn contribute_works() {
|
fn contribute_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
assert_eq!(Balances::free_balance(1), 999);
|
assert_eq!(Balances::free_balance(1), 999);
|
||||||
@@ -774,7 +775,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn contribute_handles_basic_errors() {
|
fn contribute_handles_basic_errors() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Cannot contribute to non-existing fund
|
// Cannot contribute to non-existing fund
|
||||||
assert_noop!(Crowdfund::contribute(Origin::signed(1), 0, 49), "invalid fund index");
|
assert_noop!(Crowdfund::contribute(Origin::signed(1), 0, 49), "invalid fund index");
|
||||||
// Cannot contribute below minimum contribution
|
// Cannot contribute below minimum contribution
|
||||||
@@ -797,7 +798,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fix_deploy_data_works() {
|
fn fix_deploy_data_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
assert_eq!(Balances::free_balance(1), 999);
|
assert_eq!(Balances::free_balance(1), 999);
|
||||||
@@ -819,7 +820,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fix_deploy_data_handles_basic_errors() {
|
fn fix_deploy_data_handles_basic_errors() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
assert_eq!(Balances::free_balance(1), 999);
|
assert_eq!(Balances::free_balance(1), 999);
|
||||||
@@ -862,7 +863,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn onboard_works() {
|
fn onboard_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
@@ -897,7 +898,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn onboard_handles_basic_errors() {
|
fn onboard_handles_basic_errors() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
@@ -934,7 +935,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn begin_retirement_works() {
|
fn begin_retirement_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
@@ -976,7 +977,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn begin_retirement_handles_basic_errors() {
|
fn begin_retirement_handles_basic_errors() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
@@ -1020,7 +1021,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn withdraw_works() {
|
fn withdraw_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
@@ -1046,7 +1047,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn withdraw_handles_basic_errors() {
|
fn withdraw_handles_basic_errors() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
@@ -1070,7 +1071,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dissolve_works() {
|
fn dissolve_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
@@ -1105,7 +1106,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dissolve_handles_basic_errors() {
|
fn dissolve_handles_basic_errors() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Set up a crowdfund
|
// Set up a crowdfund
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
@@ -1137,7 +1138,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fund_before_auction_works() {
|
fn fund_before_auction_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Create a crowdfund before an auction is created
|
// Create a crowdfund before an auction is created
|
||||||
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
|
||||||
// Users can already contribute
|
// Users can already contribute
|
||||||
@@ -1175,7 +1176,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fund_across_multiple_auctions_works() {
|
fn fund_across_multiple_auctions_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
// Create an auction
|
// Create an auction
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
// Create two competing crowdfunds, with end dates across multiple auctions
|
// Create two competing crowdfunds, with end dates across multiple auctions
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ use version::NativeVersion;
|
|||||||
use substrate_primitives::OpaqueMetadata;
|
use substrate_primitives::OpaqueMetadata;
|
||||||
use sr_staking_primitives::SessionIndex;
|
use sr_staking_primitives::SessionIndex;
|
||||||
use srml_support::{
|
use srml_support::{
|
||||||
parameter_types, construct_runtime, traits::{SplitTwoWays, Currency}
|
parameter_types, construct_runtime, traits::{SplitTwoWays, Currency, Randomness}
|
||||||
};
|
};
|
||||||
use authority_discovery_primitives::{AuthorityId as EncodedAuthorityId, Signature as EncodedSignature};
|
use authority_discovery_primitives::{AuthorityId as EncodedAuthorityId, Signature as EncodedSignature};
|
||||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||||
@@ -480,6 +480,7 @@ impl parachains::Trait for Runtime {
|
|||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
type ParachainCurrency = Balances;
|
type ParachainCurrency = Balances;
|
||||||
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
type ActiveParachains = Registrar;
|
type ActiveParachains = Registrar;
|
||||||
type Registrar = Registrar;
|
type Registrar = Registrar;
|
||||||
}
|
}
|
||||||
@@ -511,6 +512,7 @@ impl slots::Trait for Runtime {
|
|||||||
type Parachains = Registrar;
|
type Parachains = Registrar;
|
||||||
type LeasePeriod = LeasePeriod;
|
type LeasePeriod = LeasePeriod;
|
||||||
type EndingPeriod = EndingPeriod;
|
type EndingPeriod = EndingPeriod;
|
||||||
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types!{
|
parameter_types!{
|
||||||
|
|||||||
@@ -27,14 +27,16 @@ use sr_primitives::traits::{
|
|||||||
AccountIdConversion,
|
AccountIdConversion,
|
||||||
};
|
};
|
||||||
use sr_primitives::weights::SimpleDispatchInfo;
|
use sr_primitives::weights::SimpleDispatchInfo;
|
||||||
use primitives::{Hash, Balance, parachain::{
|
use primitives::{
|
||||||
self, Id as ParaId, Chain, DutyRoster, AttestedCandidate, Statement,
|
Hash, Balance,
|
||||||
ParachainDispatchOrigin, UpwardMessage, BlockIngressRoots, ValidatorId, ActiveParas, CollatorId,
|
parachain::{
|
||||||
Retriable
|
self, Id as ParaId, Chain, DutyRoster, AttestedCandidate, Statement, ParachainDispatchOrigin,
|
||||||
}};
|
UpwardMessage, BlockIngressRoots, ValidatorId, ActiveParas, CollatorId, Retriable
|
||||||
use {system, session};
|
},
|
||||||
|
};
|
||||||
use srml_support::{
|
use srml_support::{
|
||||||
Parameter, dispatch::Result, traits::{Currency, Get, WithdrawReason, ExistenceRequirement},
|
Parameter, dispatch::Result,
|
||||||
|
traits::{Currency, Get, WithdrawReason, ExistenceRequirement, Randomness},
|
||||||
};
|
};
|
||||||
|
|
||||||
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
|
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
|
||||||
@@ -119,6 +121,9 @@ pub trait Trait: attestations::Trait {
|
|||||||
/// Some way of interacting with balances for fees.
|
/// Some way of interacting with balances for fees.
|
||||||
type ParachainCurrency: ParachainCurrency<Self::AccountId>;
|
type ParachainCurrency: ParachainCurrency<Self::AccountId>;
|
||||||
|
|
||||||
|
/// Something that provides randomness in the runtime.
|
||||||
|
type Randomness: Randomness<Self::Hash>;
|
||||||
|
|
||||||
/// Means to determine what the current set of active parachains are.
|
/// Means to determine what the current set of active parachains are.
|
||||||
type ActiveParachains: ActiveParas;
|
type ActiveParachains: ActiveParas;
|
||||||
|
|
||||||
@@ -517,7 +522,7 @@ impl<T: Trait> Module<T> {
|
|||||||
|
|
||||||
let mut seed = {
|
let mut seed = {
|
||||||
let phrase = b"validator_role_pairs";
|
let phrase = b"validator_role_pairs";
|
||||||
let seed = randomness_collective_flip::Module::<T>::random(&phrase[..]);
|
let seed = T::Randomness::random(&phrase[..]);
|
||||||
let seed_len = seed.as_ref().len();
|
let seed_len = seed.as_ref().len();
|
||||||
let needed_bytes = validator_count * 4;
|
let needed_bytes = validator_count * 4;
|
||||||
|
|
||||||
@@ -882,7 +887,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use super::Call as ParachainsCall;
|
use super::Call as ParachainsCall;
|
||||||
use bitvec::{bitvec, vec::BitVec};
|
use bitvec::{bitvec, vec::BitVec};
|
||||||
use sr_io::{TestExternalities, with_externalities};
|
use sr_io::TestExternalities;
|
||||||
use substrate_primitives::{H256, Blake2Hasher};
|
use substrate_primitives::{H256, Blake2Hasher};
|
||||||
use substrate_trie::NodeCodec;
|
use substrate_trie::NodeCodec;
|
||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
@@ -1061,6 +1066,7 @@ mod tests {
|
|||||||
type Parachains = registrar::Module<Test>;
|
type Parachains = registrar::Module<Test>;
|
||||||
type EndingPeriod = EndingPeriod;
|
type EndingPeriod = EndingPeriod;
|
||||||
type LeasePeriod = LeasePeriod;
|
type LeasePeriod = LeasePeriod;
|
||||||
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -1083,6 +1089,7 @@ mod tests {
|
|||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
type ParachainCurrency = balances::Module<Test>;
|
type ParachainCurrency = balances::Module<Test>;
|
||||||
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
type ActiveParachains = registrar::Module<Test>;
|
type ActiveParachains = registrar::Module<Test>;
|
||||||
type Registrar = registrar::Module<Test>;
|
type Registrar = registrar::Module<Test>;
|
||||||
}
|
}
|
||||||
@@ -1092,7 +1099,7 @@ mod tests {
|
|||||||
type RandomnessCollectiveFlip = randomness_collective_flip::Module<Test>;
|
type RandomnessCollectiveFlip = randomness_collective_flip::Module<Test>;
|
||||||
type Registrar = registrar::Module<Test>;
|
type Registrar = registrar::Module<Test>;
|
||||||
|
|
||||||
fn new_test_ext(parachains: Vec<(ParaId, Vec<u8>, Vec<u8>)>) -> TestExternalities<Blake2Hasher> {
|
fn new_test_ext(parachains: Vec<(ParaId, Vec<u8>, Vec<u8>)>) -> TestExternalities {
|
||||||
use staking::StakerStatus;
|
use staking::StakerStatus;
|
||||||
use babe::AuthorityId as BabeAuthorityId;
|
use babe::AuthorityId as BabeAuthorityId;
|
||||||
|
|
||||||
@@ -1287,7 +1294,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
(2u32.into(), vec![], vec![]),
|
(2u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
with_externalities(&mut new_test_ext(parachains.clone()), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
init_block();
|
init_block();
|
||||||
queue_upward_messages(0.into(), &vec![
|
queue_upward_messages(0.into(), &vec![
|
||||||
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 4] }
|
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 4] }
|
||||||
@@ -1304,7 +1311,7 @@ mod tests {
|
|||||||
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
|
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
|
||||||
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
||||||
});
|
});
|
||||||
with_externalities(&mut new_test_ext(parachains.clone()), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
init_block();
|
init_block();
|
||||||
queue_upward_messages(0.into(), &vec![
|
queue_upward_messages(0.into(), &vec![
|
||||||
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
|
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
|
||||||
@@ -1326,7 +1333,7 @@ mod tests {
|
|||||||
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
||||||
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
|
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
|
||||||
});
|
});
|
||||||
with_externalities(&mut new_test_ext(parachains.clone()), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
init_block();
|
init_block();
|
||||||
queue_upward_messages(0.into(), &vec![
|
queue_upward_messages(0.into(), &vec![
|
||||||
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
|
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
|
||||||
@@ -1348,7 +1355,7 @@ mod tests {
|
|||||||
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
||||||
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
|
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
|
||||||
});
|
});
|
||||||
with_externalities(&mut new_test_ext(parachains.clone()), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
init_block();
|
init_block();
|
||||||
queue_upward_messages(0.into(), &vec![
|
queue_upward_messages(0.into(), &vec![
|
||||||
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
|
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
|
||||||
@@ -1377,7 +1384,7 @@ mod tests {
|
|||||||
let parachains = vec![
|
let parachains = vec![
|
||||||
(0u32.into(), vec![], vec![]),
|
(0u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
let messages = vec![
|
let messages = vec![
|
||||||
UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] }
|
UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] }
|
||||||
@@ -1405,7 +1412,7 @@ mod tests {
|
|||||||
let parachains = vec![
|
let parachains = vec![
|
||||||
(0u32.into(), vec![], vec![]),
|
(0u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// oversize, but ok since it's just one and the queue is empty.
|
// oversize, but ok since it's just one and the queue is empty.
|
||||||
let messages = vec![
|
let messages = vec![
|
||||||
@@ -1441,7 +1448,7 @@ mod tests {
|
|||||||
let parachains = vec![
|
let parachains = vec![
|
||||||
(0u32.into(), vec![], vec![]),
|
(0u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// too many messages.
|
// too many messages.
|
||||||
queue_upward_messages(0.into(), &vec![
|
queue_upward_messages(0.into(), &vec![
|
||||||
@@ -1463,7 +1470,7 @@ mod tests {
|
|||||||
let parachains = vec![
|
let parachains = vec![
|
||||||
(0u32.into(), vec![], vec![]),
|
(0u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// too much data.
|
// too much data.
|
||||||
queue_upward_messages(0.into(), &vec![
|
queue_upward_messages(0.into(), &vec![
|
||||||
@@ -1484,7 +1491,7 @@ mod tests {
|
|||||||
let parachains = vec![
|
let parachains = vec![
|
||||||
(0u32.into(), vec![], vec![]),
|
(0u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// bad - already an oversize messages queued.
|
// bad - already an oversize messages queued.
|
||||||
queue_upward_messages(0.into(), &vec![
|
queue_upward_messages(0.into(), &vec![
|
||||||
@@ -1505,7 +1512,7 @@ mod tests {
|
|||||||
let parachains = vec![
|
let parachains = vec![
|
||||||
(0u32.into(), vec![], vec![]),
|
(0u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// bad - oversized and already a message queued.
|
// bad - oversized and already a message queued.
|
||||||
queue_upward_messages(0.into(), &vec![
|
queue_upward_messages(0.into(), &vec![
|
||||||
@@ -1529,7 +1536,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// parachain 0 is self
|
// parachain 0 is self
|
||||||
let mut candidates = vec![
|
let mut candidates = vec![
|
||||||
@@ -1559,7 +1566,7 @@ mod tests {
|
|||||||
(100u32.into(), vec![4,5,6], vec![2]),
|
(100u32.into(), vec![4,5,6], vec![2]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
assert_eq!(Parachains::active_parachains(), vec![(5u32.into(), None), (100u32.into(), None)]);
|
assert_eq!(Parachains::active_parachains(), vec![(5u32.into(), None), (100u32.into(), None)]);
|
||||||
assert_eq!(Parachains::parachain_code(ParaId::from(5u32)), Some(vec![1, 2, 3]));
|
assert_eq!(Parachains::parachain_code(ParaId::from(5u32)), Some(vec![1, 2, 3]));
|
||||||
@@ -1574,7 +1581,7 @@ mod tests {
|
|||||||
(100u32.into(), vec![4,5,6], vec![2,]),
|
(100u32.into(), vec![4,5,6], vec![2,]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
assert_eq!(Parachains::active_parachains(), vec![(5u32.into(), None), (100u32.into(), None)]);
|
assert_eq!(Parachains::active_parachains(), vec![(5u32.into(), None), (100u32.into(), None)]);
|
||||||
|
|
||||||
@@ -1607,7 +1614,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
let check_roster = |duty_roster: &DutyRoster| {
|
let check_roster = |duty_roster: &DutyRoster| {
|
||||||
assert_eq!(duty_roster.validator_duty.len(), 8);
|
assert_eq!(duty_roster.validator_duty.len(), 8);
|
||||||
@@ -1643,7 +1650,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
let candidate = AttestedCandidate {
|
let candidate = AttestedCandidate {
|
||||||
validity_votes: vec![],
|
validity_votes: vec![],
|
||||||
@@ -1672,7 +1679,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
assert_eq!(Parachains::active_parachains().len(), 2);
|
assert_eq!(Parachains::active_parachains().len(), 2);
|
||||||
|
|
||||||
@@ -1728,7 +1735,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
let mut candidate = AttestedCandidate {
|
let mut candidate = AttestedCandidate {
|
||||||
validity_votes: vec![],
|
validity_votes: vec![],
|
||||||
@@ -1765,7 +1772,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
let mut candidate = AttestedCandidate {
|
let mut candidate = AttestedCandidate {
|
||||||
validity_votes: vec![],
|
validity_votes: vec![],
|
||||||
@@ -1803,7 +1810,7 @@ mod tests {
|
|||||||
(99u32.into(), vec![1, 2, 3], vec![4, 5, 6]),
|
(99u32.into(), vec![1, 2, 3], vec![4, 5, 6]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains).execute_with(|| {
|
||||||
assert_eq!(Parachains::ingress(ParaId::from(1), None), Some(Vec::new()));
|
assert_eq!(Parachains::ingress(ParaId::from(1), None), Some(Vec::new()));
|
||||||
assert_eq!(Parachains::ingress(ParaId::from(99), None), Some(Vec::new()));
|
assert_eq!(Parachains::ingress(ParaId::from(99), None), Some(Vec::new()));
|
||||||
|
|
||||||
@@ -1925,7 +1932,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// parachain 99 does not exist
|
// parachain 99 does not exist
|
||||||
let non_existent = vec![(99.into(), [1; 32].into())];
|
let non_existent = vec![(99.into(), [1; 32].into())];
|
||||||
@@ -1950,7 +1957,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// parachain 0 is self
|
// parachain 0 is self
|
||||||
let to_self = vec![(0.into(), [1; 32].into())];
|
let to_self = vec![(0.into(), [1; 32].into())];
|
||||||
@@ -1975,7 +1982,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![], vec![]),
|
(1u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// parachain 0 is self
|
// parachain 0 is self
|
||||||
let out_of_order = vec![(1.into(), [1; 32].into()), ((0.into(), [1; 32].into()))];
|
let out_of_order = vec![(1.into(), [1; 32].into()), ((0.into(), [1; 32].into()))];
|
||||||
@@ -2000,7 +2007,7 @@ mod tests {
|
|||||||
(2u32.into(), vec![], vec![]),
|
(2u32.into(), vec![], vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains.clone()).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// parachain 0 is self
|
// parachain 0 is self
|
||||||
let contains_empty_trie_root = vec![(1.into(), [1; 32].into()), ((2.into(), EMPTY_TRIE_ROOT.into()))];
|
let contains_empty_trie_root = vec![(1.into(), [1; 32].into()), ((2.into(), EMPTY_TRIE_ROOT.into()))];
|
||||||
|
|||||||
@@ -574,8 +574,8 @@ impl<T: Trait + Send + Sync> SignedExtension for LimitParathreadCommits<T> where
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bitvec::vec::BitVec;
|
use bitvec::vec::BitVec;
|
||||||
use sr_io::{TestExternalities, with_externalities};
|
use sr_io::TestExternalities;
|
||||||
use substrate_primitives::{H256, Blake2Hasher, Pair};
|
use substrate_primitives::{H256, Pair};
|
||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
traits::{
|
traits::{
|
||||||
BlakeTwo256, IdentityLookup, ConvertInto, OnInitialize, OnFinalize, Dispatchable,
|
BlakeTwo256, IdentityLookup, ConvertInto, OnInitialize, OnFinalize, Dispatchable,
|
||||||
@@ -673,6 +673,7 @@ mod tests {
|
|||||||
type Parachains = Registrar;
|
type Parachains = Registrar;
|
||||||
type EndingPeriod = EndingPeriod;
|
type EndingPeriod = EndingPeriod;
|
||||||
type LeasePeriod = LeasePeriod;
|
type LeasePeriod = LeasePeriod;
|
||||||
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types!{
|
parameter_types!{
|
||||||
@@ -709,6 +710,7 @@ mod tests {
|
|||||||
type ParachainCurrency = balances::Module<Test>;
|
type ParachainCurrency = balances::Module<Test>;
|
||||||
type ActiveParachains = Registrar;
|
type ActiveParachains = Registrar;
|
||||||
type Registrar = Registrar;
|
type Registrar = Registrar;
|
||||||
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -732,6 +734,7 @@ mod tests {
|
|||||||
type System = system::Module<Test>;
|
type System = system::Module<Test>;
|
||||||
type Slots = slots::Module<Test>;
|
type Slots = slots::Module<Test>;
|
||||||
type Registrar = Module<Test>;
|
type Registrar = Module<Test>;
|
||||||
|
type RandomnessCollectiveFlip = randomness_collective_flip::Module<Test>;
|
||||||
|
|
||||||
const AUTHORITY_KEYS: [Sr25519Keyring; 8] = [
|
const AUTHORITY_KEYS: [Sr25519Keyring; 8] = [
|
||||||
Sr25519Keyring::Alice,
|
Sr25519Keyring::Alice,
|
||||||
@@ -744,7 +747,7 @@ mod tests {
|
|||||||
Sr25519Keyring::Two,
|
Sr25519Keyring::Two,
|
||||||
];
|
];
|
||||||
|
|
||||||
fn new_test_ext(parachains: Vec<(ParaId, Vec<u8>, Vec<u8>)>) -> TestExternalities<Blake2Hasher> {
|
fn new_test_ext(parachains: Vec<(ParaId, Vec<u8>, Vec<u8>)>) -> TestExternalities {
|
||||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||||
|
|
||||||
let authority_keys = [
|
let authority_keys = [
|
||||||
@@ -859,7 +862,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_setup_works() {
|
fn basic_setup_works() {
|
||||||
with_externalities(&mut new_test_ext(vec![]), || {
|
new_test_ext(vec![]).execute_with(|| {
|
||||||
assert_eq!(super::Parachains::get(), vec![]);
|
assert_eq!(super::Parachains::get(), vec![]);
|
||||||
assert_eq!(ThreadCount::get(), 0);
|
assert_eq!(ThreadCount::get(), 0);
|
||||||
assert_eq!(Active::get(), vec![]);
|
assert_eq!(Active::get(), vec![]);
|
||||||
@@ -876,13 +879,19 @@ mod tests {
|
|||||||
(100u32.into(), vec![4,5,6], vec![2,]),
|
(100u32.into(), vec![4,5,6], vec![2,]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains).execute_with(|| {
|
||||||
// Need to trigger on_initialize
|
// Need to trigger on_initialize
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// Genesis registration works
|
// Genesis registration works
|
||||||
assert_eq!(Registrar::active_paras(), vec![(5u32.into(), None), (100u32.into(), None)]);
|
assert_eq!(Registrar::active_paras(), vec![(5u32.into(), None), (100u32.into(), None)]);
|
||||||
assert_eq!(Registrar::paras(&ParaId::from(5u32)), Some(ParaInfo { scheduling: Scheduling::Always }));
|
assert_eq!(
|
||||||
assert_eq!(Registrar::paras(&ParaId::from(100u32)), Some(ParaInfo { scheduling: Scheduling::Always }));
|
Registrar::paras(&ParaId::from(5u32)),
|
||||||
|
Some(ParaInfo { scheduling: Scheduling::Always }),
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
Registrar::paras(&ParaId::from(100u32)),
|
||||||
|
Some(ParaInfo { scheduling: Scheduling::Always }),
|
||||||
|
);
|
||||||
assert_eq!(Parachains::parachain_code(&ParaId::from(5u32)), Some(vec![1, 2, 3]));
|
assert_eq!(Parachains::parachain_code(&ParaId::from(5u32)), Some(vec![1, 2, 3]));
|
||||||
assert_eq!(Parachains::parachain_code(&ParaId::from(100u32)), Some(vec![4, 5, 6]));
|
assert_eq!(Parachains::parachain_code(&ParaId::from(100u32)), Some(vec![4, 5, 6]));
|
||||||
});
|
});
|
||||||
@@ -890,7 +899,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn swap_chain_and_thread_works() {
|
fn swap_chain_and_thread_works() {
|
||||||
with_externalities(&mut new_test_ext(vec![]), || {
|
new_test_ext(vec![]).execute_with(|| {
|
||||||
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
||||||
|
|
||||||
// Need to trigger on_initialize
|
// Need to trigger on_initialize
|
||||||
@@ -969,7 +978,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn swap_handles_funds_correctly() {
|
fn swap_handles_funds_correctly() {
|
||||||
with_externalities(&mut new_test_ext(vec![]), || {
|
new_test_ext(vec![]).execute_with(|| {
|
||||||
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
||||||
|
|
||||||
// Need to trigger on_initialize
|
// Need to trigger on_initialize
|
||||||
@@ -1013,7 +1022,7 @@ mod tests {
|
|||||||
(1u32.into(), vec![1; 3], vec![1; 3]),
|
(1u32.into(), vec![1; 3], vec![1; 3]),
|
||||||
];
|
];
|
||||||
|
|
||||||
with_externalities(&mut new_test_ext(parachains), || {
|
new_test_ext(parachains).execute_with(|| {
|
||||||
// Need to trigger on_initialize
|
// Need to trigger on_initialize
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
|
|
||||||
@@ -1080,7 +1089,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parathread_scheduling_works() {
|
fn parathread_scheduling_works() {
|
||||||
with_externalities(&mut new_test_ext(vec![]), || {
|
new_test_ext(vec![]).execute_with(|| {
|
||||||
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
||||||
|
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
@@ -1114,7 +1123,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn removing_scheduled_parathread_works() {
|
fn removing_scheduled_parathread_works() {
|
||||||
with_externalities(&mut new_test_ext(vec![]), || {
|
new_test_ext(vec![]).execute_with(|| {
|
||||||
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
||||||
|
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
@@ -1157,7 +1166,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parathread_rescheduling_works() {
|
fn parathread_rescheduling_works() {
|
||||||
with_externalities(&mut new_test_ext(vec![]), || {
|
new_test_ext(vec![]).execute_with(|| {
|
||||||
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
assert_ok!(Registrar::set_thread_count(Origin::ROOT, 1));
|
||||||
|
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
@@ -1238,7 +1247,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parathread_auction_handles_basic_errors() {
|
fn parathread_auction_handles_basic_errors() {
|
||||||
with_externalities(&mut new_test_ext(vec![]), || {
|
new_test_ext(vec![]).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
let o = Origin::signed(0);
|
let o = Origin::signed(0);
|
||||||
assert_ok!(Registrar::register_parathread(o, vec![7, 8, 9], vec![1, 1, 1]));
|
assert_ok!(Registrar::register_parathread(o, vec![7, 8, 9], vec![1, 1, 1]));
|
||||||
@@ -1291,7 +1300,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parathread_auction_works() {
|
fn parathread_auction_works() {
|
||||||
with_externalities(&mut new_test_ext(vec![]), || {
|
new_test_ext(vec![]).execute_with(|| {
|
||||||
run_to_block(2);
|
run_to_block(2);
|
||||||
// Register 5 parathreads
|
// Register 5 parathreads
|
||||||
for x in 0..5 {
|
for x in 0..5 {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use sr_primitives::weights::SimpleDispatchInfo;
|
|||||||
use codec::{Encode, Decode, Codec};
|
use codec::{Encode, Decode, Codec};
|
||||||
use srml_support::{
|
use srml_support::{
|
||||||
decl_module, decl_storage, decl_event, ensure,
|
decl_module, decl_storage, decl_event, ensure,
|
||||||
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get},
|
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
|
||||||
};
|
};
|
||||||
use primitives::parachain::{
|
use primitives::parachain::{
|
||||||
SwapAux, PARACHAIN_INFO, Id as ParaId
|
SwapAux, PARACHAIN_INFO, Id as ParaId
|
||||||
@@ -51,6 +51,9 @@ pub trait Trait: system::Trait {
|
|||||||
|
|
||||||
/// The number of blocks over which a single period lasts.
|
/// The number of blocks over which a single period lasts.
|
||||||
type LeasePeriod: Get<Self::BlockNumber>;
|
type LeasePeriod: Get<Self::BlockNumber>;
|
||||||
|
|
||||||
|
/// Something that provides randomness in the runtime.
|
||||||
|
type Randomness: Randomness<Self::Hash>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A sub-bidder identifier. Used to distinguish between different logical bidders coming from the
|
/// A sub-bidder identifier. Used to distinguish between different logical bidders coming from the
|
||||||
@@ -121,7 +124,6 @@ type WinnersData<T> =
|
|||||||
// This module's storage items.
|
// This module's storage items.
|
||||||
decl_storage! {
|
decl_storage! {
|
||||||
trait Store for Module<T: Trait> as Slots {
|
trait Store for Module<T: Trait> as Slots {
|
||||||
|
|
||||||
/// The number of auctions that been started so far.
|
/// The number of auctions that been started so far.
|
||||||
pub AuctionCounter get(auction_counter): AuctionIndex;
|
pub AuctionCounter get(auction_counter): AuctionIndex;
|
||||||
|
|
||||||
@@ -456,7 +458,7 @@ impl<T: Trait> Module<T> {
|
|||||||
if early_end + T::EndingPeriod::get() == now {
|
if early_end + T::EndingPeriod::get() == now {
|
||||||
// Just ended!
|
// Just ended!
|
||||||
let ending_period = T::EndingPeriod::get();
|
let ending_period = T::EndingPeriod::get();
|
||||||
let offset = T::BlockNumber::decode(&mut<randomness_collective_flip::Module<T>>::random_seed().as_ref())
|
let offset = T::BlockNumber::decode(&mut T::Randomness::random_seed().as_ref())
|
||||||
.expect("secure hashes always bigger than block numbers; qed") % ending_period;
|
.expect("secure hashes always bigger than block numbers; qed") % ending_period;
|
||||||
let res = <Winning<T>>::get(offset).unwrap_or_default();
|
let res = <Winning<T>>::get(offset).unwrap_or_default();
|
||||||
let mut i = T::BlockNumber::zero();
|
let mut i = T::BlockNumber::zero();
|
||||||
@@ -815,11 +817,9 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use std::{result::Result, collections::HashMap, cell::RefCell};
|
use std::{result::Result, collections::HashMap, cell::RefCell};
|
||||||
|
|
||||||
use substrate_primitives::{Blake2Hasher, H256};
|
use substrate_primitives::H256;
|
||||||
use sr_io::with_externalities;
|
|
||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
Perbill,
|
Perbill, testing::Header,
|
||||||
testing::Header,
|
|
||||||
traits::{ConvertInto, BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
|
traits::{ConvertInto, BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
|
||||||
};
|
};
|
||||||
use srml_support::{impl_outer_origin, parameter_types, assert_ok, assert_noop};
|
use srml_support::{impl_outer_origin, parameter_types, assert_ok, assert_noop};
|
||||||
@@ -942,15 +942,17 @@ mod tests {
|
|||||||
type Parachains = TestParachains;
|
type Parachains = TestParachains;
|
||||||
type LeasePeriod = LeasePeriod;
|
type LeasePeriod = LeasePeriod;
|
||||||
type EndingPeriod = EndingPeriod;
|
type EndingPeriod = EndingPeriod;
|
||||||
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
type System = system::Module<Test>;
|
type System = system::Module<Test>;
|
||||||
type Balances = balances::Module<Test>;
|
type Balances = balances::Module<Test>;
|
||||||
type Slots = Module<Test>;
|
type Slots = Module<Test>;
|
||||||
|
type RandomnessCollectiveFlip = randomness_collective_flip::Module<Test>;
|
||||||
|
|
||||||
// This function basically just builds a genesis storage key/value store according to
|
// This function basically just builds a genesis storage key/value store according to
|
||||||
// our desired mock up.
|
// our desired mock up.
|
||||||
fn new_test_ext() -> sr_io::TestExternalities<Blake2Hasher> {
|
fn new_test_ext() -> sr_io::TestExternalities {
|
||||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||||
balances::GenesisConfig::<Test>{
|
balances::GenesisConfig::<Test>{
|
||||||
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
|
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
|
||||||
@@ -973,7 +975,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_setup_works() {
|
fn basic_setup_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Slots::auction_counter(), 0);
|
assert_eq!(Slots::auction_counter(), 0);
|
||||||
assert_eq!(Slots::deposit_held(&0u32.into()), 0);
|
assert_eq!(Slots::deposit_held(&0u32.into()), 0);
|
||||||
assert_eq!(Slots::is_in_progress(), false);
|
assert_eq!(Slots::is_in_progress(), false);
|
||||||
@@ -990,7 +992,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_start_auction() {
|
fn can_start_auction() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
|
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
@@ -1003,7 +1005,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn auction_proceeds_correctly() {
|
fn auction_proceeds_correctly() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
|
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
@@ -1048,7 +1050,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_win_auction() {
|
fn can_win_auction() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
|
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
@@ -1069,7 +1071,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn offboarding_works() {
|
fn offboarding_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 1));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 1));
|
||||||
@@ -1087,7 +1089,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_offboarding_works() {
|
fn set_offboarding_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 1));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 1));
|
||||||
@@ -1108,7 +1110,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn onboarding_works() {
|
fn onboarding_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 1));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 1));
|
||||||
@@ -1128,7 +1130,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn late_onboarding_works() {
|
fn late_onboarding_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 1));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 1));
|
||||||
@@ -1151,7 +1153,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn under_bidding_works() {
|
fn under_bidding_works() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 5));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 4, 5));
|
||||||
@@ -1167,7 +1169,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_choose_best_combination() {
|
fn should_choose_best_combination() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 1, 1));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 1, 1));
|
||||||
@@ -1195,7 +1197,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn independent_bids_should_fail() {
|
fn independent_bids_should_fail() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 1, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 1, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 2, 1));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 2, 1));
|
||||||
@@ -1210,7 +1212,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multiple_onboards_offboards_should_work() {
|
fn multiple_onboards_offboards_should_work() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 1, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 1, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 1, 1));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 1, 1));
|
||||||
@@ -1287,7 +1289,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn extensions_should_work() {
|
fn extensions_should_work() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 1, 1));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 1, 1));
|
||||||
@@ -1332,7 +1334,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn renewal_with_lower_value_should_work() {
|
fn renewal_with_lower_value_should_work() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 1, 5));
|
assert_ok!(Slots::bid(Origin::signed(1), 0, 1, 1, 1, 5));
|
||||||
@@ -1361,7 +1363,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_win_incomplete_auction() {
|
fn can_win_incomplete_auction() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
|
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
@@ -1382,7 +1384,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multiple_bids_work_pre_ending() {
|
fn multiple_bids_work_pre_ending() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
|
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
@@ -1410,7 +1412,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multiple_bids_work_post_ending() {
|
fn multiple_bids_work_post_ending() {
|
||||||
with_externalities(&mut new_test_ext(), || {
|
new_test_ext().execute_with(|| {
|
||||||
run_to_block(1);
|
run_to_block(1);
|
||||||
|
|
||||||
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1));
|
||||||
|
|||||||
Reference in New Issue
Block a user