@@ -331,11 +331,15 @@ func (t *mintingTestHarness) queueSeedlingsInBatch(isFunded bool,
331331
332332// assertPendingBatchExists asserts that a pending batch is found and it has
333333// numSeedlings assets registered.
334- func (t * mintingTestHarness ) assertPendingBatchExists (numSeedlings int ) {
335- t . Helper ()
334+ func (t * mintingTestHarness ) assertPendingBatchExists (
335+ expectedSeedlings [] * tapgarden. Seedling ) {
336336
337337 // The planter is a state machine, so we need to wait until it has
338338 // reached the expected state.
339+ var (
340+ numExpectedSeedlings = len (expectedSeedlings )
341+ lastActualSeedlings map [string ]* tapgarden.Seedling
342+ )
339343 err := wait .NoError (func () error {
340344 batch , err := t .planter .PendingBatch ()
341345 if err != nil {
@@ -348,14 +352,43 @@ func (t *mintingTestHarness) assertPendingBatchExists(numSeedlings int) {
348352 "non-nil" )
349353 }
350354
351- if len (batch .Seedlings ) < numSeedlings {
355+ lastActualSeedlings = batch .Seedlings
356+
357+ if len (batch .Seedlings ) < numExpectedSeedlings {
352358 return fmt .Errorf ("expected %d seedlings, got %d" ,
353- numSeedlings , len (batch .Seedlings ))
359+ numExpectedSeedlings , len (batch .Seedlings ))
354360 }
355361
356362 return nil
357363 }, defaultTimeout )
358- require .NoError (t , err )
364+ if err != nil {
365+ // Report any missing seedlings.
366+ spewCfg := spew.ConfigState {
367+ // Disable .String() and other methods.
368+ DisableMethods : true ,
369+ Indent : " " ,
370+ }
371+
372+ for idx := range expectedSeedlings {
373+ expectedSeedling := expectedSeedlings [idx ]
374+ if lastActualSeedlings == nil {
375+ t .Logf ("Missing expected seedling: %s" ,
376+ spewCfg .Sdump (expectedSeedling ))
377+ continue
378+ }
379+
380+ _ , ok := lastActualSeedlings [expectedSeedling .AssetName ]
381+ if ! ok {
382+ t .Logf ("Missing expected seedling: %s" ,
383+ spewCfg .Sdump (expectedSeedling ))
384+ }
385+ }
386+
387+ t .Fatalf ("Batch seedling mismatch: \n actual seedlings: %s\n " +
388+ "expected seedlings: %s\n error: %v" ,
389+ spew .Sdump (lastActualSeedlings ),
390+ spew .Sdump (expectedSeedlings ), err )
391+ }
359392}
360393
361394// assertNoActiveBatch asserts that no pending batch exists.
@@ -1089,7 +1122,7 @@ func (t *mintingTestHarness) queueInitialBatch(
10891122
10901123 // At this point, there should be a single pending batch with 5
10911124 // seedlings. The batch stored in the log should also match up exactly.
1092- t .assertPendingBatchExists (numSeedlings )
1125+ t .assertPendingBatchExists (seedlings )
10931126
10941127 // Before we tick the batch, we record all existing batches, so we can
10951128 // make sure a new one was created.
@@ -1303,10 +1336,9 @@ func testMintingCancelFinalize(t *mintingTestHarness) {
13031336 // harness.
13041337 t .refreshChainPlanter ()
13051338
1306- // Create an initial batch of 5 seedlings.
1307- const numSeedlings = 5
1339+ // Create an initial set of seedlings.
1340+ const numSeedlings = 4
13081341 seedlings := t .queueInitialBatch (numSeedlings )
1309- firstSeedling := seedlings [0 ]
13101342
13111343 // If we cancel the current batch, the pending batch should be cleared,
13121344 // but the seedlings should still exist on disk.
@@ -1320,21 +1352,20 @@ func testMintingCancelFinalize(t *mintingTestHarness) {
13201352 t .finalizeBatchAssertFrozen (true )
13211353 t .cancelMintingBatch (true )
13221354
1323- // Next, make another 5 random seedlings and continue with minting.
1355+ // Next, make another set of random seedlings and continue with minting.
13241356 seedlings = t .newRandSeedlings (numSeedlings )
1325- seedlings [0 ] = firstSeedling
13261357 seedlings [0 ].ScriptKey = asset.ScriptKey {}
13271358 if seedlings [0 ].EnableEmission {
13281359 seedlings [0 ].GroupInternalKey = nil
13291360 }
13301361 t .queueSeedlingsInBatch (false , seedlings ... )
13311362
1332- t .assertPendingBatchExists (numSeedlings )
1363+ t .assertPendingBatchExists (seedlings )
13331364 t .assertSeedlingsExist (seedlings , nil )
13341365
13351366 // If we attempt to queue a seedling with the same name as a pending
13361367 // seedling, the planter should reject it.
1337- updates , err := t .planter .QueueNewSeedling (firstSeedling )
1368+ updates , err := t .planter .QueueNewSeedling (seedlings [ 0 ] )
13381369 require .NoError (t , err )
13391370 planterErr := <- updates
13401371 require .NotNil (t , planterErr .Error )
@@ -1781,7 +1812,7 @@ func testFundSealBeforeFinalize(t *mintingTestHarness) {
17811812 // Add the seedlings modified earlier to the batch, and check that they
17821813 // were added correctly.
17831814 t .queueSeedlingsInBatch (true , seedlings ... )
1784- t .assertPendingBatchExists (numSeedlings )
1815+ t .assertPendingBatchExists (seedlings )
17851816 t .assertSeedlingsExist (seedlings , nil )
17861817
17871818 verboseBatches , err := t .planter .ListBatches (
0 commit comments