Fix possible corner case in revalidation (#5172)

* remove all from members

* add test
This commit is contained in:
Nikolay Volf
2020-03-06 23:24:39 +03:00
committed by GitHub
parent 615dc00702
commit 4aac39c667
2 changed files with 34 additions and 1 deletions
@@ -295,6 +295,36 @@ fn should_revalidate_transaction_multiple_times() {
assert_eq!(pool.status().ready, 0);
}
#[test]
fn should_revalidate_across_many_blocks() {
let xt1 = uxt(Alice, 209);
let xt2 = uxt(Alice, 210);
let xt3 = uxt(Alice, 211);
let (pool, _guard) = maintained_pool();
block_on(pool.submit_one(&BlockId::number(1), xt1.clone())).expect("1. Imported");
block_on(pool.submit_one(&BlockId::number(1), xt2.clone())).expect("1. Imported");
assert_eq!(pool.status().ready, 2);
pool.api.push_block(1, vec![]);
block_on(pool.maintain(block_event(1)));
block_on(futures_timer::Delay::new(BACKGROUND_REVALIDATION_INTERVAL*2));
block_on(pool.submit_one(&BlockId::number(2), xt3.clone())).expect("1. Imported");
assert_eq!(pool.status().ready, 3);
pool.api.push_block(2, vec![xt1.clone()]);
block_on(pool.maintain(block_event(2)));
block_on(futures_timer::Delay::new(BACKGROUND_REVALIDATION_INTERVAL*2));
assert_eq!(pool.status().ready, 2);
// xt1 and xt2 validated twice, then xt3 once, then xt2 and xt3 again
assert_eq!(pool.api.validation_requests().len(), 7);
}
#[test]
fn should_push_watchers_during_maintaince() {
fn alice_uxt(nonce: u64) -> Extrinsic {