Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ 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.20240824000229-881ecafbeae1
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240730143253-1b353b0bfd58
github.com/lightninglabs/taproot-assets v0.4.2-0.20240919134641-81dd00278f8a
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240919091721-70580403898e
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/fn v1.1.0
github.com/lightningnetwork/lnd/kvdb v1.4.8
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1175,12 +1175,12 @@ 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.20240824000229-881ecafbeae1 h1:2yncq2U2xvEUPjYEP5dGazJGj83Y+gr0di/aQVmXPs8=
github.com/lightninglabs/taproot-assets v0.4.2-0.20240824000229-881ecafbeae1/go.mod h1:PMlRq9aKXaxs6PMeLnj3y3YnofrylNvEOTxvegTbhSc=
github.com/lightninglabs/taproot-assets v0.4.2-0.20240919134641-81dd00278f8a h1:EmHMf2/cgkXhj+cn6jWMi+or+2AlXmQ7Qwjfj2umZZg=
github.com/lightninglabs/taproot-assets v0.4.2-0.20240919134641-81dd00278f8a/go.mod h1:B6wbs1rSTBTJwTilsKt7p/WravtKqRvJI0ICDwvcdNQ=
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=
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240730143253-1b353b0bfd58/go.mod h1:0gen58n0DVnqJJqCMN3AXNtqWRT0KltQanlvehnhCq0=
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240919091721-70580403898e h1:Weu9TWNEIpC4XLbcUoSFK3Pv2aUSwn7NlYZKdsm8wUU=
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240919091721-70580403898e/go.mod h1:/Uh0qCiU/oQls68spxpmP0kRjX/uGkLzt7P/uPpDofE=
github.com/lightningnetwork/lnd/cert v1.2.2 h1:71YK6hogeJtxSxw2teq3eGeuy4rHGKcFf0d0Uy4qBjI=
github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bqGVxViXhX6Cd7HXM6U=
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
Expand Down Expand Up @@ -2269,6 +2269,8 @@ modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8=
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
Expand Down
46 changes: 32 additions & 14 deletions itest/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"os"
"testing"
"time"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
Expand Down Expand Up @@ -45,6 +46,9 @@ import (
"gopkg.in/macaroon.v2"
)

// PaymentTimeout is the default payment timeout we use in our tests.
const PaymentTimeout = 6 * time.Second

// createTestAssetNetwork sends asset funds from Charlie to Dave and Erin, so
// they can fund asset channels with Yara and Fabia, respectively. So the asset
// channels created are Charlie->Dave, Dave->Yara, Erin->Fabia. The channels
Expand Down Expand Up @@ -429,9 +433,10 @@ func assertPendingChannels(t *testing.T, node *HarnessNode, assetID []byte,

require.NotZero(t, pendingJSON.Assets[0].Capacity)

pendingLocalBalance, pendingRemoteBalance := getAssetChannelBalance(
t, node, assetID, true,
)
pendingLocalBalance, pendingRemoteBalance, _, _ :=
getAssetChannelBalance(
t, node, assetID, true,
)
require.EqualValues(t, localSum, pendingLocalBalance)
require.EqualValues(t, remoteSum, pendingRemoteBalance)
}
Expand Down Expand Up @@ -542,7 +547,7 @@ func getChannelCustomData(src, dst *HarnessNode) (*rfqmsg.JsonAssetChanInfo,
}

func getAssetChannelBalance(t *testing.T, node *HarnessNode, assetID []byte,
pending bool) (uint64, uint64) {
pending bool) (uint64, uint64, uint64, uint64) {

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
Expand Down Expand Up @@ -572,11 +577,14 @@ func getAssetChannelBalance(t *testing.T, node *HarnessNode, assetID []byte,
remoteSum += balances[assetIDString].RemoteBalance
}

return localSum, remoteSum
return localSum, remoteSum, balance.LocalBalance.Sat,
balance.RemoteBalance.Sat
}

func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
assetID []byte, btcAmt fn.Option[int64]) {
assetID []byte, btcAmt fn.Option[int64],
expectedStatus lnrpc.Payment_PaymentStatus,
failReason fn.Option[lnrpc.PaymentFailureReason]) {

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
Expand All @@ -601,7 +609,7 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
Amt: btcAmt.UnwrapOr(500),
DestCustomRecords: customRecords,
PaymentHash: hash[:],
TimeoutSeconds: 3,
TimeoutSeconds: int32(PaymentTimeout.Seconds()),
}

stream, err := srcTapd.SendPayment(ctxt, &tchrpc.SendPaymentRequest{
Expand All @@ -613,7 +621,12 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,

result, err := getAssetPaymentResult(stream)
require.NoError(t, err)
require.Equal(t, lnrpc.Payment_SUCCEEDED, result.Status)
require.Equal(t, expectedStatus, result.Status)

expectedReason := failReason.UnwrapOr(
lnrpc.PaymentFailureReason_FAILURE_REASON_NONE,
)
require.Equal(t, result.FailureReason, expectedReason)
}

func sendKeySendPayment(t *testing.T, src, dst *HarnessNode,
Expand All @@ -640,7 +653,7 @@ func sendKeySendPayment(t *testing.T, src, dst *HarnessNode,
Amt: int64(amt),
DestCustomRecords: customRecords,
PaymentHash: hash[:],
TimeoutSeconds: 3,
TimeoutSeconds: int32(PaymentTimeout.Seconds()),
}

stream, err := src.RouterClient.SendPaymentV2(ctxt, req)
Expand Down Expand Up @@ -698,7 +711,7 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,

sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: invoice.PaymentRequest,
TimeoutSeconds: 2,
TimeoutSeconds: int32(PaymentTimeout.Seconds()),
MaxShardSizeMsat: 80_000_000,
FeeLimitMsat: 1_000_000,
}
Expand Down Expand Up @@ -727,7 +740,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,

sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: invoice.PaymentRequest,
TimeoutSeconds: 2,
TimeoutSeconds: int32(PaymentTimeout.Seconds()),
FeeLimitMsat: 1_000_000,
}

Expand Down Expand Up @@ -1422,10 +1435,15 @@ func logBalance(t *testing.T, nodes []*HarnessNode, assetID []byte,

t.Helper()

time.Sleep(time.Millisecond * 250)

for _, node := range nodes {
local, remote := getAssetChannelBalance(t, node, assetID, false)
t.Logf("%-7s balance: local=%-9d remote=%-9d (%v)",
node.Cfg.Name, local, remote, occasion)
local, remote, localSat, remoteSat :=
getAssetChannelBalance(t, node, assetID, false)

t.Logf("%-7s balance: local=%-9d remote=%-9d, localSat=%-9d, "+
"remoteSat=%-9d (%v)", node.Cfg.Name, local, remote,
localSat, remoteSat, occasion)
}
}

Expand Down
Loading
Loading