mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 21:01:05 +00:00
cargo +nightly fmt (#3540)
* cargo +nightly fmt * add cargo-fmt check to ci * update ci * fmt * fmt * skip macro * ignore bridges
This commit is contained in:
@@ -15,21 +15,26 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{Client, FullBackend};
|
||||
use polkadot_test_runtime::{GetLastTimestamp, UncheckedExtrinsic};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_primitives::v1::{Block, InherentData as ParachainsInherentData};
|
||||
use sp_runtime::{generic::BlockId, Digest, DigestItem};
|
||||
use polkadot_test_runtime::{GetLastTimestamp, UncheckedExtrinsic};
|
||||
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_consensus_babe::{BABE_ENGINE_ID, digests::{PreDigest, SecondaryPlainPreDigest}};
|
||||
use sc_block_builder::{BlockBuilderProvider, BlockBuilder};
|
||||
use sp_consensus_babe::{
|
||||
digests::{PreDigest, SecondaryPlainPreDigest},
|
||||
BABE_ENGINE_ID,
|
||||
};
|
||||
use sp_runtime::{generic::BlockId, Digest, DigestItem};
|
||||
use sp_state_machine::BasicExternalities;
|
||||
use parity_scale_codec::{Encode, Decode};
|
||||
|
||||
/// An extension for the test client to initialize a Polkadot specific block builder.
|
||||
pub trait InitPolkadotBlockBuilder {
|
||||
/// Init a Polkadot specific block builder that works for the test runtime.
|
||||
///
|
||||
/// This will automatically create and push the inherents for you to make the block valid for the test runtime.
|
||||
fn init_polkadot_block_builder(&self) -> sc_block_builder::BlockBuilder<Block, Client, FullBackend>;
|
||||
fn init_polkadot_block_builder(
|
||||
&self,
|
||||
) -> sc_block_builder::BlockBuilder<Block, Client, FullBackend>;
|
||||
|
||||
/// Init a Polkadot specific block builder at a specific block that works for the test runtime.
|
||||
///
|
||||
@@ -42,9 +47,7 @@ pub trait InitPolkadotBlockBuilder {
|
||||
}
|
||||
|
||||
impl InitPolkadotBlockBuilder for Client {
|
||||
fn init_polkadot_block_builder(
|
||||
&self,
|
||||
) -> BlockBuilder<Block, Client, FullBackend> {
|
||||
fn init_polkadot_block_builder(&self) -> BlockBuilder<Block, Client, FullBackend> {
|
||||
let chain_info = self.chain_info();
|
||||
self.init_polkadot_block_builder_at(&BlockId::Hash(chain_info.best_hash))
|
||||
}
|
||||
@@ -53,17 +56,16 @@ impl InitPolkadotBlockBuilder for Client {
|
||||
&self,
|
||||
at: &BlockId<Block>,
|
||||
) -> BlockBuilder<Block, Client, FullBackend> {
|
||||
let last_timestamp = self
|
||||
.runtime_api()
|
||||
.get_last_timestamp(&at)
|
||||
.expect("Get last timestamp");
|
||||
let last_timestamp =
|
||||
self.runtime_api().get_last_timestamp(&at).expect("Get last timestamp");
|
||||
|
||||
// `MinimumPeriod` is a storage parameter type that requires externalities to access the value.
|
||||
let minimum_period = BasicExternalities::new_empty()
|
||||
.execute_with(|| polkadot_test_runtime::MinimumPeriod::get());
|
||||
|
||||
let timestamp = if last_timestamp == 0 {
|
||||
std::time::SystemTime::now().duration_since(std::time::SystemTime::UNIX_EPOCH)
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::SystemTime::UNIX_EPOCH)
|
||||
.expect("Time is always after UNIX_EPOCH; qed")
|
||||
.as_millis() as u64
|
||||
} else {
|
||||
@@ -77,18 +79,15 @@ impl InitPolkadotBlockBuilder for Client {
|
||||
let slot = (timestamp / slot_duration).into();
|
||||
|
||||
let digest = Digest {
|
||||
logs: vec![
|
||||
DigestItem::PreRuntime(
|
||||
BABE_ENGINE_ID,
|
||||
PreDigest::SecondaryPlain(SecondaryPlainPreDigest {
|
||||
slot,
|
||||
authority_index: 42,
|
||||
}).encode()
|
||||
),
|
||||
],
|
||||
logs: vec![DigestItem::PreRuntime(
|
||||
BABE_ENGINE_ID,
|
||||
PreDigest::SecondaryPlain(SecondaryPlainPreDigest { slot, authority_index: 42 })
|
||||
.encode(),
|
||||
)],
|
||||
};
|
||||
|
||||
let mut block_builder = self.new_block_at(at, digest, false)
|
||||
let mut block_builder = self
|
||||
.new_block_at(at, digest, false)
|
||||
.expect("Creates new block builder for test runtime");
|
||||
|
||||
let mut inherent_data = sp_inherents::InherentData::new();
|
||||
@@ -97,7 +96,8 @@ impl InitPolkadotBlockBuilder for Client {
|
||||
.put_data(sp_timestamp::INHERENT_IDENTIFIER, ×tamp)
|
||||
.expect("Put timestamp inherent data");
|
||||
|
||||
let parent_header = self.header(at)
|
||||
let parent_header = self
|
||||
.header(at)
|
||||
.expect("Get the parent block header")
|
||||
.expect("The target block header must exist");
|
||||
|
||||
@@ -105,7 +105,7 @@ impl InitPolkadotBlockBuilder for Client {
|
||||
bitfields: Vec::new(),
|
||||
backed_candidates: Vec::new(),
|
||||
disputes: Vec::new(),
|
||||
parent_header: parent_header,
|
||||
parent_header,
|
||||
};
|
||||
|
||||
inherent_data
|
||||
@@ -117,7 +117,9 @@ impl InitPolkadotBlockBuilder for Client {
|
||||
|
||||
let inherents = block_builder.create_inherents(inherent_data).expect("Creates inherents");
|
||||
|
||||
inherents.into_iter().for_each(|ext| block_builder.push(ext).expect("Pushes inherent"));
|
||||
inherents
|
||||
.into_iter()
|
||||
.for_each(|ext| block_builder.push(ext).expect("Pushes inherent"));
|
||||
|
||||
block_builder
|
||||
}
|
||||
@@ -132,15 +134,22 @@ pub trait BlockBuilderExt {
|
||||
/// the block.
|
||||
///
|
||||
/// Returns the result of the application of the extrinsic.
|
||||
fn push_polkadot_extrinsic(&mut self, ext: UncheckedExtrinsic) -> Result<(), sp_blockchain::Error>;
|
||||
fn push_polkadot_extrinsic(
|
||||
&mut self,
|
||||
ext: UncheckedExtrinsic,
|
||||
) -> Result<(), sp_blockchain::Error>;
|
||||
}
|
||||
|
||||
impl BlockBuilderExt for BlockBuilder<'_, Block, Client, FullBackend> {
|
||||
fn push_polkadot_extrinsic(&mut self, ext: UncheckedExtrinsic) -> Result<(), sp_blockchain::Error> {
|
||||
fn push_polkadot_extrinsic(
|
||||
&mut self,
|
||||
ext: UncheckedExtrinsic,
|
||||
) -> Result<(), sp_blockchain::Error> {
|
||||
let encoded = ext.encode();
|
||||
self.push(
|
||||
Decode::decode(&mut &encoded[..])
|
||||
.expect("The runtime specific extrinsic always decodes to an opaque extrinsic; qed"),
|
||||
Decode::decode(&mut &encoded[..]).expect(
|
||||
"The runtime specific extrinsic always decodes to an opaque extrinsic; qed",
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,17 +26,22 @@ use sp_core::storage::Storage;
|
||||
use sp_runtime::BuildStorage;
|
||||
|
||||
pub use block_builder::*;
|
||||
pub use substrate_test_client::*;
|
||||
pub use polkadot_test_service::{
|
||||
Client, construct_extrinsic, construct_transfer_extrinsic, PolkadotTestExecutor, FullBackend,
|
||||
};
|
||||
pub use polkadot_test_runtime as runtime;
|
||||
pub use polkadot_test_service::{
|
||||
construct_extrinsic, construct_transfer_extrinsic, Client, FullBackend, PolkadotTestExecutor,
|
||||
};
|
||||
pub use substrate_test_client::*;
|
||||
|
||||
/// Test client executor.
|
||||
pub type Executor = client::LocalCallExecutor<Block, FullBackend, sc_executor::NativeExecutor<PolkadotTestExecutor>>;
|
||||
pub type Executor = client::LocalCallExecutor<
|
||||
Block,
|
||||
FullBackend,
|
||||
sc_executor::NativeExecutor<PolkadotTestExecutor>,
|
||||
>;
|
||||
|
||||
/// Test client builder for Polkadot.
|
||||
pub type TestClientBuilder = substrate_test_client::TestClientBuilder<Block, Executor, FullBackend, GenesisParameters>;
|
||||
pub type TestClientBuilder =
|
||||
substrate_test_client::TestClientBuilder<Block, Executor, FullBackend, GenesisParameters>;
|
||||
|
||||
/// `LongestChain` type for the test runtime/client.
|
||||
pub type LongestChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
@@ -83,7 +88,7 @@ impl DefaultTestClientBuilderExt for TestClientBuilder {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests{
|
||||
mod tests {
|
||||
use super::*;
|
||||
use sp_consensus::BlockOrigin;
|
||||
|
||||
@@ -94,7 +99,8 @@ mod tests{
|
||||
let block_builder = client.init_polkadot_block_builder();
|
||||
let block = block_builder.build().expect("Finalizes the block").block;
|
||||
|
||||
futures::executor::block_on(client.import(BlockOrigin::Own, block)).expect("Imports the block");
|
||||
futures::executor::block_on(client.import(BlockOrigin::Own, block))
|
||||
.expect("Imports the block");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -112,6 +118,7 @@ mod tests{
|
||||
|
||||
let block = block_builder.build().expect("Finalizes the block").block;
|
||||
|
||||
futures::executor::block_on(client.import(BlockOrigin::Own, block)).expect("Imports the block");
|
||||
futures::executor::block_on(client.import(BlockOrigin::Own, block))
|
||||
.expect("Imports the block");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,23 +18,23 @@
|
||||
|
||||
//! Utilities for End to end runtime tests
|
||||
|
||||
use test_runner::{
|
||||
Node, ChainInfo, SignatureVerificationOverride, task_executor,
|
||||
build_runtime, client_parts, ConfigOrChainSpec,
|
||||
};
|
||||
use grandpa::GrandpaBlockImport;
|
||||
use sc_service::{TFullBackend, TFullClient};
|
||||
use sp_runtime::generic::Era;
|
||||
use sc_consensus_babe::BabeBlockImport;
|
||||
use polkadot_runtime_common::claims;
|
||||
use sp_runtime::AccountId32;
|
||||
use support::{weights::Weight, StorageValue};
|
||||
use democracy::{AccountVote, Conviction, Vote};
|
||||
use polkadot_runtime::{FastTrackVotingPeriod, Runtime, RuntimeApi, Event, TechnicalCollective, CouncilCollective};
|
||||
use std::{str::FromStr, future::Future, error::Error};
|
||||
use codec::Encode;
|
||||
use democracy::{AccountVote, Conviction, Vote};
|
||||
use grandpa::GrandpaBlockImport;
|
||||
use polkadot_runtime::{
|
||||
CouncilCollective, Event, FastTrackVotingPeriod, Runtime, RuntimeApi, TechnicalCollective,
|
||||
};
|
||||
use polkadot_runtime_common::claims;
|
||||
use sc_consensus_babe::BabeBlockImport;
|
||||
use sc_consensus_manual_seal::consensus::babe::SlotTimestampProvider;
|
||||
use sp_runtime::app_crypto::sp_core::H256;
|
||||
use sc_service::{TFullBackend, TFullClient};
|
||||
use sp_runtime::{app_crypto::sp_core::H256, generic::Era, AccountId32};
|
||||
use std::{error::Error, future::Future, str::FromStr};
|
||||
use support::{weights::Weight, StorageValue};
|
||||
use test_runner::{
|
||||
build_runtime, client_parts, task_executor, ChainInfo, ConfigOrChainSpec, Node,
|
||||
SignatureVerificationOverride,
|
||||
};
|
||||
|
||||
type BlockImport<B, BE, C, SC> = BabeBlockImport<B, C, GrandpaBlockImport<BE, B, C, SC>>;
|
||||
type Block = polkadot_primitives::v1::Block;
|
||||
@@ -63,7 +63,8 @@ impl ChainInfo for PolkadotChainInfo {
|
||||
Self::SelectChain,
|
||||
>;
|
||||
type SignedExtras = polkadot_runtime::SignedExtra;
|
||||
type InherentDataProviders = (SlotTimestampProvider, sp_consensus_babe::inherents::InherentDataProvider);
|
||||
type InherentDataProviders =
|
||||
(SlotTimestampProvider, sp_consensus_babe::inherents::InherentDataProvider);
|
||||
|
||||
fn signed_extras(from: <Runtime as system::Config>::AccountId) -> Self::SignedExtras {
|
||||
(
|
||||
@@ -80,23 +81,25 @@ impl ChainInfo for PolkadotChainInfo {
|
||||
}
|
||||
|
||||
/// Dispatch with root origin, via pallet-democracy
|
||||
pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config>::Call>, node: &Node<T>)
|
||||
-> Result<(), Box<dyn Error>>
|
||||
where
|
||||
T: ChainInfo<
|
||||
Block=Block,
|
||||
Executor=Executor,
|
||||
Runtime=Runtime,
|
||||
RuntimeApi=RuntimeApi,
|
||||
SelectChain=SelectChain,
|
||||
BlockImport=BlockImport<
|
||||
Block,
|
||||
TFullBackend<Block>,
|
||||
TFullClient<Block, RuntimeApi, Executor>,
|
||||
SelectChain,
|
||||
>,
|
||||
SignedExtras=polkadot_runtime::SignedExtra
|
||||
>
|
||||
pub async fn dispatch_with_root<T>(
|
||||
call: impl Into<<T::Runtime as system::Config>::Call>,
|
||||
node: &Node<T>,
|
||||
) -> Result<(), Box<dyn Error>>
|
||||
where
|
||||
T: ChainInfo<
|
||||
Block = Block,
|
||||
Executor = Executor,
|
||||
Runtime = Runtime,
|
||||
RuntimeApi = RuntimeApi,
|
||||
SelectChain = SelectChain,
|
||||
BlockImport = BlockImport<
|
||||
Block,
|
||||
TFullBackend<Block>,
|
||||
TFullClient<Block, RuntimeApi, Executor>,
|
||||
SelectChain,
|
||||
>,
|
||||
SignedExtras = polkadot_runtime::SignedExtra,
|
||||
>,
|
||||
{
|
||||
type DemocracyCall = democracy::Call<Runtime>;
|
||||
type CouncilCollectiveEvent = collective::Event<Runtime, CouncilCollective>;
|
||||
@@ -109,37 +112,47 @@ pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config
|
||||
"1rvXMZpAj9nKLQkPFCymyH7Fg3ZyKJhJbrc7UtHbTVhJm1A",
|
||||
"15j4dg5GzsL1bw2U2AWgeyAk6QTxq43V7ZPbXdAmbVLjvDCK",
|
||||
]
|
||||
.into_iter()
|
||||
.map(|account| AccountId32::from_str(account).unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
.into_iter()
|
||||
.map(|account| AccountId32::from_str(account).unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// and these
|
||||
let (technical_collective, council_collective) = node.with_state(|| (
|
||||
collective::Members::<Runtime, TechnicalCollective>::get(),
|
||||
collective::Members::<Runtime, CouncilCollective>::get()
|
||||
));
|
||||
let (technical_collective, council_collective) = node.with_state(|| {
|
||||
(
|
||||
collective::Members::<Runtime, TechnicalCollective>::get(),
|
||||
collective::Members::<Runtime, CouncilCollective>::get(),
|
||||
)
|
||||
});
|
||||
|
||||
// hash of the proposal in democracy
|
||||
let proposal_hash = {
|
||||
// note the call (pre-image?) of the call.
|
||||
node.submit_extrinsic(DemocracyCall::note_preimage(call.into().encode()), whales[0].clone()).await?;
|
||||
node.submit_extrinsic(
|
||||
DemocracyCall::note_preimage(call.into().encode()),
|
||||
whales[0].clone(),
|
||||
)
|
||||
.await?;
|
||||
node.seal_blocks(1).await;
|
||||
|
||||
// fetch proposal hash from event emitted by the runtime
|
||||
let events = node.events();
|
||||
events.iter()
|
||||
events
|
||||
.iter()
|
||||
.filter_map(|event| match event.event {
|
||||
Event::Democracy(democracy::Event::PreimageNoted(ref proposal_hash, _, _))
|
||||
=> Some(proposal_hash.clone()),
|
||||
_ => None
|
||||
Event::Democracy(democracy::Event::PreimageNoted(ref proposal_hash, _, _)) =>
|
||||
Some(proposal_hash.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.next()
|
||||
.ok_or_else(|| format!("democracy::Event::PreimageNoted not found in events: {:#?}", events))?
|
||||
.ok_or_else(|| {
|
||||
format!("democracy::Event::PreimageNoted not found in events: {:#?}", events)
|
||||
})?
|
||||
};
|
||||
|
||||
// submit external_propose call through council collective
|
||||
{
|
||||
let external_propose = DemocracyCall::external_propose_majority(proposal_hash.clone().into());
|
||||
let external_propose =
|
||||
DemocracyCall::external_propose_majority(proposal_hash.clone().into());
|
||||
let length = external_propose.using_encoded(|x| x.len()) as u32 + 1;
|
||||
let weight = Weight::MAX / 100_000_000;
|
||||
let proposal = CouncilCollectiveCall::propose(
|
||||
@@ -153,16 +166,17 @@ pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config
|
||||
|
||||
// fetch proposal index from event emitted by the runtime
|
||||
let events = node.events();
|
||||
let (index, hash): (u32, H256) = events.iter()
|
||||
.filter_map(|event| {
|
||||
match event.event {
|
||||
Event::Council(CouncilCollectiveEvent::Proposed(_, index, ref hash, _)) =>
|
||||
Some((index, hash.clone())),
|
||||
_ => None
|
||||
}
|
||||
let (index, hash): (u32, H256) = events
|
||||
.iter()
|
||||
.filter_map(|event| match event.event {
|
||||
Event::Council(CouncilCollectiveEvent::Proposed(_, index, ref hash, _)) =>
|
||||
Some((index, hash.clone())),
|
||||
_ => None,
|
||||
})
|
||||
.next()
|
||||
.ok_or_else(|| format!("CouncilCollectiveEvent::Proposed not found in events: {:#?}", events))?;
|
||||
.ok_or_else(|| {
|
||||
format!("CouncilCollectiveEvent::Proposed not found in events: {:#?}", events)
|
||||
})?;
|
||||
|
||||
// vote
|
||||
for member in &council_collective[1..] {
|
||||
@@ -177,21 +191,24 @@ pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config
|
||||
node.seal_blocks(1).await;
|
||||
|
||||
// assert that proposal has been passed on chain
|
||||
let events = node.events()
|
||||
let events = node
|
||||
.events()
|
||||
.into_iter()
|
||||
.filter(|event| {
|
||||
match event.event {
|
||||
Event::Council(CouncilCollectiveEvent::Closed(_hash, _, _)) if hash == _hash => true,
|
||||
Event::Council(CouncilCollectiveEvent::Approved(_hash, )) if hash == _hash => true,
|
||||
Event::Council(CouncilCollectiveEvent::Executed(_hash, Ok(()))) if hash == _hash => true,
|
||||
_ => false,
|
||||
}
|
||||
.filter(|event| match event.event {
|
||||
Event::Council(CouncilCollectiveEvent::Closed(_hash, _, _)) if hash == _hash =>
|
||||
true,
|
||||
Event::Council(CouncilCollectiveEvent::Approved(_hash)) if hash == _hash => true,
|
||||
Event::Council(CouncilCollectiveEvent::Executed(_hash, Ok(())))
|
||||
if hash == _hash =>
|
||||
true,
|
||||
_ => false,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// make sure all 3 events are in state
|
||||
assert_eq!(
|
||||
events.len(), 3,
|
||||
events.len(),
|
||||
3,
|
||||
"CouncilCollectiveEvent::{{Closed, Approved, Executed}} not found in events: {:#?}",
|
||||
node.events(),
|
||||
);
|
||||
@@ -199,7 +216,8 @@ pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config
|
||||
|
||||
// next technical collective must fast track the proposal.
|
||||
{
|
||||
let fast_track = DemocracyCall::fast_track(proposal_hash.into(), FastTrackVotingPeriod::get(), 0);
|
||||
let fast_track =
|
||||
DemocracyCall::fast_track(proposal_hash.into(), FastTrackVotingPeriod::get(), 0);
|
||||
let weight = Weight::MAX / 100_000_000;
|
||||
let length = fast_track.using_encoded(|x| x.len()) as u32 + 1;
|
||||
let proposal = TechnicalCollectiveCall::propose(
|
||||
@@ -212,16 +230,21 @@ pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config
|
||||
node.seal_blocks(1).await;
|
||||
|
||||
let events = node.events();
|
||||
let (index, hash) = events.iter()
|
||||
.filter_map(|event| {
|
||||
match event.event {
|
||||
Event::TechnicalCommittee(TechnicalCollectiveEvent::Proposed(_, index, ref hash, _))
|
||||
=> Some((index, hash.clone())),
|
||||
_ => None
|
||||
}
|
||||
let (index, hash) = events
|
||||
.iter()
|
||||
.filter_map(|event| match event.event {
|
||||
Event::TechnicalCommittee(TechnicalCollectiveEvent::Proposed(
|
||||
_,
|
||||
index,
|
||||
ref hash,
|
||||
_,
|
||||
)) => Some((index, hash.clone())),
|
||||
_ => None,
|
||||
})
|
||||
.next()
|
||||
.ok_or_else(|| format!("TechnicalCollectiveEvent::Proposed not found in events: {:#?}", events))?;
|
||||
.ok_or_else(|| {
|
||||
format!("TechnicalCollectiveEvent::Proposed not found in events: {:#?}", events)
|
||||
})?;
|
||||
|
||||
// vote
|
||||
for member in &technical_collective[1..] {
|
||||
@@ -236,35 +259,44 @@ pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config
|
||||
node.seal_blocks(1).await;
|
||||
|
||||
// assert that fast-track proposal has been passed on chain
|
||||
let events = node.events()
|
||||
let events = node
|
||||
.events()
|
||||
.into_iter()
|
||||
.filter(|event| {
|
||||
match event.event {
|
||||
Event::TechnicalCommittee(TechnicalCollectiveEvent::Closed(_hash, _, _)) if hash == _hash => true,
|
||||
Event::TechnicalCommittee(TechnicalCollectiveEvent::Approved(_hash)) if hash == _hash => true,
|
||||
Event::TechnicalCommittee(TechnicalCollectiveEvent::Executed(_hash, Ok(()))) if hash == _hash => true,
|
||||
_ => false,
|
||||
}
|
||||
.filter(|event| match event.event {
|
||||
Event::TechnicalCommittee(TechnicalCollectiveEvent::Closed(_hash, _, _))
|
||||
if hash == _hash =>
|
||||
true,
|
||||
Event::TechnicalCommittee(TechnicalCollectiveEvent::Approved(_hash))
|
||||
if hash == _hash =>
|
||||
true,
|
||||
Event::TechnicalCommittee(TechnicalCollectiveEvent::Executed(_hash, Ok(())))
|
||||
if hash == _hash =>
|
||||
true,
|
||||
_ => false,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// make sure all 3 events are in state
|
||||
assert_eq!(
|
||||
events.len(), 3,
|
||||
events.len(),
|
||||
3,
|
||||
"TechnicalCollectiveEvent::{{Closed, Approved, Executed}} not found in events: {:#?}",
|
||||
node.events(),
|
||||
);
|
||||
}
|
||||
|
||||
// now runtime upgrade proposal is a fast-tracked referendum we can vote for.
|
||||
let ref_index = node.events()
|
||||
let ref_index = node
|
||||
.events()
|
||||
.into_iter()
|
||||
.filter_map(|event| match event.event {
|
||||
Event::Democracy(democracy::Event::Started(index, _)) => Some(index),
|
||||
_ => None,
|
||||
})
|
||||
.next()
|
||||
.ok_or_else(|| format!("democracy::Event::Started not found in events: {:#?}", node.events()))?;
|
||||
.ok_or_else(|| {
|
||||
format!("democracy::Event::Started not found in events: {:#?}", node.events())
|
||||
})?;
|
||||
|
||||
let call = DemocracyCall::vote(
|
||||
ref_index,
|
||||
@@ -282,21 +314,24 @@ pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config
|
||||
node.seal_blocks(FastTrackVotingPeriod::get() as usize).await;
|
||||
|
||||
// assert that the proposal is passed by looking at events
|
||||
let events = node.events()
|
||||
let events = node
|
||||
.events()
|
||||
.into_iter()
|
||||
.filter(|event| {
|
||||
match event.event {
|
||||
Event::Democracy(democracy::Event::Passed(_index)) if _index == ref_index => true,
|
||||
Event::Democracy(democracy::Event::PreimageUsed(_hash, _, _)) if _hash == proposal_hash => true,
|
||||
Event::Democracy(democracy::Event::Executed(_index, Ok(()))) if _index == ref_index => true,
|
||||
_ => false,
|
||||
}
|
||||
.filter(|event| match event.event {
|
||||
Event::Democracy(democracy::Event::Passed(_index)) if _index == ref_index => true,
|
||||
Event::Democracy(democracy::Event::PreimageUsed(_hash, _, _))
|
||||
if _hash == proposal_hash =>
|
||||
true,
|
||||
Event::Democracy(democracy::Event::Executed(_index, Ok(()))) if _index == ref_index =>
|
||||
true,
|
||||
_ => false,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// make sure all events were emitted
|
||||
assert_eq!(
|
||||
events.len(), 3,
|
||||
events.len(),
|
||||
3,
|
||||
"democracy::Event::{{Passed, PreimageUsed, Executed}} not found in events: {:#?}",
|
||||
node.events(),
|
||||
);
|
||||
@@ -305,12 +340,12 @@ pub async fn dispatch_with_root<T>(call: impl Into<<T::Runtime as system::Config
|
||||
|
||||
/// Runs the test-runner as a binary.
|
||||
pub fn run<F, Fut>(callback: F) -> Result<(), Box<dyn Error>>
|
||||
where
|
||||
F: FnOnce(Node<PolkadotChainInfo>) -> Fut,
|
||||
Fut: Future<Output=Result<(), Box<dyn Error>>>,
|
||||
where
|
||||
F: FnOnce(Node<PolkadotChainInfo>) -> Fut,
|
||||
Fut: Future<Output = Result<(), Box<dyn Error>>>,
|
||||
{
|
||||
use structopt::StructOpt;
|
||||
use sc_cli::{CliConfiguration, SubstrateCli};
|
||||
use structopt::StructOpt;
|
||||
|
||||
let mut tokio_runtime = build_runtime()?;
|
||||
let task_executor = task_executor(tokio_runtime.handle().clone());
|
||||
@@ -326,7 +361,8 @@ pub fn run<F, Fut>(callback: F) -> Result<(), Box<dyn Error>>
|
||||
sc_cli::print_node_infos::<polkadot_cli::Cli>(&config);
|
||||
let (rpc, task_manager, client, pool, command_sink, backend) =
|
||||
client_parts::<PolkadotChainInfo>(ConfigOrChainSpec::Config(config))?;
|
||||
let node = Node::<PolkadotChainInfo>::new(rpc, task_manager, client, pool, command_sink, backend);
|
||||
let node =
|
||||
Node::<PolkadotChainInfo>::new(rpc, task_manager, client, pool, command_sink, backend);
|
||||
|
||||
// hand off node.
|
||||
tokio_runtime.block_on(callback(node))?;
|
||||
@@ -337,19 +373,22 @@ pub fn run<F, Fut>(callback: F) -> Result<(), Box<dyn Error>>
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use sp_keyring::sr25519::Keyring::Alice;
|
||||
use sp_runtime::{MultiSigner, traits::IdentifyAccount};
|
||||
use polkadot_service::chain_spec::polkadot_development_config;
|
||||
use sp_keyring::sr25519::Keyring::Alice;
|
||||
use sp_runtime::{traits::IdentifyAccount, MultiSigner};
|
||||
|
||||
#[test]
|
||||
fn test_runner() {
|
||||
let mut runtime = build_runtime().unwrap();
|
||||
let task_executor = task_executor(runtime.handle().clone());
|
||||
let (rpc, task_manager, client, pool, command_sink, backend) =
|
||||
client_parts::<PolkadotChainInfo>(
|
||||
ConfigOrChainSpec::ChainSpec(Box::new(polkadot_development_config().unwrap()), task_executor)
|
||||
).unwrap();
|
||||
let node = Node::<PolkadotChainInfo>::new(rpc, task_manager, client, pool, command_sink, backend);
|
||||
client_parts::<PolkadotChainInfo>(ConfigOrChainSpec::ChainSpec(
|
||||
Box::new(polkadot_development_config().unwrap()),
|
||||
task_executor,
|
||||
))
|
||||
.unwrap();
|
||||
let node =
|
||||
Node::<PolkadotChainInfo>::new(rpc, task_manager, client, pool, command_sink, backend);
|
||||
|
||||
runtime.block_on(async {
|
||||
// seals blocks
|
||||
|
||||
@@ -16,40 +16,46 @@
|
||||
//! Attempts to upgrade the polkadot runtime, in a Simnet environment
|
||||
use std::{error::Error, str::FromStr};
|
||||
|
||||
use polkadot_simnet::{run, dispatch_with_root};
|
||||
use polkadot_runtime::Event;
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sc_client_api::{ExecutorProvider, CallExecutor};
|
||||
use sp_core::crypto::AccountId32;
|
||||
use polkadot_simnet::{dispatch_with_root, run};
|
||||
use sc_client_api::{CallExecutor, ExecutorProvider};
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_core::crypto::AccountId32;
|
||||
use sp_runtime::generic::BlockId;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
run(|node| async {
|
||||
let old_runtime_version = node.client()
|
||||
let old_runtime_version = node
|
||||
.client()
|
||||
.executor()
|
||||
.runtime_version(&BlockId::Hash(node.client().info().best_hash))?
|
||||
.spec_version;
|
||||
|
||||
let wasm_binary = polkadot_runtime::WASM_BINARY
|
||||
.ok_or("Polkadot development wasm not available")?
|
||||
.to_vec();
|
||||
// upgrade runtime.
|
||||
dispatch_with_root(system::Call::set_code(wasm_binary), &node).await?;
|
||||
.ok_or("Polkadot development wasm not available")?
|
||||
.to_vec();
|
||||
// upgrade runtime.
|
||||
dispatch_with_root(system::Call::set_code(wasm_binary), &node).await?;
|
||||
|
||||
// assert that the runtime has been updated by looking at events
|
||||
let events = node.events()
|
||||
let events = node
|
||||
.events()
|
||||
.into_iter()
|
||||
.filter(|event| {
|
||||
match event.event {
|
||||
Event::System(system::Event::CodeUpdated) => true,
|
||||
_ => false,
|
||||
}
|
||||
.filter(|event| match event.event {
|
||||
Event::System(system::Event::CodeUpdated) => true,
|
||||
_ => false,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// make sure event was emitted
|
||||
assert_eq!(events.len(), 1, "system::Event::CodeUpdate not found in events: {:#?}", node.events());
|
||||
let new_runtime_version = node.client()
|
||||
assert_eq!(
|
||||
events.len(),
|
||||
1,
|
||||
"system::Event::CodeUpdate not found in events: {:#?}",
|
||||
node.events()
|
||||
);
|
||||
let new_runtime_version = node
|
||||
.client()
|
||||
.executor()
|
||||
.runtime_version(&BlockId::Hash(node.client().info().best_hash))?
|
||||
.spec_version;
|
||||
@@ -64,20 +70,20 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
let (from, dest, balance) = (
|
||||
AccountId32::from_str("15j4dg5GzsL1bw2U2AWgeyAk6QTxq43V7ZPbXdAmbVLjvDCK")?,
|
||||
AccountId32::from_str("1rvXMZpAj9nKLQkPFCymyH7Fg3ZyKJhJbrc7UtHbTVhJm1A")?,
|
||||
10_000_000_000_000 // 10 dots
|
||||
10_000_000_000_000, // 10 dots
|
||||
);
|
||||
|
||||
// post upgrade tests, a simple balance transfer
|
||||
node.submit_extrinsic(balances::Call::transfer(dest.into(), balance), from).await?;
|
||||
node.submit_extrinsic(balances::Call::transfer(dest.into(), balance), from)
|
||||
.await?;
|
||||
node.seal_blocks(1).await;
|
||||
|
||||
let events = node.events()
|
||||
let events = node
|
||||
.events()
|
||||
.into_iter()
|
||||
.filter(|event| {
|
||||
match event.event {
|
||||
Event::Balances(balances::Event::Transfer(_, _, _)) => true,
|
||||
_ => false,
|
||||
}
|
||||
.filter(|event| match event.event {
|
||||
Event::Balances(balances::Event::Transfer(_, _, _)) => true,
|
||||
_ => false,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
// make sure transfer went through
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
//! Chain specifications for the test runtime.
|
||||
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use babe_primitives::AuthorityId as BabeId;
|
||||
use grandpa::AuthorityId as GrandpaId;
|
||||
use pallet_staking::Forcing;
|
||||
use polkadot_primitives::v1::{ValidatorId, AccountId, AssignmentId, MAX_CODE_SIZE, MAX_POV_SIZE};
|
||||
use polkadot_primitives::v1::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE};
|
||||
use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions};
|
||||
use polkadot_test_runtime::{constants::currency::DOTS, BABE_GENESIS_EPOCH_CONFIG};
|
||||
use sc_chain_spec::{ChainSpec, ChainType};
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_core::sr25519;
|
||||
use sp_runtime::Perbill;
|
||||
|
||||
@@ -51,10 +51,7 @@ pub fn polkadot_local_testnet_config() -> PolkadotChainSpec {
|
||||
/// Local testnet genesis config (multivalidator Alice + Bob)
|
||||
pub fn polkadot_local_testnet_genesis() -> polkadot_test_runtime::GenesisConfig {
|
||||
polkadot_testnet_genesis(
|
||||
vec![
|
||||
get_authority_keys_from_seed("Alice"),
|
||||
get_authority_keys_from_seed("Bob"),
|
||||
],
|
||||
vec![get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob")],
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
None,
|
||||
)
|
||||
@@ -120,10 +117,7 @@ fn polkadot_testnet_genesis(
|
||||
},
|
||||
indices: runtime::IndicesConfig { indices: vec![] },
|
||||
balances: runtime::BalancesConfig {
|
||||
balances: endowed_accounts
|
||||
.iter()
|
||||
.map(|k| (k.clone(), ENDOWMENT))
|
||||
.collect(),
|
||||
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
|
||||
},
|
||||
session: runtime::SessionConfig {
|
||||
keys: initial_authorities
|
||||
@@ -148,14 +142,7 @@ fn polkadot_testnet_genesis(
|
||||
validator_count: 2,
|
||||
stakers: initial_authorities
|
||||
.iter()
|
||||
.map(|x| {
|
||||
(
|
||||
x.0.clone(),
|
||||
x.1.clone(),
|
||||
STASH,
|
||||
runtime::StakerStatus::Validator,
|
||||
)
|
||||
})
|
||||
.map(|x| (x.0.clone(), x.1.clone(), STASH, runtime::StakerStatus::Validator))
|
||||
.collect(),
|
||||
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
||||
force_era: Forcing::NotForcing,
|
||||
@@ -168,10 +155,7 @@ fn polkadot_testnet_genesis(
|
||||
},
|
||||
grandpa: Default::default(),
|
||||
authority_discovery: runtime::AuthorityDiscoveryConfig { keys: vec![] },
|
||||
claims: runtime::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
},
|
||||
claims: runtime::ClaimsConfig { claims: vec![], vesting: vec![] },
|
||||
vesting: runtime::VestingConfig { vesting: vec![] },
|
||||
sudo: runtime::SudoConfig { key: root_key },
|
||||
parachains_configuration: runtime::ParachainsConfigurationConfig {
|
||||
|
||||
@@ -22,20 +22,17 @@ pub mod chain_spec;
|
||||
|
||||
pub use chain_spec::*;
|
||||
use futures::future::Future;
|
||||
use polkadot_node_primitives::{CollationGenerationConfig, CollatorFn};
|
||||
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
|
||||
use polkadot_overseer::Handle;
|
||||
use polkadot_primitives::v1::{
|
||||
Id as ParaId, HeadData, ValidationCode, Balance, CollatorPair,
|
||||
};
|
||||
use polkadot_primitives::v1::{Balance, CollatorPair, HeadData, Id as ParaId, ValidationCode};
|
||||
use polkadot_runtime_common::BlockHashCount;
|
||||
use polkadot_service::{
|
||||
Error, NewFull, FullClient, ClientHandle, ExecuteWithClient, IsCollator,
|
||||
};
|
||||
use polkadot_node_subsystem::messages::{CollatorProtocolMessage, CollationGenerationMessage};
|
||||
use polkadot_test_runtime::{
|
||||
Runtime, SignedExtra, SignedPayload, VERSION, ParasSudoWrapperCall, SudoCall, UncheckedExtrinsic,
|
||||
};
|
||||
use polkadot_node_primitives::{CollatorFn, CollationGenerationConfig};
|
||||
use polkadot_runtime_parachains::paras::ParaGenesisArgs;
|
||||
use polkadot_service::{ClientHandle, Error, ExecuteWithClient, FullClient, IsCollator, NewFull};
|
||||
use polkadot_test_runtime::{
|
||||
ParasSudoWrapperCall, Runtime, SignedExtra, SignedPayload, SudoCall, UncheckedExtrinsic,
|
||||
VERSION,
|
||||
};
|
||||
use sc_chain_spec::ChainSpec;
|
||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||
use sc_executor::native_executor_instance;
|
||||
@@ -45,16 +42,18 @@ use sc_network::{
|
||||
};
|
||||
use service::{
|
||||
config::{DatabaseConfig, KeystoreConfig, MultiaddrWithPeerId, WasmExecutionMethod},
|
||||
RpcHandlers, TaskExecutor, TaskManager, KeepBlocks, TransactionStorageMode,
|
||||
BasePath, Configuration, KeepBlocks, Role, RpcHandlers, TaskExecutor, TaskManager,
|
||||
TransactionStorageMode,
|
||||
};
|
||||
use service::{BasePath, Configuration, Role};
|
||||
use sp_arithmetic::traits::SaturatedConversion;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
use sp_runtime::{codec::Encode, generic, traits::IdentifyAccount, MultiSigner};
|
||||
use sp_state_machine::BasicExternalities;
|
||||
use std::{sync::Arc, path::PathBuf};
|
||||
use substrate_test_client::{BlockchainEventsExt, RpcHandlersExt, RpcTransactionOutput, RpcTransactionError};
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use substrate_test_client::{
|
||||
BlockchainEventsExt, RpcHandlersExt, RpcTransactionError, RpcTransactionOutput,
|
||||
};
|
||||
|
||||
native_executor_instance!(
|
||||
pub PolkadotTestExecutor,
|
||||
@@ -74,10 +73,7 @@ pub fn new_full(
|
||||
config: Configuration,
|
||||
is_collator: IsCollator,
|
||||
worker_program_path: Option<PathBuf>,
|
||||
) -> Result<
|
||||
NewFull<Arc<Client>>,
|
||||
Error,
|
||||
> {
|
||||
) -> Result<NewFull<Arc<Client>>, Error> {
|
||||
polkadot_service::new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor, _>(
|
||||
config,
|
||||
is_collator,
|
||||
@@ -115,17 +111,10 @@ pub fn node_config(
|
||||
) -> Configuration {
|
||||
let base_path = BasePath::new_temp_dir().expect("could not create temporary directory");
|
||||
let root = base_path.path();
|
||||
let role = if is_validator {
|
||||
Role::Authority
|
||||
} else {
|
||||
Role::Full
|
||||
};
|
||||
let role = if is_validator { Role::Authority } else { Role::Full };
|
||||
let key_seed = key.to_seed();
|
||||
let mut spec = polkadot_local_testnet_config();
|
||||
let mut storage = spec
|
||||
.as_storage_builder()
|
||||
.build_storage()
|
||||
.expect("could not build storage");
|
||||
let mut storage = spec.as_storage_builder().build_storage().expect("could not build storage");
|
||||
|
||||
BasicExternalities::execute_with_storage(&mut storage, storage_update_func);
|
||||
spec.set_storage(storage);
|
||||
@@ -142,13 +131,9 @@ pub fn node_config(
|
||||
network_config.allow_non_globals_in_dht = true;
|
||||
|
||||
let addr: multiaddr::Multiaddr = multiaddr::Protocol::Memory(rand::random()).into();
|
||||
network_config
|
||||
.listen_addresses
|
||||
.push(addr.clone());
|
||||
network_config.listen_addresses.push(addr.clone());
|
||||
|
||||
network_config
|
||||
.public_addresses
|
||||
.push(addr);
|
||||
network_config.public_addresses.push(addr);
|
||||
|
||||
network_config.transport = TransportConfig::MemoryOnly;
|
||||
|
||||
@@ -161,10 +146,7 @@ pub fn node_config(
|
||||
network: network_config,
|
||||
keystore: KeystoreConfig::InMemory,
|
||||
keystore_remote: Default::default(),
|
||||
database: DatabaseConfig::RocksDb {
|
||||
path: root.join("db"),
|
||||
cache_size: 128,
|
||||
},
|
||||
database: DatabaseConfig::RocksDb { path: root.join("db"), cache_size: 128 },
|
||||
state_cache_size: 16777216,
|
||||
state_cache_child_ratio: None,
|
||||
state_pruning: Default::default(),
|
||||
@@ -224,19 +206,14 @@ pub fn run_validator_node(
|
||||
let config = node_config(storage_update_func, task_executor, key, boot_nodes, true);
|
||||
let multiaddr = config.network.listen_addresses[0].clone();
|
||||
let NewFull { task_manager, client, network, rpc_handlers, overseer_handle, .. } =
|
||||
new_full(config, IsCollator::No, worker_program_path).expect("could not create Polkadot test service");
|
||||
new_full(config, IsCollator::No, worker_program_path)
|
||||
.expect("could not create Polkadot test service");
|
||||
|
||||
let overseer_handle = overseer_handle.expect("test node must have an overseer handle");
|
||||
let peer_id = network.local_peer_id().clone();
|
||||
let addr = MultiaddrWithPeerId { multiaddr, peer_id };
|
||||
|
||||
PolkadotTestNode {
|
||||
task_manager,
|
||||
client,
|
||||
overseer_handle,
|
||||
addr,
|
||||
rpc_handlers,
|
||||
}
|
||||
PolkadotTestNode { task_manager, client, overseer_handle, addr, rpc_handlers }
|
||||
}
|
||||
|
||||
/// Run a test collator node that uses the test runtime.
|
||||
@@ -260,27 +237,15 @@ pub fn run_collator_node(
|
||||
) -> PolkadotTestNode {
|
||||
let config = node_config(storage_update_func, task_executor, key, boot_nodes, false);
|
||||
let multiaddr = config.network.listen_addresses[0].clone();
|
||||
let NewFull {
|
||||
task_manager,
|
||||
client,
|
||||
network,
|
||||
rpc_handlers,
|
||||
overseer_handle,
|
||||
..
|
||||
} = new_full(config, IsCollator::Yes(collator_pair), None)
|
||||
.expect("could not create Polkadot test service");
|
||||
let NewFull { task_manager, client, network, rpc_handlers, overseer_handle, .. } =
|
||||
new_full(config, IsCollator::Yes(collator_pair), None)
|
||||
.expect("could not create Polkadot test service");
|
||||
|
||||
let overseer_handle = overseer_handle.expect("test node must have an overseer handle");
|
||||
let peer_id = network.local_peer_id().clone();
|
||||
let addr = MultiaddrWithPeerId { multiaddr, peer_id };
|
||||
|
||||
PolkadotTestNode {
|
||||
task_manager,
|
||||
client,
|
||||
overseer_handle,
|
||||
addr,
|
||||
rpc_handlers,
|
||||
}
|
||||
PolkadotTestNode { task_manager, client, overseer_handle, addr, rpc_handlers }
|
||||
}
|
||||
|
||||
/// A Polkadot test node instance used for testing.
|
||||
@@ -325,7 +290,9 @@ impl PolkadotTestNode {
|
||||
},
|
||||
);
|
||||
|
||||
self.send_extrinsic(SudoCall::sudo(Box::new(call.into())), Sr25519Keyring::Alice).await.map(drop)
|
||||
self.send_extrinsic(SudoCall::sudo(Box::new(call.into())), Sr25519Keyring::Alice)
|
||||
.await
|
||||
.map(drop)
|
||||
}
|
||||
|
||||
/// Wait for `count` blocks to be imported in the node and then exit. This function will not return if no blocks
|
||||
@@ -341,11 +308,7 @@ impl PolkadotTestNode {
|
||||
para_id: ParaId,
|
||||
collator: CollatorFn,
|
||||
) {
|
||||
let config = CollationGenerationConfig {
|
||||
key: collator_key,
|
||||
collator,
|
||||
para_id,
|
||||
};
|
||||
let config = CollationGenerationConfig { key: collator_key, collator, para_id };
|
||||
|
||||
self.overseer_handle
|
||||
.send_msg(CollationGenerationMessage::Initialize(config), "Collator")
|
||||
@@ -368,10 +331,8 @@ pub fn construct_extrinsic(
|
||||
let current_block = client.info().best_number.saturated_into();
|
||||
let genesis_block = client.hash(0).unwrap().unwrap();
|
||||
let nonce = 0;
|
||||
let period = BlockHashCount::get()
|
||||
.checked_next_power_of_two()
|
||||
.map(|c| c / 2)
|
||||
.unwrap_or(2) as u64;
|
||||
let period =
|
||||
BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
|
||||
let tip = 0;
|
||||
let extra: SignedExtra = (
|
||||
frame_system::CheckSpecVersion::<Runtime>::new(),
|
||||
@@ -411,12 +372,10 @@ pub fn construct_transfer_extrinsic(
|
||||
dest: sp_keyring::AccountKeyring,
|
||||
value: Balance,
|
||||
) -> UncheckedExtrinsic {
|
||||
let function = polkadot_test_runtime::Call::Balances(
|
||||
pallet_balances::Call::transfer(
|
||||
MultiSigner::from(dest.public()).into_account().into(),
|
||||
value,
|
||||
),
|
||||
);
|
||||
let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer(
|
||||
MultiSigner::from(dest.public()).into_account().into(),
|
||||
value,
|
||||
));
|
||||
|
||||
construct_extrinsic(client, function, origin)
|
||||
}
|
||||
|
||||
@@ -25,13 +25,8 @@ async fn ensure_test_service_build_blocks(task_executor: TaskExecutor) {
|
||||
builder.with_colors(false);
|
||||
builder.init().expect("Sets up logger");
|
||||
|
||||
let mut alice = run_validator_node(
|
||||
task_executor.clone(),
|
||||
Sr25519Keyring::Alice,
|
||||
|| {},
|
||||
Vec::new(),
|
||||
None,
|
||||
);
|
||||
let mut alice =
|
||||
run_validator_node(task_executor.clone(), Sr25519Keyring::Alice, || {}, Vec::new(), None);
|
||||
let mut bob = run_validator_node(
|
||||
task_executor.clone(),
|
||||
Sr25519Keyring::Bob,
|
||||
|
||||
@@ -34,11 +34,7 @@ async fn call_function_actually_work(task_executor: TaskExecutor) {
|
||||
assert!(object.contains_key("jsonrpc"), "key jsonrpc exists");
|
||||
let result = object.get("result");
|
||||
let result = result.expect("key result exists");
|
||||
assert_eq!(
|
||||
result.as_str().map(|x| x.starts_with("0x")),
|
||||
Some(true),
|
||||
"result starts with 0x",
|
||||
);
|
||||
assert_eq!(result.as_str().map(|x| x.starts_with("0x")), Some(true), "result starts with 0x",);
|
||||
|
||||
alice.task_manager.clean_shutdown().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user