@@ -46,7 +46,7 @@ import (
4646// Default to a large interval so the planter never actually ticks and only
4747// rely on our manual ticks.
4848var (
49- defaultTimeout = time .Second * 5
49+ defaultTimeout = time .Second * 10
5050 noCaretakerStates = fn .NewSet (
5151 tapgarden .BatchStatePending ,
5252 tapgarden .BatchStateSeedlingCancelled ,
@@ -309,7 +309,18 @@ func (t *mintingTestHarness) queueSeedlingsInBatch(isFunded bool,
309309 // The received update should be a state of MintingStateSeed.
310310 require .Equal (t , tapgarden .MintingStateSeed , update .NewState )
311311
312- t .keyRing .AssertNumberOfCalls (t , "DeriveNextKey" , keyCount )
312+ require .Eventually (t , func () bool {
313+ // Assert that the key ring method DeriveNextKey was
314+ // called the expected number of times.
315+ count := 0
316+ for _ , call := range t .keyRing .Calls {
317+ if call .Method == "DeriveNextKey" {
318+ count ++
319+ }
320+ }
321+
322+ return count == keyCount
323+ }, defaultTimeout , wait .PollInterval )
313324 }
314325}
315326
@@ -318,10 +329,15 @@ func (t *mintingTestHarness) queueSeedlingsInBatch(isFunded bool,
318329func (t * mintingTestHarness ) assertPendingBatchExists (numSeedlings int ) {
319330 t .Helper ()
320331
321- batch , err := t .planter .PendingBatch ()
322- require .NoError (t , err )
323- require .NotNil (t , batch )
324- require .Len (t , batch .Seedlings , numSeedlings )
332+ // The planter is a state machine, so we need to wait until it has
333+ // reached the expected state.
334+ require .Eventually (t , func () bool {
335+ batch , err := t .planter .PendingBatch ()
336+ require .NoError (t , err )
337+
338+ require .NotNil (t , batch )
339+ return len (batch .Seedlings ) == numSeedlings
340+ }, defaultTimeout , wait .PollInterval )
325341}
326342
327343// assertNoActiveBatch asserts that no pending batch exists.
0 commit comments