diff --git a/itest/assertions.go b/itest/assertions.go index 9acab8cc0..fe81fd9b0 100644 --- a/itest/assertions.go +++ b/itest/assertions.go @@ -12,7 +12,6 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightninglabs/taproot-assets/asset" "github.com/lightninglabs/taproot-assets/fn" @@ -366,7 +365,27 @@ func verifyProofBlob(t *testing.T, tapClient taprpc.TaprootAssetsClient, return err } - snapshot, err := f.Verify(ctxt, headerVerifier) + groupVerifier := func(groupKey *btcec.PublicKey) error { + assetGroupKey := hex.EncodeToString( + groupKey.SerializeCompressed(), + ) + + // The given group key should be listed as a known group. + assetGroups, err := tapClient.ListGroups( + ctxt, &taprpc.ListGroupsRequest{}, + ) + require.NoError(t, err) + + _, ok := assetGroups.Groups[assetGroupKey] + if !ok { + return fmt.Errorf("group key %s not known", + assetGroupKey) + } + + return nil + } + + snapshot, err := f.Verify(ctxt, headerVerifier, groupVerifier) require.NoError(t, err) return f, snapshot @@ -845,15 +864,20 @@ func AssertGroup(t *testing.T, a *taprpc.Asset, b *taprpc.AssetHumanReadable, // AssertGroupAnchor asserts that a specific asset genesis was used to create // a tweaked group key. func AssertGroupAnchor(t *testing.T, anchorGen *asset.Genesis, - internalKey, tweakedKey []byte) { + anchorGroup *taprpc.AssetGroup) { - internalPubKey, err := btcec.ParsePubKey(internalKey) + internalPubKey, err := btcec.ParsePubKey(anchorGroup.RawGroupKey) require.NoError(t, err) - computedGroupPubKey := txscript.ComputeTaprootOutputKey( - internalPubKey, anchorGen.GroupKeyTweak(), + + // TODO(jhb): add tapscript root support + anchorTweak := anchorGen.ID() + computedGroupPubKey, err := asset.GroupPubKey( + internalPubKey, anchorTweak[:], nil, ) + require.NoError(t, err) + computedGroupKey := computedGroupPubKey.SerializeCompressed() - require.Equal(t, tweakedKey, computedGroupKey) + require.Equal(t, anchorGroup.TweakedGroupKey, computedGroupKey) } // MatchRpcAsset is a function that returns true if the given RPC asset is a diff --git a/itest/assets_test.go b/itest/assets_test.go index 4a430ade8..87f49ab1e 100644 --- a/itest/assets_test.go +++ b/itest/assets_test.go @@ -408,9 +408,8 @@ func assertAssetBalances(t *harnessTest, require.Equal( t.t, balance.Balance, rpcAsset.Amount, ) - require.Equal( - t.t, - balance.AssetGenesis, + AssertAssetGenesis( + t.t, balance.AssetGenesis, rpcAsset.AssetGenesis, ) } diff --git a/itest/multi_asset_group_test.go b/itest/multi_asset_group_test.go index 2d7eae59f..1d22340ad 100644 --- a/itest/multi_asset_group_test.go +++ b/itest/multi_asset_group_test.go @@ -191,10 +191,7 @@ func VerifyGroupAnchor(t *testing.T, assets []*taprpc.Asset, anchorGen := parseGenInfo(t, anchor.AssetGenesis) anchorGen.Type = asset.Type(anchor.AssetType) - AssertGroupAnchor( - t, anchorGen, anchor.AssetGroup.RawGroupKey, - anchor.AssetGroup.TweakedGroupKey, - ) + AssertGroupAnchor(t, anchorGen, anchor.AssetGroup) return anchor }