Skip to content

Commit

Permalink
Make test more stable (paritytech#653)
Browse files Browse the repository at this point in the history
Signed-off-by: koushiro <[email protected]>
  • Loading branch information
koushiro authored May 9, 2022
1 parent 142058c commit 9f62ebb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions client/rpc/src/eth/cache/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ mod tests {
executor::block_on(client.import(BlockOrigin::Own, a2)).unwrap();

// Give some time to consume and process the import notification stream.
thread::sleep(time::Duration::from_millis(1));
thread::sleep(time::Duration::from_millis(100));

// Expect: genesis with schema V1, A2 with schema V2.
assert_eq!(
Expand Down Expand Up @@ -203,7 +203,7 @@ mod tests {
executor::block_on(client.import(BlockOrigin::Own, b3)).unwrap();

// Give some time to consume and process the import notification stream.
thread::sleep(time::Duration::from_millis(1));
thread::sleep(time::Duration::from_millis(100));

// Expect: A2 to be retracted, genesis with schema V1, B3 with schema V2.
assert_eq!(
Expand All @@ -230,7 +230,7 @@ mod tests {
executor::block_on(client.import(BlockOrigin::Own, c2)).unwrap();

// Give some time to consume and process the import notification stream.
thread::sleep(time::Duration::from_millis(1));
thread::sleep(time::Duration::from_millis(100));

// Expect: genesis with schema V1, B3 still with schema V2.
// C2 still not best block and not cached.
Expand All @@ -243,28 +243,28 @@ mod tests {
);

// Make C2 branch the longest chain.
// C2 -> D2
// C2 -> C3
let mut builder = client
.new_block_at(&BlockId::Hash(c2_hash), Default::default(), false)
.unwrap();
builder.push_storage_change(vec![2], None).unwrap();
let d2 = builder.build().unwrap().block;
let d2_hash = d2.header.hash();
executor::block_on(client.import(BlockOrigin::Own, d2)).unwrap();
let c3 = builder.build().unwrap().block;
let c3_hash = c3.header.hash();
executor::block_on(client.import(BlockOrigin::Own, c3)).unwrap();

// D2 -> E2
// C3 -> C4
let mut builder = client
.new_block_at(&BlockId::Hash(d2_hash), Default::default(), false)
.new_block_at(&BlockId::Hash(c3_hash), Default::default(), false)
.unwrap();
builder.push_storage_change(vec![3], None).unwrap();
let e2 = builder.build().unwrap().block;
executor::block_on(client.import(BlockOrigin::Own, e2)).unwrap();
let c4 = builder.build().unwrap().block;
executor::block_on(client.import(BlockOrigin::Own, c4)).unwrap();

// Give some time to consume and process the import notification stream.
thread::sleep(time::Duration::from_millis(1));
thread::sleep(time::Duration::from_millis(100));

// Expect: B2 branch to be retracted, genesis with schema V1, C2 with schema V2.
// E2 became new best, chain reorged, we expect the C2 ancestor to be cached.
// C4 became new best, chain reorged, we expect the C2 ancestor to be cached.
assert_eq!(
frontier_backend_client::load_cached_schema::<_>(frontier_backend.as_ref()),
Ok(Some(vec![
Expand Down

0 comments on commit 9f62ebb

Please sign in to comment.