mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
Uniformize tests (#220)
* Initial commit Forked at:56753b7717Parent branch: origin/master * Copy runtime module from rococo Forked at:56753b7717Parent branch: origin/master * Also copy dependencies pallets and primitives Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * test-service * Move integration test * CLEANUP Forked at:56753b7717Parent branch: origin/master * Not sure what went wrong... * WIP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * CLEANUP Forked at:56753b7717Parent branch: origin/master * fmt * CLEANUP Forked at:56753b7717Parent branch: origin/master * CLEANUP Forked at:56753b7717Parent branch: origin/master * Remove pallet contracts (not used) * Remove pallet parachain-info and token-dealer (not used) * Sort dependencies alphabetically * CLEANUP Forked at:56753b7717Parent branch: origin/master * CumulusTestNode for testing * Speed up block generation * Fix improper shutdown * rustfmt * runtime: replace const by storage * Fix for previous commit * Remove some generics * Move generate_genesis_state to cumulus-primitives * fmt * Remove message_example * fixup! Remove message_example * WIP Forked at:56753b7717Parent branch: origin/master * Half the solution to previous commit :( * Revert "Fix for previous commit" This reverts commit 60010bab6797487093ac8c790b3a536f7ca0895b. * Revert "runtime: replace const by storage" This reverts commit c64b3a46f0325a98922015e0cbf3570e2e431774. Not working for some reason... * Use helper Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * Remove test-primitives * Revert "Half the solution to previous commit :(" This reverts commit 9a8f89f9f06252198e6405057043c6b313f1aea4. * Revert "Revert "Half the solution to previous commit :("" This reverts commit 6a93f0f09d74ccdc3738dd78a777c483427c03ce. * Test with some extra extrinsics * WIP Forked at:56753b7717Parent branch: origin/master * CLEANUP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * WIP Forked at:56753b7717Parent branch: origin/master * CLEANUP Forked at:56753b7717Parent branch: origin/master * Remove message broker
This commit is contained in:
@@ -15,24 +15,18 @@
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use ansi_term::Color;
|
||||
use cumulus_collator::CollatorBuilder;
|
||||
use cumulus_network::DelayedBlockAnnounceValidator;
|
||||
use cumulus_service::{
|
||||
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
|
||||
};
|
||||
use polkadot_primitives::v0::CollatorPair;
|
||||
use rococo_parachain_primitives::Block;
|
||||
use sc_client_api::{Backend as BackendT, BlockBackend, Finalizer, UsageProvider};
|
||||
use sc_executor::native_executor_instance;
|
||||
pub use sc_executor::NativeExecutor;
|
||||
use sc_informant::OutputFormat;
|
||||
use sc_network::NetworkService;
|
||||
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
|
||||
use sp_api::ConstructRuntimeApi;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_consensus::{BlockImport, Environment, Error as ConsensusError, Proposer};
|
||||
use sp_core::{crypto::Pair, H256};
|
||||
use sp_runtime::traits::{BlakeTwo256, Block as BlockT};
|
||||
use sp_runtime::traits::BlakeTwo256;
|
||||
use sp_trie::PrefixedMemoryDB;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -122,91 +116,6 @@ where
|
||||
Ok(params)
|
||||
}
|
||||
|
||||
/// Start a test collator node for a parachain.
|
||||
///
|
||||
/// A collator is similar to a validator in a normal blockchain.
|
||||
/// It is responsible for producing blocks and sending the blocks to a
|
||||
/// parachain validator for validation and inclusion into the relay chain.
|
||||
pub fn start_test_collator<'a, Block, PF, BI, BS, Client, Backend>(
|
||||
StartCollatorParams {
|
||||
para_id,
|
||||
proposer_factory,
|
||||
inherent_data_providers,
|
||||
block_import,
|
||||
block_status,
|
||||
announce_block,
|
||||
client,
|
||||
block_announce_validator,
|
||||
task_manager,
|
||||
polkadot_config,
|
||||
collator_key,
|
||||
}: StartCollatorParams<'a, Block, PF, BI, BS, Client>,
|
||||
) -> sc_service::error::Result<()>
|
||||
where
|
||||
Block: BlockT,
|
||||
PF: Environment<Block> + Send + 'static,
|
||||
BI: BlockImport<
|
||||
Block,
|
||||
Error = ConsensusError,
|
||||
Transaction = <PF::Proposer as Proposer<Block>>::Transaction,
|
||||
> + Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
BS: BlockBackend<Block> + Send + Sync + 'static,
|
||||
Client: Finalizer<Block, Backend>
|
||||
+ UsageProvider<Block>
|
||||
+ HeaderBackend<Block>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ BlockBackend<Block>
|
||||
+ 'static,
|
||||
for<'b> &'b Client: BlockImport<Block>,
|
||||
Backend: BackendT<Block> + 'static,
|
||||
{
|
||||
let builder = CollatorBuilder::new(
|
||||
proposer_factory,
|
||||
inherent_data_providers,
|
||||
block_import,
|
||||
block_status,
|
||||
para_id,
|
||||
client,
|
||||
announce_block,
|
||||
block_announce_validator,
|
||||
);
|
||||
|
||||
let (polkadot_future, polkadot_task_manager) = {
|
||||
let (task_manager, client, handles, _network, _rpc_handlers) =
|
||||
polkadot_test_service::polkadot_test_new_full(
|
||||
polkadot_config,
|
||||
Some((collator_key.public(), para_id)),
|
||||
None,
|
||||
false,
|
||||
6000,
|
||||
)?;
|
||||
|
||||
let test_client = polkadot_test_service::TestClient(client);
|
||||
|
||||
let future = polkadot_collator::build_collator_service(
|
||||
task_manager.spawn_handle(),
|
||||
handles,
|
||||
test_client,
|
||||
para_id,
|
||||
collator_key,
|
||||
builder,
|
||||
)?;
|
||||
|
||||
(future, task_manager)
|
||||
};
|
||||
|
||||
task_manager
|
||||
.spawn_essential_handle()
|
||||
.spawn("polkadot", polkadot_future);
|
||||
|
||||
task_manager.add_child(polkadot_task_manager);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
|
||||
///
|
||||
/// This is the actual implementation that is abstract over the executor and the runtime api.
|
||||
@@ -217,12 +126,7 @@ fn start_node_impl<RuntimeApi, Executor, RB>(
|
||||
id: polkadot_primitives::v0::Id,
|
||||
validator: bool,
|
||||
rpc_ext_builder: RB,
|
||||
test: bool,
|
||||
) -> sc_service::error::Result<(
|
||||
TaskManager,
|
||||
Arc<TFullClient<Block, RuntimeApi, Executor>>,
|
||||
Arc<NetworkService<Block, H256>>,
|
||||
)>
|
||||
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)>
|
||||
where
|
||||
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>>
|
||||
+ Send
|
||||
@@ -339,11 +243,7 @@ where
|
||||
collator_key,
|
||||
};
|
||||
|
||||
if test {
|
||||
start_test_collator(params)?;
|
||||
} else {
|
||||
start_collator(params)?;
|
||||
}
|
||||
start_collator(params)?;
|
||||
} else {
|
||||
let params = StartFullNodeParams {
|
||||
client: client.clone(),
|
||||
@@ -360,7 +260,7 @@ where
|
||||
|
||||
start_network.start_network();
|
||||
|
||||
Ok((task_manager, client, network))
|
||||
Ok((task_manager, client))
|
||||
}
|
||||
|
||||
/// Start a normal parachain node.
|
||||
@@ -370,11 +270,9 @@ pub fn start_node(
|
||||
polkadot_config: polkadot_collator::Configuration,
|
||||
id: polkadot_primitives::v0::Id,
|
||||
validator: bool,
|
||||
test: bool,
|
||||
) -> sc_service::error::Result<(
|
||||
TaskManager,
|
||||
Arc<TFullClient<Block, parachain_runtime::RuntimeApi, RuntimeExecutor>>,
|
||||
Arc<NetworkService<Block, H256>>,
|
||||
)> {
|
||||
start_node_impl::<parachain_runtime::RuntimeApi, RuntimeExecutor, _>(
|
||||
parachain_config,
|
||||
@@ -383,7 +281,6 @@ pub fn start_node(
|
||||
id,
|
||||
validator,
|
||||
|_| Default::default(),
|
||||
test,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -394,7 +291,6 @@ pub fn start_contracts_node(
|
||||
polkadot_config: polkadot_collator::Configuration,
|
||||
id: polkadot_primitives::v0::Id,
|
||||
validator: bool,
|
||||
test: bool,
|
||||
) -> sc_service::error::Result<TaskManager> {
|
||||
start_node_impl::<parachain_contracts_runtime::RuntimeApi, ContractsRuntimeExecutor, _>(
|
||||
parachain_config,
|
||||
@@ -409,7 +305,6 @@ pub fn start_contracts_node(
|
||||
io.extend_with(ContractsApi::to_delegate(Contracts::new(client)));
|
||||
io
|
||||
},
|
||||
test,
|
||||
)
|
||||
.map(|r| r.0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user