Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Martin Pugh
polkadot
Commits
7b8f9ba5
Commit
7b8f9ba5
authored
Sep 10, 2020
by
Peter Goodspeed-Niklaus
Browse files
partially remove node/test-service
parent
24e2e293
Changes
9
Hide whitespace changes
Inline
Side-by-side
Cargo.lock
View file @
7b8f9ba5
...
...
@@ -5563,7 +5563,6 @@ dependencies = [
"polkadot-primitives",
"polkadot-runtime-common",
"polkadot-test-runtime",
"polkadot-test-service",
"sc-block-builder",
"sc-client-api",
"sc-consensus",
...
...
@@ -5576,53 +5575,6 @@ dependencies = [
"substrate-test-client",
]
[[package]]
name = "polkadot-test-service"
version = "0.8.2"
dependencies = [
"frame-benchmarking",
"frame-system",
"futures 0.1.29",
"futures 0.3.5",
"hex",
"log 0.4.11",
"pallet-balances",
"pallet-staking",
"pallet-transaction-payment",
"polkadot-primitives",
"polkadot-rpc",
"polkadot-runtime-common",
"polkadot-service-new",
"polkadot-test-runtime",
"rand 0.7.3",
"sc-authority-discovery",
"sc-chain-spec",
"sc-client-api",
"sc-consensus",
"sc-consensus-babe",
"sc-executor",
"sc-finality-grandpa",
"sc-informant",
"sc-network",
"sc-service",
"sc-transaction-pool",
"serde_json",
"sp-arithmetic",
"sp-blockchain",
"sp-consensus",
"sp-consensus-babe",
"sp-core",
"sp-finality-grandpa",
"sp-inherents",
"sp-keyring",
"sp-runtime",
"sp-state-machine",
"substrate-test-client",
"substrate-test-utils",
"tempfile",
"tokio 0.2.21",
]
[[package]]
name = "polkadot-validation"
version = "0.8.23"
...
...
@@ -8620,26 +8572,6 @@ dependencies = [
"sp-state-machine",
]
[[package]]
name = "substrate-test-utils"
version = "2.0.0-rc6"
source = "git+https://github.com/paritytech/substrate#e473c5bb6525f0480f415bf58ed5a03f20367d6c"
dependencies = [
"futures 0.3.5",
"substrate-test-utils-derive",
"tokio 0.2.21",
]
[[package]]
name = "substrate-test-utils-derive"
version = "0.8.0-rc6"
source = "git+https://github.com/paritytech/substrate#e473c5bb6525f0480f415bf58ed5a03f20367d6c"
dependencies = [
"proc-macro-crate",
"quote 1.0.7",
"syn 1.0.33",
]
[[package]]
name = "substrate-wasm-builder-runner"
version = "1.0.6"
...
...
@@ -8921,7 +8853,6 @@ dependencies = [
"pin-project-lite",
"signal-hook-registry",
"slab",
"tokio-macros",
"winapi 0.3.9",
]
...
...
@@ -9000,17 +8931,6 @@ dependencies = [
"log 0.4.11",
]
[[package]]
name = "tokio-macros"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389"
dependencies = [
"proc-macro2 1.0.18",
"quote 1.0.7",
"syn 1.0.33",
]
[[package]]
name = "tokio-named-pipes"
version = "0.1.0"
...
...
Cargo.toml
View file @
7b8f9ba5
...
...
@@ -58,7 +58,6 @@ members = [
"node/subsystem"
,
"node/subsystem-test-helpers"
,
"node/subsystem-util"
,
"node/test-service"
,
"parachain/test-parachains"
,
"parachain/test-parachains/adder"
,
...
...
node/service/src/lib.rs
View file @
7b8f9ba5
...
...
@@ -36,7 +36,7 @@ use sp_trie::PrefixedMemoryDB;
use
std
::
sync
::
Arc
;
use
std
::
time
::
Duration
;
pub
use
self
::
client
::{
AbstractClient
,
Client
,
RuntimeApiCollection
};
pub
use
self
::
client
::{
AbstractClient
,
Client
,
ClientHandle
,
ExecuteWithClient
,
RuntimeApiCollection
};
pub
use
chain_spec
::{
PolkadotChainSpec
,
KusamaChainSpec
,
WestendChainSpec
,
RococoChainSpec
};
#[cfg(feature
=
"full-node"
)]
pub
use
codec
::
Codec
;
...
...
@@ -121,9 +121,9 @@ fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceErro
Ok
(())
}
type
FullBackend
=
service
::
TFullBackend
<
Block
>
;
pub
type
FullBackend
=
service
::
TFullBackend
<
Block
>
;
pub
type
FullClient
<
RuntimeApi
,
Executor
>
=
service
::
TFullClient
<
Block
,
RuntimeApi
,
Executor
>
;
type
FullSelectChain
=
sc_consensus
::
LongestChain
<
FullBackend
,
Block
>
;
type
FullClient
<
RuntimeApi
,
Executor
>
=
service
::
TFullClient
<
Block
,
RuntimeApi
,
Executor
>
;
type
FullGrandpaBlockImport
<
RuntimeApi
,
Executor
>
=
grandpa
::
GrandpaBlockImport
<
FullBackend
,
Block
,
FullClient
<
RuntimeApi
,
Executor
>
,
FullSelectChain
>
;
...
...
node/test-service/Cargo.toml
deleted
100644 → 0
View file @
24e2e293
[package]
name
=
"polkadot-test-service"
version
=
"0.8.2"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
[dependencies]
futures
=
"0.3.4"
futures01
=
{
package
=
"futures"
,
version
=
"0.1.29"
}
hex
=
"0.4"
log
=
"0.4.8"
rand
=
"0.7.3"
tempfile
=
"3.1.0"
# Polkadot dependencies
polkadot-primitives
=
{
path
=
"../../primitives"
}
polkadot-rpc
=
{
path
=
"../../rpc"
}
polkadot-runtime-common
=
{
path
=
"../../runtime/common"
}
polkadot-service-new
=
{
path
=
"../service"
}
polkadot-test-runtime
=
{
path
=
"../../runtime/test-runtime"
}
# Substrate dependencies
authority-discovery
=
{
package
=
"sc-authority-discovery"
,
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
babe
=
{
package
=
"sc-consensus-babe"
,
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
babe-primitives
=
{
package
=
"sp-consensus-babe"
,
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
consensus_common
=
{
package
=
"sp-consensus"
,
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
frame-benchmarking
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
frame-system
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
grandpa
=
{
package
=
"sc-finality-grandpa"
,
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
grandpa_primitives
=
{
package
=
"sp-finality-grandpa"
,
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
inherents
=
{
package
=
"sp-inherents"
,
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
pallet-staking
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
pallet-transaction-payment
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sc-chain-spec
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sc-client-api
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sc-consensus
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sc-executor
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sc-informant
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sc-network
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sc-transaction-pool
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
service
=
{
package
=
"sc-service"
,
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
,
default-features
=
false
}
sp-arithmetic
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sp-blockchain
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sp-core
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sp-keyring
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sp-runtime
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
sp-state-machine
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
substrate-test-client
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
[dev-dependencies]
pallet-balances
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
,
default-features
=
false
}
serde_json
=
"1.0"
substrate-test-utils
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
}
tokio
=
{
version
=
"0.2"
,
features
=
["macros"]
}
node/test-service/src/chain_spec.rs
deleted
100644 → 0
View file @
24e2e293
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot 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.
// Polkadot 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 Polkadot. If not, see <http://www.gnu.org/licenses/>.
use
babe_primitives
::
AuthorityId
as
BabeId
;
use
grandpa
::
AuthorityId
as
GrandpaId
;
use
pallet_staking
::
Forcing
;
use
polkadot_primitives
::
v0
::{
ValidatorId
,
AccountId
};
use
polkadot_service_new
::
chain_spec
::{
get_account_id_from_seed
,
get_from_seed
,
Extensions
};
use
polkadot_test_runtime
::
constants
::
currency
::
DOTS
;
use
sc_chain_spec
::{
ChainSpec
,
ChainType
};
use
sp_core
::{
sr25519
,
ChangesTrieConfiguration
};
use
sp_runtime
::
Perbill
;
const
DEFAULT_PROTOCOL_ID
:
&
str
=
"dot"
;
/// The `ChainSpec parametrised for polkadot runtime`.
pub
type
PolkadotChainSpec
=
service
::
GenericChainSpec
<
polkadot_test_runtime
::
GenesisConfig
,
Extensions
>
;
/// Polkadot local testnet config (multivalidator Alice + Bob)
pub
fn
polkadot_local_testnet_config
()
->
PolkadotChainSpec
{
PolkadotChainSpec
::
from_genesis
(
"Local Testnet"
,
"local_testnet"
,
ChainType
::
Local
,
||
polkadot_local_testnet_genesis
(
None
),
vec!
[],
None
,
Some
(
DEFAULT_PROTOCOL_ID
),
None
,
Default
::
default
(),
)
}
/// Polkadot local testnet genesis config (multivalidator Alice + Bob)
pub
fn
polkadot_local_testnet_genesis
(
changes_trie_config
:
Option
<
ChangesTrieConfiguration
>
,
)
->
polkadot_test_runtime
::
GenesisConfig
{
polkadot_testnet_genesis
(
vec!
[
get_authority_keys_from_seed
(
"Alice"
),
get_authority_keys_from_seed
(
"Bob"
),
get_authority_keys_from_seed
(
"Charlie"
),
],
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Alice"
),
None
,
changes_trie_config
,
)
}
/// Helper function to generate stash, controller and session key from seed
fn
get_authority_keys_from_seed
(
seed
:
&
str
,
)
->
(
AccountId
,
AccountId
,
BabeId
,
GrandpaId
,
ValidatorId
)
{
(
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
&
format!
(
"{}//stash"
,
seed
)),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
seed
),
get_from_seed
::
<
BabeId
>
(
seed
),
get_from_seed
::
<
GrandpaId
>
(
seed
),
get_from_seed
::
<
ValidatorId
>
(
seed
),
)
}
fn
testnet_accounts
()
->
Vec
<
AccountId
>
{
vec!
[
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Alice"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Bob"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Charlie"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Dave"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Eve"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Ferdie"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Alice//stash"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Bob//stash"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Charlie//stash"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Dave//stash"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Eve//stash"
),
get_account_id_from_seed
::
<
sr25519
::
Public
>
(
"Ferdie//stash"
),
]
}
/// Helper function to create polkadot GenesisConfig for testing
fn
polkadot_testnet_genesis
(
initial_authorities
:
Vec
<
(
AccountId
,
AccountId
,
BabeId
,
GrandpaId
,
ValidatorId
)
>
,
root_key
:
AccountId
,
endowed_accounts
:
Option
<
Vec
<
AccountId
>>
,
changes_trie_config
:
Option
<
ChangesTrieConfiguration
>
,
)
->
polkadot_test_runtime
::
GenesisConfig
{
use
polkadot_test_runtime
as
polkadot
;
let
endowed_accounts
:
Vec
<
AccountId
>
=
endowed_accounts
.unwrap_or_else
(
testnet_accounts
);
const
ENDOWMENT
:
u128
=
1_000_000
*
DOTS
;
const
STASH
:
u128
=
100
*
DOTS
;
polkadot
::
GenesisConfig
{
frame_system
:
Some
(
polkadot
::
SystemConfig
{
code
:
polkadot
::
WASM_BINARY
.expect
(
"Wasm binary must be built for testing"
)
.to_vec
(),
changes_trie_config
,
}),
pallet_indices
:
Some
(
polkadot
::
IndicesConfig
{
indices
:
vec!
[]
}),
pallet_balances
:
Some
(
polkadot
::
BalancesConfig
{
balances
:
endowed_accounts
.iter
()
.map
(|
k
|
(
k
.clone
(),
ENDOWMENT
))
.collect
(),
}),
pallet_session
:
Some
(
polkadot
::
SessionConfig
{
keys
:
initial_authorities
.iter
()
.map
(|
x
|
{
(
x
.0
.clone
(),
x
.0
.clone
(),
polkadot_test_runtime
::
SessionKeys
{
babe
:
x
.2
.clone
(),
grandpa
:
x
.3
.clone
(),
parachain_validator
:
x
.4
.clone
(),
},
)
})
.collect
::
<
Vec
<
_
>>
(),
}),
pallet_staking
:
Some
(
polkadot
::
StakingConfig
{
minimum_validator_count
:
1
,
validator_count
:
2
,
stakers
:
initial_authorities
.iter
()
.map
(|
x
|
{
(
x
.0
.clone
(),
x
.1
.clone
(),
STASH
,
polkadot
::
StakerStatus
::
Validator
,
)
})
.collect
(),
invulnerables
:
initial_authorities
.iter
()
.map
(|
x
|
x
.0
.clone
())
.collect
(),
force_era
:
Forcing
::
NotForcing
,
slash_reward_fraction
:
Perbill
::
from_percent
(
10
),
..
Default
::
default
()
}),
pallet_babe
:
Some
(
Default
::
default
()),
pallet_grandpa
:
Some
(
Default
::
default
()),
pallet_authority_discovery
:
Some
(
polkadot
::
AuthorityDiscoveryConfig
{
keys
:
vec!
[]
}),
claims
:
Some
(
polkadot
::
ClaimsConfig
{
claims
:
vec!
[],
vesting
:
vec!
[],
}),
pallet_vesting
:
Some
(
polkadot
::
VestingConfig
{
vesting
:
vec!
[]
}),
pallet_sudo
:
Some
(
polkadot
::
SudoConfig
{
key
:
root_key
}),
}
}
/// Can be called for a `Configuration` to check if it is a configuration for the `Test` network.
pub
trait
IdentifyVariant
{
/// Returns if this is a configuration for the `Test` network.
fn
is_test
(
&
self
)
->
bool
;
}
impl
IdentifyVariant
for
Box
<
dyn
ChainSpec
>
{
fn
is_test
(
&
self
)
->
bool
{
self
.id
()
.starts_with
(
"test"
)
}
}
node/test-service/src/lib.rs
deleted
100644 → 0
View file @
24e2e293
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot 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.
// Polkadot 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 Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Polkadot test service only.
#![warn(missing_docs)]
mod
chain_spec
;
pub
use
chain_spec
::
*
;
use
futures
::
future
::
Future
;
use
polkadot_primitives
::
v0
::{
Block
,
Hash
,
CollatorId
,
Id
as
ParaId
,
};
use
polkadot_runtime_common
::
BlockHashCount
;
use
polkadot_service_new
::{
new_full
,
FullNodeHandles
,
AbstractClient
,
ClientHandle
,
ExecuteWithClient
,
};
use
polkadot_test_runtime
::{
Runtime
,
SignedExtra
,
SignedPayload
,
VERSION
};
use
sc_chain_spec
::
ChainSpec
;
use
sc_client_api
::{
execution_extensions
::
ExecutionStrategies
,
BlockchainEvents
};
use
sc_executor
::
native_executor_instance
;
use
sc_informant
::
OutputFormat
;
use
sc_network
::{
config
::{
NetworkConfiguration
,
TransportConfig
},
multiaddr
,
NetworkService
,
};
use
service
::{
config
::{
DatabaseConfig
,
KeystoreConfig
,
MultiaddrWithPeerId
,
WasmExecutionMethod
},
error
::
Error
as
ServiceError
,
RpcHandlers
,
TaskExecutor
,
TaskManager
,
};
use
service
::{
BasePath
,
Configuration
,
Role
,
TFullBackend
};
use
sp_arithmetic
::
traits
::
SaturatedConversion
;
use
sp_blockchain
::
HeaderBackend
;
use
sp_keyring
::
Sr25519Keyring
;
use
sp_runtime
::{
codec
::
Encode
,
generic
};
use
sp_state_machine
::
BasicExternalities
;
use
std
::
sync
::
Arc
;
use
substrate_test_client
::{
BlockchainEventsExt
,
RpcHandlersExt
,
RpcTransactionOutput
,
RpcTransactionError
};
native_executor_instance!
(
pub
PolkadotTestExecutor
,
polkadot_test_runtime
::
api
::
dispatch
,
polkadot_test_runtime
::
native_version
,
frame_benchmarking
::
benchmarking
::
HostFunctions
,
);
/// Create a new Polkadot test service for a full node.
pub
fn
polkadot_test_new_full
(
config
:
Configuration
,
collating_for
:
Option
<
(
CollatorId
,
ParaId
)
>
,
authority_discovery_enabled
:
bool
,
)
->
Result
<
(
TaskManager
,
Arc
<
polkadot_service
::
FullClient
<
polkadot_test_runtime
::
RuntimeApi
,
PolkadotTestExecutor
>>
,
FullNodeHandles
,
Arc
<
NetworkService
<
Block
,
Hash
>>
,
RpcHandlers
,
),
ServiceError
,
>
{
let
(
task_manager
,
client
,
handles
,
network
,
rpc_handlers
)
=
new_full
::
<
polkadot_test_runtime
::
RuntimeApi
,
PolkadotTestExecutor
>
(
config
,
collating_for
,
authority_discovery_enabled
,
None
,
true
,
)
?
;
Ok
((
task_manager
,
client
,
handles
,
network
,
rpc_handlers
))
}
/// A wrapper for the test client that implements `ClientHandle`.
pub
struct
TestClient
(
pub
Arc
<
polkadot_service
::
FullClient
<
polkadot_test_runtime
::
RuntimeApi
,
PolkadotTestExecutor
>>
);
impl
ClientHandle
for
TestClient
{
fn
execute_with
<
T
:
ExecuteWithClient
>
(
&
self
,
t
:
T
)
->
T
::
Output
{
T
::
execute_with_client
::
<
_
,
_
,
polkadot_service
::
FullBackend
>
(
t
,
self
.0
.clone
())
}
}
/// Create a Polkadot `Configuration`. By default an in-memory socket will be used, therefore you need to provide boot
/// nodes if you want the future node to be connected to other nodes. The `storage_update_func` can be used to make
/// adjustements to the runtime before the node starts.
pub
fn
node_config
(
storage_update_func
:
impl
Fn
(),
task_executor
:
TaskExecutor
,
key
:
Sr25519Keyring
,
boot_nodes
:
Vec
<
MultiaddrWithPeerId
>
,
)
->
Configuration
{
let
base_path
=
BasePath
::
new_temp_dir
()
.expect
(
"could not create temporary directory"
);
let
root
=
base_path
.path
();
let
role
=
Role
::
Authority
{
sentry_nodes
:
Vec
::
new
(),
};
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"
);
BasicExternalities
::
execute_with_storage
(
&
mut
storage
,
storage_update_func
);
spec
.set_storage
(
storage
);
let
mut
network_config
=
NetworkConfiguration
::
new
(
format!
(
"Polkadot Test Node for: {}"
,
key_seed
),
"network/test/0.1"
,
Default
::
default
(),
None
,
);
let
informant_output_format
=
OutputFormat
{
enable_color
:
false
,
prefix
:
format!
(
"[{}] "
,
key_seed
),
};
network_config
.boot_nodes
=
boot_nodes
;
network_config
.allow_non_globals_in_dht
=
true
;
network_config
.listen_addresses
.push
(
multiaddr
::
Protocol
::
Memory
(
rand
::
random
())
.into
());
network_config
.transport
=
TransportConfig
::
MemoryOnly
;
Configuration
{
impl_name
:
"polkadot-test-node"
.to_string
(),
impl_version
:
"0.1"
.to_string
(),
role
,
task_executor
,
transaction_pool
:
Default
::
default
(),
network
:
network_config
,
keystore
:
KeystoreConfig
::
Path
{
path
:
root
.join
(
"key"
),
password
:
None
,
},
database
:
DatabaseConfig
::
RocksDb
{
path
:
root
.join
(
"db"
),
cache_size
:
128
,
},
state_cache_size
:
16777216
,
state_cache_child_ratio
:
None
,
pruning
:
Default
::
default
(),
chain_spec
:
Box
::
new
(
spec
),
wasm_method
:
WasmExecutionMethod
::
Interpreted
,
// NOTE: we enforce the use of the native runtime to make the errors more debuggable
execution_strategies
:
ExecutionStrategies
{
syncing
:
sc_client_api
::
ExecutionStrategy
::
NativeWhenPossible
,
importing
:
sc_client_api
::
ExecutionStrategy
::
NativeWhenPossible
,
block_construction
:
sc_client_api
::
ExecutionStrategy
::
NativeWhenPossible
,
offchain_worker
:
sc_client_api
::
ExecutionStrategy
::
NativeWhenPossible
,
other
:
sc_client_api
::
ExecutionStrategy
::
NativeWhenPossible
,
},
rpc_http
:
None
,
rpc_ws
:
None
,
rpc_ipc
:
None
,
rpc_ws_max_connections
:
None
,
rpc_cors
:
None
,
rpc_methods
:
Default
::
default
(),
prometheus_config
:
None
,
telemetry_endpoints
:
None
,
telemetry_external_transport
:
None
,
default_heap_pages
:
None
,
offchain_worker
:
Default
::
default
(),
force_authoring
:
false
,
disable_grandpa
:
false
,
dev_key_seed
:
Some
(
key_seed
),
tracing_targets
:
None
,
tracing_receiver
:
Default
::
default
(),
max_runtime_instances
:
8
,
announce_block
:
true
,
base_path
:
Some
(
base_path
),
informant_output_format
,
}
}
/// Run a Polkadot test node using the Polkadot test runtime. The node will be using an in-memory socket, therefore you
/// need to provide boot nodes if you want it to be connected to other nodes. The `storage_update_func` can be used to
/// make adjustements to the runtime before the node starts.
pub
fn
run_test_node
(
task_executor
:
TaskExecutor
,
key
:
Sr25519Keyring
,
storage_update_func
:
impl
Fn
(),
boot_nodes
:
Vec
<
MultiaddrWithPeerId
>
,
)
->
PolkadotTestNode
<
TaskManager
,
impl
AbstractClient
<
Block
,
TFullBackend
<
Block
>>
,
>
{
let
config
=
node_config
(
storage_update_func
,
task_executor
,
key
,
boot_nodes
);
let
multiaddr
=
config
.network.listen_addresses
[
0
]
.clone
();
let
authority_discovery_enabled
=
false
;
let
(
task_manager
,
client
,
handles
,
network
,
rpc_handlers
)
=
polkadot_test_new_full
(
config
,
None
,
authority_discovery_enabled
)
.expect
(
"could not create Polkadot test service"
);
let
peer_id
=
network
.local_peer_id
()
.clone
();
let
addr
=
MultiaddrWithPeerId
{
multiaddr
,
peer_id
};
PolkadotTestNode
{
task_manager
,
client
,
handles
,
addr
,
rpc_handlers
,
}
}
/// A Polkadot test node instance used for testing.
pub
struct
PolkadotTestNode
<
S
,
C
>
{
/// TaskManager's instance.
pub
task_manager
:
S
,
/// Client's instance.
pub
client
:
Arc
<
C
>
,
/// Node's handles.
pub
handles
:
FullNodeHandles
,
/// The `MultiaddrWithPeerId` to this node. This is useful if you want to pass it as "boot node" to other nodes.
pub
addr
:
MultiaddrWithPeerId
,
/// RPCHandlers to make RPC queries.
pub
rpc_handlers
:
RpcHandlers
,