Skip to content

Commit

Permalink
Merge pull request #825 from lightninglabs/spend-tx-after-fc
Browse files Browse the repository at this point in the history
itest: spend assets after sweeping from force close
  • Loading branch information
Roasbeef authored Aug 24, 2024
2 parents 5f05f2d + dc2c5d6 commit 79f7297
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
55 changes: 55 additions & 0 deletions itest/litd_custom_channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79f7297

Please sign in to comment.