From dc2c5d68d57fcaf3a818f7db622d14ee02957dcf Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 22 Aug 2024 11:20:43 +0200 Subject: [PATCH] itest: spend assets after sweeping from force close --- go.mod | 2 +- go.sum | 4 +-- itest/litd_custom_channels_test.go | 55 ++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0ae61be11..222cc16f2 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/lightninglabs/loop/swapserverrpc v1.0.8 github.com/lightninglabs/pool v0.6.5-beta.0.20240604070222-e121aadb3289 github.com/lightninglabs/pool/auctioneerrpc v1.1.2 - github.com/lightninglabs/taproot-assets v0.4.2-0.20240815180811-2110839696cb + github.com/lightninglabs/taproot-assets v0.4.2-0.20240824000229-881ecafbeae1 github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240730143253-1b353b0bfd58 github.com/lightningnetwork/lnd/cert v1.2.2 github.com/lightningnetwork/lnd/fn v1.1.0 diff --git a/go.sum b/go.sum index 4abf3eebb..064174c7e 100644 --- a/go.sum +++ b/go.sum @@ -1175,8 +1175,8 @@ github.com/lightninglabs/pool/auctioneerrpc v1.1.2 h1:Dbg+9Z9jXnhimR27EN37foc4aB github.com/lightninglabs/pool/auctioneerrpc v1.1.2/go.mod h1:1wKDzN2zEP8srOi0B9iySlEsPdoPhw6oo3Vbm1v4Mhw= github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display h1:pRdza2wleRN1L2fJXd6ZoQ9ZegVFTAb2bOQfruJPKcY= github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -github.com/lightninglabs/taproot-assets v0.4.2-0.20240815180811-2110839696cb h1:0MPIRVvk7ExBV35xEfAS2gDzQyGfufPYVhCAp2S6jwo= -github.com/lightninglabs/taproot-assets v0.4.2-0.20240815180811-2110839696cb/go.mod h1:PMlRq9aKXaxs6PMeLnj3y3YnofrylNvEOTxvegTbhSc= +github.com/lightninglabs/taproot-assets v0.4.2-0.20240824000229-881ecafbeae1 h1:2yncq2U2xvEUPjYEP5dGazJGj83Y+gr0di/aQVmXPs8= +github.com/lightninglabs/taproot-assets v0.4.2-0.20240824000229-881ecafbeae1/go.mod h1:PMlRq9aKXaxs6PMeLnj3y3YnofrylNvEOTxvegTbhSc= github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f h1:Pua7+5TcFEJXIIZ1I2YAUapmbcttmLj4TTi786bIi3s= github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI= github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240730143253-1b353b0bfd58 h1:qmJAHLGfpeYIl1qUKyQViOjNAVRqF4afKuORzeIAwjA= diff --git a/itest/litd_custom_channels_test.go b/itest/litd_custom_channels_test.go index c9119c445..e0bc1c82f 100644 --- a/itest/litd_custom_channels_test.go +++ b/itest/litd_custom_channels_test.go @@ -1403,6 +1403,61 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness, // UTXO he can use. assertNumAssetUTXOs(t.t, daveTap, 1) assertNumAssetUTXOs(t.t, charlieTap, 2) + + // We'll make sure Dave can spend his asset UTXO by sending it all but + // one unit to Zane (the universe). + assetSendAmount := daveBalance - 1 + zaneAddr, err := universeTap.NewAddr(ctxb, &taprpc.NewAddrRequest{ + Amt: assetSendAmount, + AssetId: assetID, + ProofCourierAddr: fmt.Sprintf( + "%s://%s", proof.UniverseRpcCourierType, + charlieTap.node.Cfg.LitAddr(), + ), + }) + require.NoError(t.t, err) + + t.Logf("Sending %v asset from Dave units to Zane...", assetSendAmount) + + // Send the assets to Zane. We expect Dave to have 3 transfers: the + // funding txn, their force close sweep, and now this new send. + itest.AssertAddrCreated(t.t, universeTap, cents, zaneAddr) + sendResp, err := daveTap.SendAsset(ctxb, &taprpc.SendAssetRequest{ + TapAddrs: []string{zaneAddr.Encoded}, + }) + require.NoError(t.t, err) + itest.ConfirmAndAssertOutboundTransfer( + t.t, t.lndHarness.Miner.Client, daveTap, sendResp, assetID, + []uint64{1, assetSendAmount}, 2, 3, + ) + itest.AssertNonInteractiveRecvComplete(t.t, universeTap, 1) + + // And now we also send all assets but one from Charlie to the universe + // to make sure the time lock sweep output can also be spent correctly. + assetSendAmount = charlieBalance - 1 + zaneAddr2, err := universeTap.NewAddr(ctxb, &taprpc.NewAddrRequest{ + Amt: assetSendAmount, + AssetId: assetID, + ProofCourierAddr: fmt.Sprintf( + "%s://%s", proof.UniverseRpcCourierType, + charlieTap.node.Cfg.LitAddr(), + ), + }) + require.NoError(t.t, err) + + t.Logf("Sending %v asset from Charlie units to Zane...", + assetSendAmount) + + itest.AssertAddrCreated(t.t, universeTap, cents, zaneAddr2) + sendResp2, err := charlieTap.SendAsset(ctxb, &taprpc.SendAssetRequest{ + TapAddrs: []string{zaneAddr2.Encoded}, + }) + require.NoError(t.t, err) + itest.ConfirmAndAssertOutboundTransfer( + t.t, t.lndHarness.Miner.Client, charlieTap, sendResp2, assetID, + []uint64{1, assetSendAmount}, 3, 4, + ) + itest.AssertNonInteractiveRecvComplete(t.t, universeTap, 2) } // testCustomChannelsBreach tests a force close scenario that breaches an old