@@ -19,6 +19,7 @@ import (
1919 "github.com/lightningnetwork/lnd/keychain"
2020 "github.com/lightningnetwork/lnd/tlv"
2121 "github.com/stretchr/testify/require"
22+ "pgregory.net/rapid"
2223)
2324
2425// RandGenesis creates a random genesis for testing.
@@ -38,17 +39,24 @@ func RandGenesis(t testing.TB, assetType Type) Genesis {
3839}
3940
4041// RandGroupKey creates a random group key for testing.
41- func RandGroupKey (t testing .TB , genesis Genesis , newAsset * Asset ) * GroupKey {
42- groupKey , _ := RandGroupKeyWithSigner (t , genesis , newAsset )
42+ func RandGroupKey (t rapid .TB , genesis Genesis , newAsset * Asset ) * GroupKey {
43+ groupKey , _ := RandGroupKeyWithSigner (t , nil , genesis , newAsset )
4344 return groupKey
4445}
4546
4647// RandGroupKeyWithSigner creates a random group key for testing, and provides
4748// the signer for reissuing assets into the same group.
48- func RandGroupKeyWithSigner (t testing .TB , genesis Genesis ,
49- newAsset * Asset ) (* GroupKey , []byte ) {
49+ func RandGroupKeyWithSigner (t rapid .TB , privKey * btcec. PrivateKey ,
50+ genesis Genesis , newAsset * Asset ) (* GroupKey , []byte ) {
5051
51- privateKey := test .RandPrivKey (t )
52+ var privateKey * btcec.PrivateKey
53+ switch {
54+ case privKey != nil :
55+ privateKey = privKey
56+
57+ default :
58+ privateKey = test .RandPrivKey ()
59+ }
5260
5361 genSigner := NewMockGenesisSigner (privateKey )
5462 genBuilder := MockGroupTxBuilder {}
@@ -352,7 +360,7 @@ func AssetCustomGroupKey(t *testing.T, useHashLock, BIP86, keySpend,
352360 scriptKey := RandScriptKey (t )
353361 protoAsset := RandAssetWithValues (t , gen , nil , scriptKey )
354362
355- groupPrivKey := test .RandPrivKey (t )
363+ groupPrivKey := test .RandPrivKey ()
356364 groupInternalKey := groupPrivKey .PubKey ()
357365 genSigner := NewMockGenesisSigner (groupPrivKey )
358366 genBuilder := MockGroupTxBuilder {}
@@ -430,12 +438,12 @@ func AssetCustomGroupKey(t *testing.T, useHashLock, BIP86, keySpend,
430438
431439// RandScriptKey creates a random script key for testing.
432440func RandScriptKey (t testing.TB ) ScriptKey {
433- return NewScriptKey (test .RandPrivKey (t ).PubKey ())
441+ return NewScriptKey (test .RandPrivKey ().PubKey ())
434442}
435443
436444// RandSerializedKey creates a random serialized key for testing.
437445func RandSerializedKey (t testing.TB ) SerializedKey {
438- return ToSerialized (test .RandPrivKey (t ).PubKey ())
446+ return ToSerialized (test .RandPrivKey ().PubKey ())
439447}
440448
441449// RandID creates a random asset ID.
0 commit comments