Skip to content

Commit 171535d

Browse files
committed
itest: always specify outpoint in sendProof
1 parent dbb80f6 commit 171535d

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

itest/addrs_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66

77
"github.com/btcsuite/btcd/btcec/v2/schnorr"
8+
"github.com/btcsuite/btcd/wire"
89
tap "github.com/lightninglabs/taproot-assets"
910
"github.com/lightninglabs/taproot-assets/fn"
1011
"github.com/lightninglabs/taproot-assets/internal/test"
@@ -515,16 +516,34 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice,
515516

516517
// sendProof manually exports a proof from the given source node and imports it
517518
// using the development only ImportProof RPC on the destination node.
518-
func sendProof(t *harnessTest, src, dst *tapdHarness, scriptKey []byte,
519+
func sendProof(t *harnessTest, src, dst *tapdHarness,
520+
sendResp *taprpc.SendAssetResponse, scriptKey []byte,
519521
genInfo *taprpc.GenesisInfo) *tapdevrpc.ImportProofResponse {
520522

521523
ctxb := context.Background()
522524

525+
// We need to find the outpoint of the asset we sent to the address.
526+
var outpoint *taprpc.OutPoint
527+
for _, out := range sendResp.Transfer.Outputs {
528+
if bytes.Equal(out.ScriptKey, scriptKey) {
529+
wireOutPoint, err := wire.NewOutPointFromString(
530+
out.Anchor.Outpoint,
531+
)
532+
require.NoError(t.t, err)
533+
534+
outpoint = &taprpc.OutPoint{
535+
Txid: wireOutPoint.Hash[:],
536+
OutputIndex: wireOutPoint.Index,
537+
}
538+
}
539+
}
540+
523541
var proofResp *taprpc.ProofFile
524542
waitErr := wait.NoError(func() error {
525543
resp, err := src.ExportProof(ctxb, &taprpc.ExportProofRequest{
526544
AssetId: genInfo.AssetId,
527545
ScriptKey: scriptKey,
546+
Outpoint: outpoint,
528547
})
529548
if err != nil {
530549
return err

itest/psbt_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func testPsbtScriptHashLockSend(t *harnessTest) {
132132
// This is an interactive/PSBT based transfer, so we do need to manually
133133
// send the proof from the sender to the receiver because the proof
134134
// courier address gets lost in the address->PSBT conversion.
135-
_ = sendProof(t, bob, alice, aliceAddr.ScriptKey, genInfo)
135+
_ = sendProof(t, bob, alice, sendResp, aliceAddr.ScriptKey, genInfo)
136136
AssertNonInteractiveRecvComplete(t.t, alice, 1)
137137

138138
aliceAssets, err := alice.ListAssets(ctxb, &taprpc.ListAssetRequest{
@@ -258,7 +258,7 @@ func testPsbtScriptCheckSigSend(t *harnessTest) {
258258
// This is an interactive/PSBT based transfer, so we do need to manually
259259
// send the proof from the sender to the receiver because the proof
260260
// courier address gets lost in the address->PSBT conversion.
261-
_ = sendProof(t, bob, alice, aliceAddr.ScriptKey, genInfo)
261+
_ = sendProof(t, bob, alice, sendResp, aliceAddr.ScriptKey, genInfo)
262262
AssertNonInteractiveRecvComplete(t.t, alice, 1)
263263

264264
aliceAssets, err := alice.ListAssets(ctxb, &taprpc.ListAssetRequest{
@@ -434,7 +434,7 @@ func runPsbtInteractiveFullValueSendTest(ctxt context.Context, t *harnessTest,
434434
// This is an interactive transfer, so we do need to manually
435435
// send the proof from the sender to the receiver.
436436
_ = sendProof(
437-
t, sender, receiver,
437+
t, sender, receiver, sendResp,
438438
receiverScriptKey.PubKey.SerializeCompressed(), genInfo,
439439
)
440440

@@ -647,7 +647,7 @@ func runPsbtInteractiveSplitSendTest(ctxt context.Context, t *harnessTest,
647647
// This is an interactive transfer, so we do need to manually
648648
// send the proof from the sender to the receiver.
649649
_ = sendProof(
650-
t, sender, receiver,
650+
t, sender, receiver, sendResp,
651651
receiverScriptKey.PubKey.SerializeCompressed(), genInfo,
652652
)
653653

@@ -769,7 +769,7 @@ func testPsbtInteractiveTapscriptSibling(t *harnessTest) {
769769
// This is an interactive transfer, so we do need to manually send the
770770
// proof from the sender to the receiver.
771771
_ = sendProof(
772-
t, alice, bob,
772+
t, alice, bob, sendResp,
773773
receiverScriptKey.PubKey.SerializeCompressed(), genInfo,
774774
)
775775

@@ -916,11 +916,11 @@ func testPsbtMultiSend(t *harnessTest) {
916916
// This is an interactive transfer, so we do need to manually send the
917917
// proof from the sender to the receiver.
918918
_ = sendProof(
919-
t, sender, receiver,
919+
t, sender, receiver, sendResp,
920920
receiverScriptKey1.PubKey.SerializeCompressed(), genInfo,
921921
)
922922
_ = sendProof(
923-
t, sender, receiver,
923+
t, sender, receiver, sendResp,
924924
receiverScriptKey2.PubKey.SerializeCompressed(), genInfo,
925925
)
926926

@@ -1158,7 +1158,7 @@ func testMultiInputPsbtSingleAssetID(t *harnessTest) {
11581158
// This is an interactive transfer. Therefore, we will manually transfer
11591159
// the proof from the sender to the receiver.
11601160
_ = sendProof(
1161-
t, secondaryTapd, primaryTapd,
1161+
t, secondaryTapd, primaryTapd, sendResp,
11621162
primaryNodeScriptKey.PubKey.SerializeCompressed(), genInfo,
11631163
)
11641164

@@ -1233,7 +1233,7 @@ func testMultiInputPsbtSingleAssetID(t *harnessTest) {
12331233
// This is an interactive transfer. Therefore, we will manually transfer
12341234
// the proof from the sender to the receiver.
12351235
_ = sendProof(
1236-
t, secondaryTapd, primaryTapd,
1236+
t, secondaryTapd, primaryTapd, sendResp,
12371237
primaryNodeScriptKey.PubKey.SerializeCompressed(), genInfo,
12381238
)
12391239

0 commit comments

Comments
 (0)