remove flakiness (#5572)

This commit is contained in:
Nikolay Volf
2020-04-08 02:49:32 -07:00
committed by GitHub
parent 762bcbab03
commit c73398ab03
4 changed files with 21 additions and 13 deletions
@@ -30,7 +30,7 @@ use std::time::Duration;
#[cfg(not(test))]
const BACKGROUND_REVALIDATION_INTERVAL: Duration = Duration::from_millis(200);
#[cfg(test)]
pub const BACKGROUND_REVALIDATION_INTERVAL: Duration = Duration::from_millis(5);
pub const BACKGROUND_REVALIDATION_INTERVAL: Duration = Duration::from_millis(1);
const BACKGROUND_REVALIDATION_BATCH_SIZE: usize = 20;
@@ -214,12 +214,21 @@ impl<Api: ChainApi> RevalidationWorker<Api> {
loop {
futures::select! {
_ = interval.next() => {
_guard = interval.next() => {
let next_batch = this.prepare_batch();
let batch_len = next_batch.len();
batch_revalidate(this.pool.clone(), this.api.clone(), this.best_block, next_batch).await;
#[cfg(test)]
{
use intervalier::Guard;
// only trigger test events if something was processed
if batch_len == 0 {
_guard.expect("Always some() in tests").skip();
}
}
if batch_len > 0 || this.len() > 0 {
log::debug!(
target: "txpool",
@@ -221,7 +221,7 @@ fn should_revalidate_during_maintenance() {
block_on(pool.maintain(block_event(1)));
assert_eq!(pool.status().ready, 1);
block_on(notifier.next_blocking());
block_on(notifier.next());
// test that pool revalidated transaction that left ready and not included in the block
assert_eq!(pool.api.validation_requests().len(), 3);
@@ -264,8 +264,8 @@ fn should_not_retain_invalid_hashes_from_retracted() {
block_on(pool.maintain(event));
// maintenance is in background
block_on(notifier.next_blocking());
block_on(notifier.next());
assert_eq!(pool.status().ready, 0);
}
@@ -281,7 +281,6 @@ fn should_revalidate_transaction_multiple_times() {
pool.api.push_block(1, vec![xt.clone()]);
block_on(pool.maintain(block_event(1)));
block_on(notifier.next_blocking());
block_on(pool.submit_one(&BlockId::number(0), SOURCE, xt.clone())).expect("1. Imported");
assert_eq!(pool.status().ready, 1);
@@ -290,7 +289,7 @@ fn should_revalidate_transaction_multiple_times() {
pool.api.add_invalid(&xt);
block_on(pool.maintain(block_event(2)));
block_on(notifier.next_blocking());
block_on(notifier.next());
assert_eq!(pool.status().ready, 0);
}
@@ -309,14 +308,14 @@ fn should_revalidate_across_many_blocks() {
pool.api.push_block(1, vec![]);
block_on(pool.maintain(block_event(1)));
block_on(notifier.next_blocking());
block_on(notifier.next());
block_on(pool.submit_one(&BlockId::number(2), SOURCE, 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(notifier.next_blocking());
block_on(notifier.next());
assert_eq!(pool.status().ready, 2);
// xt1 and xt2 validated twice, then xt3 once, then xt2 and xt3 again
@@ -361,7 +360,7 @@ fn should_push_watchers_during_maintaince() {
// clear timer events if any
block_on(pool.maintain(block_event(0)));
block_on(notifier.next_blocking());
block_on(notifier.next());
// then
// hash3 is now invalid