From d50065a16f29901281d41e59ab03e4bd0ede4365 Mon Sep 17 00:00:00 2001 From: Seebs Date: Thu, 20 Jan 2022 14:50:45 -0600 Subject: [PATCH] bump timeouts on single-writer RBF Tx test There's no correct timeout value here, really, but the intent of this is that we first want to be sure that a second tx doesn't successfully start before the first exits, and then that the second *does* successfully start *after* the first exits. Unfortunately, there's no guarantees on timely processing, and in reality, CI can break us by waiting more than 10ms before we get enough CPU time to do something. More generally, there's no way to make a test like this work correctly -- no matter how long you wait for the second Tx to start before closing the first one, it's always possible that it *would* have started just a millisecond later even without you closing the first one. And similarly, no matter how long you give it to start when it's *supposed* to, it could always take longer. We could in principle just set this to wait for the second Tx to start and rely on the test timeout killing us if it doesn't, but then we don't get a useful message. Let's optimistically hope that 10 seconds is long enough for a trivial rollback to happen, since that doesn't need to imply writes. And I think 50ms is a better bet for the first test, although that does make this test close to 5x slower on non-CI hardware. --- rbf/tx_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rbf/tx_test.go b/rbf/tx_test.go index 14626ce00..6f98a0fb0 100644 --- a/rbf/tx_test.go +++ b/rbf/tx_test.go @@ -140,14 +140,14 @@ func TestTx_CommitRollback(t *testing.T) { select { case <-ch1: t.Fatal("second tx started while first tx active") - case <-time.After(10 * time.Millisecond): + case <-time.After(50 * time.Millisecond): } // Finish first transaction. close(ch0) select { case <-ch1: - case <-time.After(10 * time.Millisecond): + case <-time.After(10 * time.Second): t.Fatal("second tx should have started after first tx closed") } })