Skip to content

Commit

Permalink
itest: always specify outpoint in sendProof
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Feb 5, 2024
1 parent dbb80f6 commit 171535d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
21 changes: 20 additions & 1 deletion itest/addrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"

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

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

ctxb := context.Background()

// We need to find the outpoint of the asset we sent to the address.
var outpoint *taprpc.OutPoint
for _, out := range sendResp.Transfer.Outputs {
if bytes.Equal(out.ScriptKey, scriptKey) {
wireOutPoint, err := wire.NewOutPointFromString(
out.Anchor.Outpoint,
)
require.NoError(t.t, err)

outpoint = &taprpc.OutPoint{
Txid: wireOutPoint.Hash[:],
OutputIndex: wireOutPoint.Index,
}
}
}

var proofResp *taprpc.ProofFile
waitErr := wait.NoError(func() error {
resp, err := src.ExportProof(ctxb, &taprpc.ExportProofRequest{
AssetId: genInfo.AssetId,
ScriptKey: scriptKey,
Outpoint: outpoint,
})
if err != nil {
return err
Expand Down
18 changes: 9 additions & 9 deletions itest/psbt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func testPsbtScriptHashLockSend(t *harnessTest) {
// This is an interactive/PSBT based transfer, so we do need to manually
// send the proof from the sender to the receiver because the proof
// courier address gets lost in the address->PSBT conversion.
_ = sendProof(t, bob, alice, aliceAddr.ScriptKey, genInfo)
_ = sendProof(t, bob, alice, sendResp, aliceAddr.ScriptKey, genInfo)
AssertNonInteractiveRecvComplete(t.t, alice, 1)

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

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

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

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

Expand Down Expand Up @@ -916,11 +916,11 @@ func testPsbtMultiSend(t *harnessTest) {
// This is an interactive transfer, so we do need to manually send the
// proof from the sender to the receiver.
_ = sendProof(
t, sender, receiver,
t, sender, receiver, sendResp,
receiverScriptKey1.PubKey.SerializeCompressed(), genInfo,
)
_ = sendProof(
t, sender, receiver,
t, sender, receiver, sendResp,
receiverScriptKey2.PubKey.SerializeCompressed(), genInfo,
)

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

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

Expand Down

0 comments on commit 171535d

Please sign in to comment.