-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd0cfbe
commit b08323a
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use ant_evm::EvmTestnet; | ||
use ant_node::spawn::network::NetworkSpawner; | ||
use std::time::Duration; | ||
use tokio::time::sleep; | ||
use tracing_subscriber::layer::SubscriberExt; | ||
use tracing_subscriber::util::SubscriberInitExt; | ||
use tracing_subscriber::{fmt, EnvFilter}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
tracing_subscriber::registry() | ||
.with(fmt::layer()) | ||
.with(EnvFilter::from_env("RUST_LOG")) | ||
.init(); | ||
|
||
// start local Ethereum node | ||
let evm_testnet = EvmTestnet::new().await; | ||
let evm_network = evm_testnet.to_network(); | ||
let network_size = 2; | ||
|
||
let running_network = NetworkSpawner::new() | ||
.with_evm_network(evm_network) | ||
.with_local(true) | ||
.with_size(network_size) | ||
.spawn() | ||
.await | ||
.unwrap(); | ||
|
||
assert_eq!(running_network.running_nodes().len(), network_size); | ||
|
||
// Validate each node's listen addresses are not empty | ||
for node in running_network.running_nodes() { | ||
let listen_addrs = node.get_listen_addrs().await.unwrap(); | ||
|
||
assert!(!listen_addrs.is_empty()); | ||
} | ||
|
||
// Wait for nodes to dial each other | ||
sleep(Duration::from_secs(20)).await; | ||
|
||
// TODO: Validate that all nodes know each other | ||
Check notice Code scanning / devskim A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
Suspicious comment
|
||
for node in running_network.running_nodes() { | ||
let known_peers = node.get_swarm_local_state().await.unwrap().connected_peers; | ||
|
||
println!("Known peers: {known_peers:?}"); | ||
|
||
// TODO: nodes do not know each other.. | ||
Check notice Code scanning / devskim A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
Suspicious comment
|
||
} | ||
|
||
running_network.shutdown(); | ||
} |