Skip to content

Commit a1c3027

Browse files
committed
proof: test proof creation with custom group key
1 parent d5b2f89 commit a1c3027

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

proof/mint_test.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,8 @@ func TestNewMintingBlobs(t *testing.T) {
3636
assetGenesis := asset.RandGenesis(t, asset.Collectible)
3737
assetGenesis.MetaHash = metaReveal.MetaHash()
3838
assetGenesis.OutputIndex = 0
39-
protoAsset := asset.NewAssetNoErr(
40-
t, assetGenesis, 1, 0, 0,
41-
asset.NewScriptKeyBip86(genesisScriptKey), nil,
42-
)
43-
44-
assetGroupKey := asset.RandGroupKey(t, assetGenesis, protoAsset)
4539
tapCommitment, _, err := commitment.Mint(
46-
assetGenesis, assetGroupKey, &commitment.AssetDetails{
40+
assetGenesis, nil, &commitment.AssetDetails{
4741
Type: asset.Collectible,
4842
ScriptKey: genesisScriptKey,
4943
Amount: nil,
@@ -53,6 +47,22 @@ func TestNewMintingBlobs(t *testing.T) {
5347
)
5448
require.NoError(t, err)
5549

50+
// Add a group anchor with a custom tapscript root to the set of minted
51+
// assets. We cannot make this type of asset with commitment.Mint, so
52+
// we create it manually and then insert it into the tap commitment.
53+
groupedGenesis := asset.RandGenesis(t, asset.Normal)
54+
groupedGenesis.FirstPrevOut = assetGenesis.FirstPrevOut
55+
groupedGenesis.MetaHash = metaReveal.MetaHash()
56+
groupedGenesis.OutputIndex = 0
57+
groupedAsset := asset.AssetCustomGroupKey(
58+
t, test.RandBool(), false, false, true, groupedGenesis,
59+
)
60+
61+
groupedAssetTree, err := commitment.NewAssetCommitment(groupedAsset)
62+
require.NoError(t, err)
63+
err = tapCommitment.Upsert(groupedAssetTree)
64+
require.NoError(t, err)
65+
5666
internalKey := test.SchnorrPubKey(t, genesisPrivKey)
5767
tapscriptRoot := tapCommitment.TapscriptRoot(nil)
5868
taprootKey := txscript.ComputeTaprootOutputKey(
@@ -89,11 +99,10 @@ func TestNewMintingBlobs(t *testing.T) {
8999
0, chaincfg.MainNetParams.GenesisHash, merkleRoot, 0, 0,
90100
)
91101

92-
newAsset := tapCommitment.CommittedAssets()[0]
93-
assetScriptKey := newAsset.ScriptKey
94-
102+
assetScriptKey := asset.NewScriptKeyBip86(genesisScriptKey)
95103
metaReveals := map[asset.SerializedKey]*MetaReveal{
96-
asset.ToSerialized(assetScriptKey.PubKey): metaReveal,
104+
asset.ToSerialized(assetScriptKey.PubKey): metaReveal,
105+
asset.ToSerialized(groupedAsset.ScriptKey.PubKey): metaReveal,
97106
}
98107

99108
// The NewMintingBlobs will return an error if the generated proof is

0 commit comments

Comments
 (0)