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