From 171535dfac72597bf95435f9919014e9dfd7033c Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 2 Feb 2024 13:19:09 +0100 Subject: [PATCH] itest: always specify outpoint in sendProof --- itest/addrs_test.go | 21 ++++++++++++++++++++- itest/psbt_test.go | 18 +++++++++--------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/itest/addrs_test.go b/itest/addrs_test.go index b03ddfbc9..6fa71950b 100644 --- a/itest/addrs_test.go +++ b/itest/addrs_test.go @@ -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" @@ -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 diff --git a/itest/psbt_test.go b/itest/psbt_test.go index 0b0639ce7..0858c9101 100644 --- a/itest/psbt_test.go +++ b/itest/psbt_test.go @@ -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{ @@ -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{ @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, )