mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 03:01:07 +00:00
Fix a bunch of low work dependency cycles (#4354)
* take test-client off sp-consensus * use test primitives rather than test client in authority discovery tests * move runtime-interface tests * don't forget to remove the dev-dependency * remove more unneeded dev deps * add changes_trie_config to test prrimitives * Separate network crates from its integration tests * Fix up consensus crates for networking test changes * remove unnecessary dependencies * remove unused addition * remove unnecessary dev-dependencies * fixing finality grandpa tests * removing unnecessary executor dependencies
This commit is contained in:
committed by
GitHub
parent
ed50be1eb5
commit
605c0e655e
Generated
+45
-12
@@ -4904,7 +4904,7 @@ dependencies = [
|
||||
"sp-blockchain 2.0.0",
|
||||
"sp-core 2.0.0",
|
||||
"sp-runtime 2.0.0",
|
||||
"substrate-test-runtime-client 2.0.0",
|
||||
"sp-test-primitives 2.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5044,17 +5044,14 @@ name = "sc-client-api"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sc-client-db 2.0.0",
|
||||
"sc-executor 2.0.0",
|
||||
"sc-telemetry 2.0.0",
|
||||
"sp-api 2.0.0",
|
||||
@@ -5064,7 +5061,6 @@ dependencies = [
|
||||
"sp-externalities 2.0.0",
|
||||
"sp-inherents 2.0.0",
|
||||
"sp-keyring 2.0.0",
|
||||
"sp-panic-handler 2.0.0",
|
||||
"sp-runtime 2.0.0",
|
||||
"sp-state-machine 2.0.0",
|
||||
"sp-std 2.0.0",
|
||||
@@ -5072,8 +5068,6 @@ dependencies = [
|
||||
"sp-transaction-pool-api 2.0.0",
|
||||
"sp-trie 2.0.0",
|
||||
"sp-version 2.0.0",
|
||||
"substrate-test-runtime-client 2.0.0",
|
||||
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5122,6 +5116,7 @@ dependencies = [
|
||||
"sc-executor 2.0.0",
|
||||
"sc-keystore 2.0.0",
|
||||
"sc-network 2.0.0",
|
||||
"sc-network-test 2.0.0",
|
||||
"sc-service 2.0.0",
|
||||
"sc-telemetry 2.0.0",
|
||||
"sp-api 2.0.0",
|
||||
@@ -5169,6 +5164,7 @@ dependencies = [
|
||||
"sc-executor 2.0.0",
|
||||
"sc-keystore 2.0.0",
|
||||
"sc-network 2.0.0",
|
||||
"sc-network-test 2.0.0",
|
||||
"sc-service 2.0.0",
|
||||
"sc-telemetry 2.0.0",
|
||||
"schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -5259,8 +5255,6 @@ dependencies = [
|
||||
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sc-client-api 2.0.0",
|
||||
"sc-offchain 2.0.0",
|
||||
"sc-runtime-test 2.0.0",
|
||||
"sp-core 2.0.0",
|
||||
"sp-externalities 2.0.0",
|
||||
@@ -5298,6 +5292,7 @@ dependencies = [
|
||||
"sc-client-api 2.0.0",
|
||||
"sc-keystore 2.0.0",
|
||||
"sc-network 2.0.0",
|
||||
"sc-network-test 2.0.0",
|
||||
"sc-telemetry 2.0.0",
|
||||
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sp-api 2.0.0",
|
||||
@@ -5374,8 +5369,8 @@ dependencies = [
|
||||
"sp-core 2.0.0",
|
||||
"sp-keyring 2.0.0",
|
||||
"sp-runtime 2.0.0",
|
||||
"sp-test-primitives 2.0.0",
|
||||
"substrate-test-client 2.0.0",
|
||||
"substrate-test-runtime 2.0.0",
|
||||
"substrate-test-runtime-client 2.0.0",
|
||||
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -5385,6 +5380,33 @@ dependencies = [
|
||||
"zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sc-network-test"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sc-block-builder 2.0.0",
|
||||
"sc-client 2.0.0",
|
||||
"sc-client-api 2.0.0",
|
||||
"sc-network 2.0.0",
|
||||
"sp-blockchain 2.0.0",
|
||||
"sp-consensus 2.0.0",
|
||||
"sp-consensus-babe 2.0.0",
|
||||
"sp-core 2.0.0",
|
||||
"sp-runtime 2.0.0",
|
||||
"substrate-test-runtime 2.0.0",
|
||||
"substrate-test-runtime-client 2.0.0",
|
||||
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sc-offchain"
|
||||
version = "2.0.0"
|
||||
@@ -6090,8 +6112,8 @@ dependencies = [
|
||||
"sp-inherents 2.0.0",
|
||||
"sp-runtime 2.0.0",
|
||||
"sp-std 2.0.0",
|
||||
"sp-test-primitives 2.0.0",
|
||||
"sp-version 2.0.0",
|
||||
"substrate-test-runtime-client 2.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6326,7 +6348,6 @@ dependencies = [
|
||||
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sc-executor 2.0.0",
|
||||
"sp-core 2.0.0",
|
||||
"sp-externalities 2.0.0",
|
||||
"sp-io 2.0.0",
|
||||
@@ -6350,6 +6371,18 @@ dependencies = [
|
||||
"syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sp-runtime-interface-test"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"sc-executor 2.0.0",
|
||||
"sp-core 2.0.0",
|
||||
"sp-io 2.0.0",
|
||||
"sp-runtime-interface 2.0.0",
|
||||
"sp-runtime-interface-test-wasm 2.0.0",
|
||||
"sp-state-machine 2.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sp-runtime-interface-test-wasm"
|
||||
version = "2.0.0"
|
||||
|
||||
@@ -30,6 +30,7 @@ members = [
|
||||
"client/tracing",
|
||||
"client/keystore",
|
||||
"client/network",
|
||||
"client/network/test",
|
||||
"client/offchain",
|
||||
"client/peerset",
|
||||
"client/rpc-servers",
|
||||
@@ -114,6 +115,7 @@ members = [
|
||||
"primitives/runtime-interface",
|
||||
"primitives/runtime-interface/proc-macro",
|
||||
"primitives/runtime-interface/test-wasm",
|
||||
"primitives/runtime-interface/test",
|
||||
"primitives/serializer",
|
||||
"primitives/session",
|
||||
"primitives/api",
|
||||
|
||||
@@ -31,10 +31,4 @@ trie = { package = "sp-trie", path = "../../primitives/trie" }
|
||||
txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" }
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.7.0"
|
||||
tempfile = "3.1.0"
|
||||
client-db = { package = "sc-client-db", path = "../db", features = ["kvdb-rocksdb"] }
|
||||
test-primitives = { package = "sp-test-primitives", path = "../../primitives/test-primitives" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" }
|
||||
kvdb-memorydb = "0.1.2"
|
||||
panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" }
|
||||
test-primitives = { package = "sp-test-primitives", path = "../../primitives/test-primitives" }
|
||||
@@ -30,5 +30,5 @@ sp-runtime = { path = "../../primitives/runtime" }
|
||||
env_logger = "0.7.0"
|
||||
parking_lot = "0.9.0"
|
||||
peerset = { package = "sc-peerset", path = "../peerset" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" }
|
||||
sp-test-primitives = { path = "../../primitives/test-primitives" }
|
||||
sp-api = { path = "../../primitives/api" }
|
||||
|
||||
@@ -555,7 +555,7 @@ mod tests {
|
||||
use sp_runtime::traits::Zero;
|
||||
use sp_runtime::traits::{ApiRef, Block as BlockT, NumberFor, ProvideRuntimeApi};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use test_client::runtime::Block;
|
||||
use sp_test_primitives::Block;
|
||||
|
||||
#[test]
|
||||
fn interval_at_with_start_now() {
|
||||
|
||||
@@ -34,7 +34,8 @@ sc-telemetry = { path = "../../telemetry" }
|
||||
[dev-dependencies]
|
||||
keyring = { package = "sp-keyring", path = "../../../primitives/keyring" }
|
||||
sc-executor = { path = "../../executor" }
|
||||
network = { package = "sc-network", path = "../../network", features = ["test-helpers"]}
|
||||
sc-network = { path = "../../network" }
|
||||
sc-network-test = { path = "../../network/test" }
|
||||
service = { package = "sc-service", path = "../../service" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" }
|
||||
tokio = "0.1.22"
|
||||
|
||||
@@ -748,10 +748,9 @@ pub fn import_queue<B, C, P, T>(
|
||||
mod tests {
|
||||
use super::*;
|
||||
use consensus_common::NoNetwork as DummyOracle;
|
||||
use network::test::*;
|
||||
use network::test::{Block as TestBlock, PeersClient, PeersFullClient};
|
||||
use sc_network_test::{Block as TestBlock, *};
|
||||
use sp_runtime::traits::{Block as BlockT, DigestFor};
|
||||
use network::config::ProtocolConfig;
|
||||
use sc_network::config::ProtocolConfig;
|
||||
use parking_lot::Mutex;
|
||||
use tokio::runtime::current_thread;
|
||||
use keyring::sr25519::Keyring;
|
||||
|
||||
@@ -43,7 +43,8 @@ derive_more = "0.99.2"
|
||||
[dev-dependencies]
|
||||
keyring = { package = "sp-keyring", path = "../../../primitives/keyring" }
|
||||
sc-executor = { path = "../../executor" }
|
||||
network = { package = "sc-network", path = "../../network", features = ["test-helpers"]}
|
||||
sc-network = { path = "../../network" }
|
||||
sc-network-test = { path = "../../network/test" }
|
||||
service = { package = "sc-service", path = "../../service" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" }
|
||||
block-builder = { package = "sc-block-builder", path = "../../block-builder" }
|
||||
|
||||
@@ -28,11 +28,10 @@ use consensus_common::NoNetwork as DummyOracle;
|
||||
use consensus_common::import_queue::{
|
||||
BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport,
|
||||
};
|
||||
use network::test::*;
|
||||
use network::test::{Block as TestBlock, PeersClient};
|
||||
use network::config::BoxFinalityProofRequestBuilder;
|
||||
use sc_network_test::*;
|
||||
use sc_network_test::{Block as TestBlock, PeersClient};
|
||||
use sc_network::config::{BoxFinalityProofRequestBuilder, ProtocolConfig};
|
||||
use sp_runtime::{generic::DigestItem, traits::{Block as BlockT, DigestFor}};
|
||||
use network::config::ProtocolConfig;
|
||||
use tokio::runtime::current_thread;
|
||||
use client_api::BlockchainEvents;
|
||||
use test_client;
|
||||
|
||||
@@ -39,8 +39,6 @@ hex-literal = "0.2.1"
|
||||
runtime-test = { package = "sc-runtime-test", path = "runtime-test" }
|
||||
test-runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" }
|
||||
runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" }
|
||||
client-api = { package = "sc-client-api", path = "../api" }
|
||||
sc-offchain = { path = "../offchain/" }
|
||||
state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
|
||||
test-case = "0.3.3"
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["deriv
|
||||
|
||||
[dev-dependencies]
|
||||
grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec", "test-helpers"] }
|
||||
network = { package = "sc-network", path = "../network", features = ["test-helpers"] }
|
||||
network = { package = "sc-network", path = "../network" }
|
||||
sc-network-test = { path = "../network/test" }
|
||||
keyring = { package = "sp-keyring", path = "../../primitives/keyring" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client"}
|
||||
babe_primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" }
|
||||
|
||||
@@ -1506,7 +1506,7 @@ mod tests {
|
||||
use super::*;
|
||||
use super::environment::SharedVoterSetState;
|
||||
use network_gossip::Validator as GossipValidatorT;
|
||||
use network::test::Block;
|
||||
use sc_network_test::Block;
|
||||
use primitives::{crypto::Public, H256};
|
||||
|
||||
// some random config (not really needed)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use futures::sync::mpsc;
|
||||
use futures::prelude::*;
|
||||
use network::consensus_gossip as network_gossip;
|
||||
use network::test::{Block, Hash};
|
||||
use sc_network_test::{Block, Hash};
|
||||
use network_gossip::Validator;
|
||||
use tokio::runtime::current_thread;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
use super::*;
|
||||
use environment::HasVoted;
|
||||
use network::test::{Block, DummySpecialization, Hash, TestNetFactory, Peer, PeersClient};
|
||||
use network::test::{PassThroughVerifier};
|
||||
use sc_network_test::{Block, DummySpecialization, Hash, TestNetFactory, Peer, PeersClient};
|
||||
use sc_network_test::{PassThroughVerifier};
|
||||
use network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder};
|
||||
use parking_lot::Mutex;
|
||||
use futures03::{StreamExt as _, TryStreamExt as _};
|
||||
@@ -1553,7 +1553,7 @@ fn voter_catches_up_to_latest_round_when_behind() {
|
||||
#[test]
|
||||
fn grandpa_environment_respects_voting_rules() {
|
||||
use grandpa::Chain;
|
||||
use network::test::TestClient;
|
||||
use sc_network_test::TestClient;
|
||||
|
||||
let peers = &[Ed25519Keyring::Alice];
|
||||
let voters = make_ids(peers);
|
||||
|
||||
@@ -51,12 +51,11 @@ zeroize = "1.0.0"
|
||||
babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-test-primitives = { path = "../../primitives/test-primitives" }
|
||||
env_logger = "0.7.0"
|
||||
keyring = { package = "sp-keyring", path = "../../primitives/keyring" }
|
||||
quickcheck = "0.9.0"
|
||||
rand = "0.7.2"
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" }
|
||||
test_runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" }
|
||||
tempfile = "3.1.0"
|
||||
tokio = "0.1.22"
|
||||
|
||||
|
||||
@@ -181,15 +181,12 @@ mod utils;
|
||||
pub mod config;
|
||||
pub mod error;
|
||||
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
pub mod test;
|
||||
|
||||
pub use chain::{Client as ClientHandle, FinalityProofProvider};
|
||||
pub use service::{
|
||||
NetworkService, NetworkWorker, TransactionPool, ExHashT, ReportHandle,
|
||||
NetworkStateInfo,
|
||||
};
|
||||
pub use protocol::{PeerInfo, Context, consensus_gossip, message, specialization};
|
||||
pub use protocol::{PeerInfo, Context, ProtocolConfig, consensus_gossip, message, specialization};
|
||||
pub use protocol::event::{Event, DhtEvent};
|
||||
pub use protocol::sync::SyncState;
|
||||
pub use libp2p::{Multiaddr, PeerId};
|
||||
|
||||
@@ -27,7 +27,7 @@ use rand::seq::SliceRandom;
|
||||
use std::{io, time::Duration, time::Instant};
|
||||
use crate::message::Message;
|
||||
use crate::protocol::legacy_proto::{LegacyProto, LegacyProtoOut};
|
||||
use test_client::runtime::Block;
|
||||
use sp_test_primitives::Block;
|
||||
|
||||
/// Builds two nodes that have each other as bootstrap nodes.
|
||||
/// This is to be used only for testing, and a panic will happen if something goes wrong.
|
||||
|
||||
@@ -686,7 +686,7 @@ pub mod tests {
|
||||
use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId};
|
||||
use libp2p::PeerId;
|
||||
use super::{REQUEST_TIMEOUT, LightDispatch, LightDispatchNetwork, RequestData, StorageProof};
|
||||
use test_client::runtime::{changes_trie_config, Block, Extrinsic, Header};
|
||||
use sp_test_primitives::{changes_trie_config, Block, Extrinsic, Header};
|
||||
|
||||
struct DummyFetchChecker { ok: bool }
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ mod tests {
|
||||
use rand::Rng;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use super::*;
|
||||
use test_client::runtime::{Block, BlockNumber, Hash};
|
||||
use sp_test_primitives::{Block, BlockNumber, Hash};
|
||||
|
||||
#[test]
|
||||
fn requests_are_processed_in_order() {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
[package]
|
||||
description = "Integration tests for Substrate network protocol"
|
||||
name = "sc-network-test"
|
||||
version = "2.0.0"
|
||||
license = "GPL-3.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
sc-network = { path = "../" }
|
||||
log = "0.4.8"
|
||||
parking_lot = "0.9.0"
|
||||
futures = "0.1.29"
|
||||
futures03 = { package = "futures", version = "0.3.1", features = ["compat"] }
|
||||
futures-timer = "0.4.0"
|
||||
rand = "0.7.2"
|
||||
libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] }
|
||||
consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
client = { package = "sc-client", path = "../../" }
|
||||
client-api = { package = "sc-client-api", path = "../../api" }
|
||||
sp-blockchain = { path = "../../../primitives/blockchain" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
block-builder = { package = "sc-block-builder", path = "../../block-builder" }
|
||||
babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" }
|
||||
env_logger = "0.7.0"
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" }
|
||||
test_runtime = { package = "substrate-test-runtime", path = "../../../test/utils/runtime" }
|
||||
tempfile = "3.1.0"
|
||||
tokio = "0.1.22"
|
||||
+13
-15
@@ -24,9 +24,9 @@ mod sync;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::config::build_multiaddr;
|
||||
use libp2p::build_multiaddr;
|
||||
use log::trace;
|
||||
use crate::chain::FinalityProofProvider;
|
||||
use sc_network::FinalityProofProvider;
|
||||
use sp_blockchain::{
|
||||
Result as ClientResult, well_known_cache_keys::{self, Id as CacheKeyId},
|
||||
};
|
||||
@@ -38,7 +38,7 @@ use client_api::{
|
||||
};
|
||||
use block_builder::BlockBuilder;
|
||||
use client::LongestChain;
|
||||
use crate::config::Roles;
|
||||
use sc_network::config::Roles;
|
||||
use consensus::block_validation::DefaultBlockAnnounceValidator;
|
||||
use consensus::import_queue::BasicQueue;
|
||||
use consensus::import_queue::{
|
||||
@@ -49,17 +49,17 @@ use consensus::Error as ConsensusError;
|
||||
use consensus::{BlockOrigin, ForkChoiceStrategy, BlockImportParams, BlockCheckParams, JustificationImport};
|
||||
use futures::prelude::*;
|
||||
use futures03::{StreamExt as _, TryStreamExt as _};
|
||||
use crate::{NetworkWorker, NetworkService, ReportHandle, config::ProtocolId};
|
||||
use crate::config::{NetworkConfiguration, TransportConfig, BoxFinalityProofRequestBuilder};
|
||||
use sc_network::{NetworkWorker, NetworkService, ReportHandle, config::ProtocolId};
|
||||
use sc_network::config::{NetworkConfiguration, TransportConfig, BoxFinalityProofRequestBuilder};
|
||||
use libp2p::PeerId;
|
||||
use parking_lot::Mutex;
|
||||
use primitives::H256;
|
||||
use crate::protocol::{Context, ProtocolConfig};
|
||||
use sc_network::{Context, ProtocolConfig};
|
||||
use sp_runtime::generic::{BlockId, OpaqueDigestItemId};
|
||||
use sp_runtime::traits::{Block as BlockT, Header, NumberFor};
|
||||
use sp_runtime::Justification;
|
||||
use crate::service::TransactionPool;
|
||||
use crate::specialization::NetworkSpecialization;
|
||||
use sc_network::TransactionPool;
|
||||
use sc_network::specialization::NetworkSpecialization;
|
||||
use test_client::{self, AccountKeyring};
|
||||
|
||||
pub use test_client::runtime::{Block, Extrinsic, Hash, Transfer};
|
||||
@@ -67,13 +67,11 @@ pub use test_client::{TestClient, TestClientBuilder, TestClientBuilderExt};
|
||||
|
||||
type AuthorityId = babe_primitives::AuthorityId;
|
||||
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
/// A Verifier that accepts all blocks and passes them on with the configured
|
||||
/// finality to be imported.
|
||||
#[derive(Clone)]
|
||||
pub struct PassThroughVerifier(pub bool);
|
||||
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
/// This `Verifier` accepts all data as valid.
|
||||
impl<B: BlockT> Verifier<B> for PassThroughVerifier {
|
||||
fn verify(
|
||||
@@ -117,7 +115,7 @@ impl NetworkSpecialization<Block> for DummySpecialization {
|
||||
&mut self,
|
||||
_ctx: &mut dyn Context<Block>,
|
||||
_peer_id: PeerId,
|
||||
_status: crate::message::Status<Block>
|
||||
_status: sc_network::message::Status<Block>
|
||||
) {}
|
||||
|
||||
fn on_disconnect(&mut self, _ctx: &mut dyn Context<Block>, _peer_id: PeerId) {}
|
||||
@@ -401,8 +399,8 @@ impl TransactionPool<Hash, Block> for EmptyTransactionPool {
|
||||
&self,
|
||||
_report_handle: ReportHandle,
|
||||
_who: PeerId,
|
||||
_rep_change_good: crate::ReputationChange,
|
||||
_rep_change_bad: crate::ReputationChange,
|
||||
_rep_change_good: sc_network::ReputationChange,
|
||||
_rep_change_bad: sc_network::ReputationChange,
|
||||
_transaction: Extrinsic
|
||||
) {}
|
||||
|
||||
@@ -563,7 +561,7 @@ pub trait TestNetFactory: Sized {
|
||||
|
||||
let listen_addr = build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let network = NetworkWorker::new(crate::config::Params {
|
||||
let network = NetworkWorker::new(sc_network::config::Params {
|
||||
roles: config.roles,
|
||||
network_config: NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
@@ -637,7 +635,7 @@ pub trait TestNetFactory: Sized {
|
||||
|
||||
let listen_addr = build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let network = NetworkWorker::new(crate::config::Params {
|
||||
let network = NetworkWorker::new(sc_network::config::Params {
|
||||
roles: config.roles,
|
||||
network_config: NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::config::Roles;
|
||||
use sc_network::config::Roles;
|
||||
use consensus::BlockOrigin;
|
||||
use futures03::TryFutureExt as _;
|
||||
use std::time::Duration;
|
||||
@@ -20,7 +20,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive
|
||||
parking_lot = "0.9.0"
|
||||
|
||||
[dev-dependencies]
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" }
|
||||
sp-test-primitives = { path = "../../test-primitives" }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
//! ```
|
||||
//! use sp_consensus::import_queue::Link;
|
||||
//! # use sp_consensus::import_queue::buffered_link::buffered_link;
|
||||
//! # use test_client::runtime::Block;
|
||||
//! # use sp_test_primitives::Block;
|
||||
//! # struct DummyLink; impl Link<Block> for DummyLink {}
|
||||
//! # let mut my_link = DummyLink;
|
||||
//! let (mut tx, mut rx) = buffered_link::<Block>();
|
||||
@@ -161,7 +161,7 @@ impl<B: BlockT> BufferedLinkReceiver<B> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use test_client::runtime::Block;
|
||||
use sp_test_primitives::Block;
|
||||
|
||||
#[test]
|
||||
fn is_closed() {
|
||||
|
||||
@@ -15,7 +15,6 @@ static_assertions = "1.0.0"
|
||||
primitive-types = { version = "0.6.1", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
executor = { package = "sc-executor", path = "../../client/executor" }
|
||||
test-wasm = { package = "sp-runtime-interface-test-wasm", path = "test-wasm" }
|
||||
state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
|
||||
primitives = { package = "sp-core", path = "../core" }
|
||||
|
||||
@@ -260,97 +260,4 @@ pub type Pointer<T> = *mut T;
|
||||
|
||||
/// A pointer that can be used in a runtime interface function signature.
|
||||
#[cfg(feature = "std")]
|
||||
pub type Pointer<T> = wasm_interface::Pointer<T>;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use test_wasm::{WASM_BINARY, test_api::HostFunctions};
|
||||
use wasm_interface::HostFunctions as HostFunctionsT;
|
||||
|
||||
type TestExternalities = state_machine::TestExternalities<primitives::Blake2Hasher, u64>;
|
||||
|
||||
fn call_wasm_method<HF: HostFunctionsT>(method: &str) -> TestExternalities {
|
||||
let mut ext = TestExternalities::default();
|
||||
let mut ext_ext = ext.ext();
|
||||
|
||||
executor::call_in_wasm::<
|
||||
_,
|
||||
(
|
||||
HF,
|
||||
sp_io::SubstrateHostFunctions,
|
||||
executor::deprecated_host_interface::SubstrateExternals
|
||||
)
|
||||
>(
|
||||
method,
|
||||
&[],
|
||||
executor::WasmExecutionMethod::Interpreted,
|
||||
&mut ext_ext,
|
||||
&WASM_BINARY[..],
|
||||
8,
|
||||
).expect(&format!("Executes `{}`", method));
|
||||
|
||||
ext
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_data() {
|
||||
call_wasm_method::<HostFunctions>("test_return_data");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_option_data() {
|
||||
call_wasm_method::<HostFunctions>("test_return_option_data");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_set_storage() {
|
||||
let mut ext = call_wasm_method::<HostFunctions>("test_set_storage");
|
||||
|
||||
let expected = "world";
|
||||
assert_eq!(expected.as_bytes(), &ext.ext().storage("hello".as_bytes()).unwrap()[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_value_into_mutable_reference() {
|
||||
call_wasm_method::<HostFunctions>("test_return_value_into_mutable_reference");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_and_return_array() {
|
||||
call_wasm_method::<HostFunctions>("test_get_and_return_array");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_array_as_mutable_reference() {
|
||||
call_wasm_method::<HostFunctions>("test_array_as_mutable_reference");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_input_public_key() {
|
||||
call_wasm_method::<HostFunctions>("test_return_input_public_key");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(
|
||||
expected = "Other(\"Instantiation: Export ext_test_api_return_input_version_1 not found\")"
|
||||
)]
|
||||
fn host_function_not_found() {
|
||||
call_wasm_method::<()>("test_return_data");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(
|
||||
expected =
|
||||
"FunctionExecution(\"ext_test_api_invalid_utf8_data_version_1\", \
|
||||
\"Invalid utf8 data provided\")"
|
||||
)]
|
||||
fn test_invalid_utf8_data_should_return_an_error() {
|
||||
call_wasm_method::<HostFunctions>("test_invalid_utf8_data_should_return_an_error");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_overwrite_native_function_implementation() {
|
||||
call_wasm_method::<HostFunctions>("test_overwrite_native_function_implementation");
|
||||
}
|
||||
}
|
||||
pub type Pointer<T> = wasm_interface::Pointer<T>;
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "sp-runtime-interface-test"
|
||||
version = "2.0.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
sp-runtime-interface = { path = "../" }
|
||||
executor = { package = "sc-executor", path = "../../../client/executor" }
|
||||
test-wasm = { package = "sp-runtime-interface-test-wasm", path = "../test-wasm" }
|
||||
state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" }
|
||||
primitives = { package = "sp-core", path = "../../core" }
|
||||
sp-io = { path = "../../io" }
|
||||
@@ -0,0 +1,107 @@
|
||||
// Copyright 2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Integration tests for runtime interface primitives
|
||||
|
||||
use sp_runtime_interface::*;
|
||||
use test_wasm::{WASM_BINARY, test_api::HostFunctions};
|
||||
use wasm_interface::HostFunctions as HostFunctionsT;
|
||||
|
||||
type TestExternalities = state_machine::TestExternalities<primitives::Blake2Hasher, u64>;
|
||||
|
||||
fn call_wasm_method<HF: HostFunctionsT>(method: &str) -> TestExternalities {
|
||||
let mut ext = TestExternalities::default();
|
||||
let mut ext_ext = ext.ext();
|
||||
|
||||
executor::call_in_wasm::<
|
||||
_,
|
||||
(
|
||||
HF,
|
||||
sp_io::SubstrateHostFunctions,
|
||||
executor::deprecated_host_interface::SubstrateExternals
|
||||
)
|
||||
>(
|
||||
method,
|
||||
&[],
|
||||
executor::WasmExecutionMethod::Interpreted,
|
||||
&mut ext_ext,
|
||||
&WASM_BINARY[..],
|
||||
8,
|
||||
).expect(&format!("Executes `{}`", method));
|
||||
|
||||
ext
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_data() {
|
||||
call_wasm_method::<HostFunctions>("test_return_data");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_option_data() {
|
||||
call_wasm_method::<HostFunctions>("test_return_option_data");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_set_storage() {
|
||||
let mut ext = call_wasm_method::<HostFunctions>("test_set_storage");
|
||||
|
||||
let expected = "world";
|
||||
assert_eq!(expected.as_bytes(), &ext.ext().storage("hello".as_bytes()).unwrap()[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_value_into_mutable_reference() {
|
||||
call_wasm_method::<HostFunctions>("test_return_value_into_mutable_reference");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_and_return_array() {
|
||||
call_wasm_method::<HostFunctions>("test_get_and_return_array");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_array_as_mutable_reference() {
|
||||
call_wasm_method::<HostFunctions>("test_array_as_mutable_reference");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_input_public_key() {
|
||||
call_wasm_method::<HostFunctions>("test_return_input_public_key");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(
|
||||
expected = "Other(\"Instantiation: Export ext_test_api_return_input_version_1 not found\")"
|
||||
)]
|
||||
fn host_function_not_found() {
|
||||
call_wasm_method::<()>("test_return_data");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(
|
||||
expected =
|
||||
"FunctionExecution(\"ext_test_api_invalid_utf8_data_version_1\", \
|
||||
\"Invalid utf8 data provided\")"
|
||||
)]
|
||||
fn test_invalid_utf8_data_should_return_an_error() {
|
||||
call_wasm_method::<HostFunctions>("test_invalid_utf8_data_should_return_an_error");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_overwrite_native_function_implementation() {
|
||||
call_wasm_method::<HostFunctions>("test_overwrite_native_function_implementation");
|
||||
}
|
||||
@@ -76,3 +76,12 @@ pub type Digest = sp_runtime::generic::Digest<H256>;
|
||||
pub type Block = sp_runtime::generic::Block<Header, Extrinsic>;
|
||||
/// A test block's header.
|
||||
pub type Header = sp_runtime::generic::Header<BlockNumber, BlakeTwo256>;
|
||||
|
||||
|
||||
/// Changes trie configuration (optionally) used in tests.
|
||||
pub fn changes_trie_config() -> primitives::ChangesTrieConfiguration {
|
||||
primitives::ChangesTrieConfiguration {
|
||||
digest_interval: 4,
|
||||
digest_levels: 2,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user