-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
357: test: add more integration test for new p2p lib r=quake a=quake - [x] add network related rpc - [x] test discovery - [x] test disconnection Co-authored-by: quake wang <[email protected]>
- Loading branch information
Showing
16 changed files
with
173 additions
and
34 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
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
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
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
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
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
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
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
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
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
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
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,49 @@ | ||
use crate::{sleep, Net, Spec}; | ||
use log::info; | ||
|
||
pub struct Discovery; | ||
|
||
impl Spec for Discovery { | ||
fn run(&self, net: Net) { | ||
info!("Running Discovery"); | ||
let node0_id = &net.nodes[0].node_id.clone().unwrap(); | ||
let node2 = &net.nodes[2]; | ||
|
||
info!("Waiting for discovering"); | ||
sleep(5); | ||
|
||
info!("The address of node0 should be discovered by node2 and connected"); | ||
let peers = node2 | ||
.rpc_client() | ||
.get_peers() | ||
.call() | ||
.expect("rpc call get_peers failed"); | ||
assert!(peers.iter().any(|peer| &peer.node_id == node0_id)); | ||
} | ||
} | ||
|
||
pub struct Disconnect; | ||
|
||
impl Spec for Disconnect { | ||
fn run(&self, mut net: Net) { | ||
info!("Running Disconnect"); | ||
|
||
info!("Disconnect node1"); | ||
let node1 = net.nodes.pop().unwrap(); | ||
std::mem::drop(node1); | ||
sleep(3); | ||
|
||
info!("The address of node1 should be removed from node0's peers"); | ||
let peers = net.nodes[0] | ||
.rpc_client() | ||
.get_peers() | ||
.call() | ||
.expect("rpc call get_peers failed"); | ||
|
||
assert!(peers.is_empty()); | ||
} | ||
|
||
fn num_nodes(&self) -> usize { | ||
2 | ||
} | ||
} |
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
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
Oops, something went wrong.