Skip to content

Commit 3dae4bb

Browse files
committed
itest: use universe based proof transfer for trustless swap
We don't want to use the development build only devrpc.ImportProof RPC, since this scenario will be used by production build apps as well. So we update the test to use the new taprpc.RegisterTransfer RPC instead.
1 parent d3adc11 commit 3dae4bb

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

itest/psbt_test.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,10 +2424,31 @@ func testPsbtTrustlessSwap(t *harnessTest) {
24242424
// We also need to push the proof for this transfer to the universe
24252425
// server.
24262426
bobScriptKeyBytes := bobScriptKey.PubKey.SerializeCompressed()
2427+
bobOutputIndex := uint32(1)
2428+
transferTXID := finalPsbt.UnsignedTx.TxHash()
2429+
bobAssetOutpoint := fmt.Sprintf("%s:%d", transferTXID.String(),
2430+
bobOutputIndex)
24272431
transferProofUniRPC(
24282432
t, t.universeServer.service, bob, bobScriptKeyBytes, genInfo,
2429-
mintedAsset.AssetGroup,
2430-
logResp.Transfer.Outputs[0].Anchor.Outpoint,
2433+
mintedAsset.AssetGroup, bobAssetOutpoint,
2434+
)
2435+
2436+
// In order for Bob to expect this incoming transfer, we need to
2437+
// register it with the internal wallet of Bob.
2438+
registerResp, err := bob.RegisterTransfer(
2439+
ctxb, &taprpc.RegisterTransferRequest{
2440+
AssetId: assetID[:],
2441+
GroupKey: mintedAsset.AssetGroup.TweakedGroupKey,
2442+
ScriptKey: bobScriptKeyBytes,
2443+
Outpoint: &taprpc.OutPoint{
2444+
Txid: transferTXID[:],
2445+
OutputIndex: bobOutputIndex,
2446+
},
2447+
},
2448+
)
2449+
require.NoError(t.t, err)
2450+
require.Equal(
2451+
t.t, bobScriptKeyBytes, registerResp.RegisteredAsset.ScriptKey,
24312452
)
24322453

24332454
bobAssets, err := bob.ListAssets(ctxb, &taprpc.ListAssetRequest{})
@@ -2436,6 +2457,8 @@ func testPsbtTrustlessSwap(t *harnessTest) {
24362457
// Verify that Bob now holds the asset.
24372458
require.Len(t.t, bobAssets.Assets, 1)
24382459
require.Equal(t.t, bobAssets.Assets[0].Amount, numUnits)
2460+
2461+
require.Equal(t.t, bobScriptKeyBytes, bobAssets.Assets[0].ScriptKey)
24392462
}
24402463

24412464
// testPsbtExternalCommit tests the ability to fully customize the BTC level of

0 commit comments

Comments
 (0)