mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 12:09:37 +00:00
b493e3e31f
* Route validators for any active set through sc-authority-discovery Additionally adds an RPC route to retrieve their P2P addresses. * Have the coordinator get peers from substrate * Have the RPC return one address, not up to 3 Prevents the coordinator from believing it has 3 peers when it has one. * Add missing feature to serai-client * Correct network argument in serai-client for p2p_validators call * Add a test in serai-client to check DHT population with a much quicker failure than the coordinator tests * Update to latest Substrate Removes distinguishing BABE/AuthorityDiscovery keys which causes sc_authority_discovery to populate as desired. * Update to a properly tagged substrate commit * Add all dialed to peers to GossipSub * cargo fmt * Reduce common code in serai-coordinator-tests with amore involved new_test * Use a recursive async function to spawn `n` DockerTests with the necessary networking configuration * Merge UNIQUE_ID and ONE_AT_A_TIME * Tidy up the new recursive code in tests/coordinator * Use a Mutex in CONTEXT to let it be set multiple times * Make complimentary edits to full-stack tests * Augment coordinator P2p connection logs * Drop lock acquisitions before recursing * Better scope lock acquisitions in full-stack, preventing a deadlock * Ensure OUTER_OPS is reset across the test boundary * Add cargo deny allowance for dockertest fork
59 lines
1.8 KiB
Rust
59 lines
1.8 KiB
Rust
use serai_client::{primitives::NetworkId, Serai};
|
|
|
|
#[tokio::test]
|
|
async fn dht() {
|
|
use dockertest::{
|
|
PullPolicy, StartPolicy, LogOptions, LogAction, LogPolicy, LogSource, Image,
|
|
TestBodySpecification, DockerTest,
|
|
};
|
|
|
|
serai_docker_tests::build("serai".to_string());
|
|
|
|
let handle = |name| format!("serai_client-serai_node-{name}");
|
|
let composition = |name| {
|
|
TestBodySpecification::with_image(
|
|
Image::with_repository("serai-dev-serai").pull_policy(PullPolicy::Never),
|
|
)
|
|
.replace_cmd(vec![
|
|
"serai-node".to_string(),
|
|
"--unsafe-rpc-external".to_string(),
|
|
"--rpc-cors".to_string(),
|
|
"all".to_string(),
|
|
"--chain".to_string(),
|
|
"local".to_string(),
|
|
format!("--{name}"),
|
|
])
|
|
.set_publish_all_ports(true)
|
|
.set_handle(handle(name))
|
|
.set_start_policy(StartPolicy::Strict)
|
|
.set_log_options(Some(LogOptions {
|
|
action: LogAction::Forward,
|
|
policy: LogPolicy::Always,
|
|
source: LogSource::Both,
|
|
}))
|
|
};
|
|
|
|
let mut test = DockerTest::new().with_network(dockertest::Network::Isolated);
|
|
test.provide_container(composition("alice"));
|
|
test.provide_container(composition("bob"));
|
|
test.provide_container(composition("charlie"));
|
|
test.provide_container(composition("dave"));
|
|
test
|
|
.run_async(|ops| async move {
|
|
// Sleep until the Substrate RPC starts
|
|
let alice = handle("alice");
|
|
let serai_rpc = ops.handle(&alice).host_port(9944).unwrap();
|
|
let serai_rpc = format!("http://{}:{}", serai_rpc.0, serai_rpc.1);
|
|
// Sleep for a minute
|
|
tokio::time::sleep(core::time::Duration::from_secs(60)).await;
|
|
// Check the DHT has been populated
|
|
assert!(!Serai::new(serai_rpc.clone())
|
|
.await
|
|
.unwrap()
|
|
.p2p_validators(NetworkId::Bitcoin)
|
|
.await
|
|
.unwrap()
|
|
.is_empty());
|
|
})
|
|
.await;
|
|
}
|