@@ -609,6 +609,62 @@ func TestCommitMintingBatchSeedlings(t *testing.T) {
609609 assertSeedlingBatchLen (t , mintingBatches , 1 , numSeedlings )
610610}
611611
612+ // TestInsertFetchUniCommitBatch tests that we're able to properly write
613+ // and read a minting batch that has universe commitments enabled.
614+ func TestInsertFetchUniCommitBatch (t * testing.T ) {
615+ t .Parallel ()
616+
617+ ctx := context .Background ()
618+ assetStore , _ , _ := newAssetStore (t )
619+
620+ // Generate a batch with a single seedling, we will set the group
621+ // information later.
622+ batch := tapgarden .RandMintingBatch (
623+ t , tapgarden .WithTotalGroups ([]int {1 }),
624+ tapgarden .WithUniverseCommitments (true ),
625+ )
626+ require .True (t , batch .UniverseCommitments )
627+
628+ // Generate the group genesis, persist it, and assign the group details
629+ // to the seedling.
630+ assetName := maps .Keys (batch .Seedlings )[0 ]
631+ assetType := batch .Seedlings [assetName ].AssetType
632+
633+ privDesc , groupPriv := test .RandKeyDesc (t )
634+ randGenesis := asset .RandGenesis (t , assetType )
635+ _ , _ , group := storeGroupGenesis (
636+ t , ctx , randGenesis , nil , assetStore , privDesc , groupPriv ,
637+ )
638+
639+ batch .Seedlings [assetName ].GroupInfo = group
640+
641+ // Assert that the seedling is in the expected state.
642+ seedling := batch .Seedlings [assetName ]
643+ require .True (t , seedling .UniverseCommitments )
644+ require .True (t , seedling .DelegationKey .IsSome ())
645+
646+ // Commit the minting batch to the database.
647+ err := assetStore .CommitMintingBatch (ctx , batch )
648+ require .NoError (t , err )
649+
650+ // Fetch the same batch from the database.
651+ dbBatch , err := assetStore .FetchMintingBatch (
652+ ctx , batch .BatchKey .PubKey ,
653+ )
654+ require .NoError (t , err )
655+
656+ // Assert that the batch is in the expected state.
657+ require .True (t , dbBatch .UniverseCommitments )
658+
659+ // Assert that the seedling is in the expected state.
660+ require .Len (t , dbBatch .Seedlings , 1 )
661+
662+ dbSeedling := dbBatch .Seedlings [assetName ]
663+ require .True (t , dbSeedling .UniverseCommitments )
664+ require .True (t , dbSeedling .DelegationKey .IsSome ())
665+ require .Equal (t , dbSeedling .DelegationKey , seedling .DelegationKey )
666+ }
667+
612668// seedlingsToAssetRoot maps a set of seedlings to an asset root.
613669//
614670// TODO(roasbeef): same func in tapgarden can just re-use?
0 commit comments