@@ -46,7 +46,7 @@ import (
46
46
// Default to a large interval so the planter never actually ticks and only
47
47
// rely on our manual ticks.
48
48
var (
49
- defaultTimeout = time .Second * 5
49
+ defaultTimeout = time .Second * 10
50
50
noCaretakerStates = fn .NewSet (
51
51
tapgarden .BatchStatePending ,
52
52
tapgarden .BatchStateSeedlingCancelled ,
@@ -309,7 +309,18 @@ func (t *mintingTestHarness) queueSeedlingsInBatch(isFunded bool,
309
309
// The received update should be a state of MintingStateSeed.
310
310
require .Equal (t , tapgarden .MintingStateSeed , update .NewState )
311
311
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 )
313
324
}
314
325
}
315
326
@@ -318,10 +329,15 @@ func (t *mintingTestHarness) queueSeedlingsInBatch(isFunded bool,
318
329
func (t * mintingTestHarness ) assertPendingBatchExists (numSeedlings int ) {
319
330
t .Helper ()
320
331
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 )
325
341
}
326
342
327
343
// assertNoActiveBatch asserts that no pending batch exists.
0 commit comments