forked from nervosnetwork/ckb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nervosnetwork#20 from contrun/sync-after-restart: …
…Add integration test to check correctly sync after restart Add integration test to check correctly sync after restart
- Loading branch information
Showing
9 changed files
with
217 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod randomly_kill; | ||
|
||
pub use randomly_kill::*; |
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,31 @@ | ||
use crate::{Node, Spec}; | ||
|
||
use ckb_logger::info; | ||
use rand::{thread_rng, Rng}; | ||
|
||
pub struct RandomlyKill; | ||
|
||
impl Spec for RandomlyKill { | ||
crate::setup!(num_nodes: 1); | ||
|
||
fn run(&self, nodes: &mut Vec<Node>) { | ||
let mut rng = thread_rng(); | ||
let node = &mut nodes[0]; | ||
for _ in 0..rng.gen_range(10, 20) { | ||
let n = rng.gen_range(0, 10); | ||
// TODO: the kill of child process and mining are actually sequential here | ||
// We need to find some way to so these two things in parallel. | ||
// It would be great if we can kill and start the node externally (instead of writing | ||
// rust code to manage all the nodes, because in that case we will have to fight | ||
// ownership rules, and monitor node). | ||
if n != 0 { | ||
info!("Mining {} blocks", n); | ||
node.mine(n); | ||
} | ||
info!("Stop the node"); | ||
node.stop(); | ||
info!("Start the node"); | ||
node.start(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.