Skip to content

Commit da6dcea

Browse files
committed
itest: retrieve anchor txid from outpoint
1 parent ec46259 commit da6dcea

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

itest/assertions.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ func AssetAnchorCheck(txid, blockHash chainhash.Hash) AssetCheck {
6969
return fmt.Errorf("asset is missing chain anchor field")
7070
}
7171

72-
if a.ChainAnchor.AnchorTxid != txid.String() {
72+
out, err :=
73+
wire.NewOutPointFromString(a.ChainAnchor.AnchorOutpoint)
74+
if err != nil {
75+
return fmt.Errorf("unable to parse outpoint: %v", err)
76+
}
77+
78+
anchorTxid := out.Hash.String()
79+
80+
if anchorTxid != txid.String() {
7381
return fmt.Errorf("unexpected asset anchor TXID, got "+
74-
"%v wanted %x", a.ChainAnchor.AnchorTxid,
75-
txid[:])
82+
"%v wanted %x", anchorTxid, txid[:])
7683
}
7784

7885
if a.ChainAnchor.AnchorBlockHash != blockHash.String() {

itest/assets_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/btcsuite/btcd/chaincfg/chainhash"
10+
"github.com/btcsuite/btcd/wire"
1011
"github.com/lightninglabs/taproot-assets/fn"
1112
"github.com/lightninglabs/taproot-assets/proof"
1213
"github.com/lightninglabs/taproot-assets/taprpc"
@@ -173,11 +174,13 @@ func transferAssetProofs(t *harnessTest, src, dst *tapdHarness,
173174
importedAssets := GroupAssetsByName(listResp.Assets)
174175
for _, existingAsset := range assets {
175176
gen := existingAsset.AssetGenesis
176-
anchorTxHash, err := chainhash.NewHashFromStr(
177-
existingAsset.ChainAnchor.AnchorTxid,
177+
out, err := wire.NewOutPointFromString(
178+
existingAsset.ChainAnchor.AnchorOutpoint,
178179
)
179180
require.NoError(t.t, err)
180181

182+
anchorTxHash := out.Hash
183+
181184
anchorBlockHash, err := chainhash.NewHashFromStr(
182185
existingAsset.ChainAnchor.AnchorBlockHash,
183186
)
@@ -187,7 +190,7 @@ func transferAssetProofs(t *harnessTest, src, dst *tapdHarness,
187190
t.t, importedAssets, gen.Name, gen.MetaHash,
188191
AssetAmountCheck(existingAsset.Amount),
189192
AssetTypeCheck(existingAsset.AssetGenesis.AssetType),
190-
AssetAnchorCheck(*anchorTxHash, *anchorBlockHash),
193+
AssetAnchorCheck(anchorTxHash, *anchorBlockHash),
191194
AssetScriptKeyIsLocalCheck(shouldShowUpAsLocal),
192195
)
193196
}

0 commit comments

Comments
 (0)