Skip to content

Commit 01f23a0

Browse files
committed
tapgarden: call fundGenesisPsbt from RandSeedlingMintingBatch
Use the standalone function fundGenesisPsbt when generating a mock batch genesis (mint anchor tx) funded PSBT. This change will allow us to seamlessly include pre-commitment outputs in the mock process later.
1 parent f62e65e commit 01f23a0

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

tapgarden/mock.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,32 @@ func RandSeedlings(t testing.TB, numSeedlings int) map[string]*Seedling {
5959
// RandSeedlingMintingBatch creates a new minting batch with only random
6060
// seedlings populated for testing.
6161
func RandSeedlingMintingBatch(t testing.TB, numSeedlings int) *MintingBatch {
62-
genesisTx := NewGenesisTx(t, chainfee.FeePerKwFloor)
63-
BatchKey, _ := test.RandKeyDesc(t)
64-
return &MintingBatch{
65-
BatchKey: BatchKey,
62+
batchKey, _ := test.RandKeyDesc(t)
63+
batch := MintingBatch{
64+
BatchKey: batchKey,
6665
Seedlings: RandSeedlings(t, numSeedlings),
6766
HeightHint: test.RandInt[uint32](),
6867
CreationTime: time.Now(),
69-
GenesisPacket: &FundedMintAnchorPsbt{
70-
FundedPsbt: tapsend.FundedPsbt{
71-
Pkt: &genesisTx,
72-
ChangeOutputIndex: 1,
73-
},
74-
AssetAnchorOutIdx: 0,
75-
},
7668
}
69+
70+
walletFundPsbt := func(ctx context.Context,
71+
anchorPkt psbt.Packet) (tapsend.FundedPsbt, error) {
72+
73+
FundGenesisTx(&anchorPkt, chainfee.FeePerKwFloor)
74+
75+
return tapsend.FundedPsbt{
76+
Pkt: &anchorPkt,
77+
ChangeOutputIndex: 1,
78+
}, nil
79+
}
80+
81+
// Fund genesis packet.
82+
ctx := context.Background()
83+
fundedPsbt, err := fundGenesisPsbt(ctx, &batch, walletFundPsbt)
84+
require.NoError(t, err)
85+
86+
batch.GenesisPacket = &fundedPsbt
87+
return &batch
7788
}
7889

7990
type MockWalletAnchor struct {

0 commit comments

Comments
 (0)