Skip to content

Commit 127e016

Browse files
authored
Merge pull request #912 from lightninglabs/forward-traffic-shaper
[custom channels]: test forward traffic shaper
2 parents 8371d03 + a08e051 commit 127e016

File tree

6 files changed

+287
-82
lines changed

6 files changed

+287
-82
lines changed

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ require (
2323
github.com/lightninglabs/pool v0.6.5-beta.0.20241015105339-044cb451b5df
2424
github.com/lightninglabs/pool/auctioneerrpc v1.1.2
2525
github.com/lightninglabs/pool/poolrpc v1.0.0
26-
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e
27-
github.com/lightningnetwork/lnd v0.18.4-beta.rc1
26+
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209175552-fde673202d0d
27+
github.com/lightningnetwork/lnd v0.18.4-beta.rc1.0.20241205204908-f312064bfbd5
2828
github.com/lightningnetwork/lnd/cert v1.2.2
2929
github.com/lightningnetwork/lnd/fn v1.2.3
3030
github.com/lightningnetwork/lnd/kvdb v1.4.10
@@ -236,6 +236,4 @@ replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-d
236236

237237
replace github.com/lightninglabs/lightning-terminal/litrpc => ./litrpc
238238

239-
replace github.com/lightninglabs/aperture => github.com/lightninglabs/aperture v0.3.4-beta
240-
241239
go 1.22.6

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,12 +1177,12 @@ github.com/lightninglabs/pool/poolrpc v1.0.0 h1:vvosrgNx9WXF4mcHGqLjZOW8wNM0q+BL
11771177
github.com/lightninglabs/pool/poolrpc v1.0.0/go.mod h1:ZqpEpBFRMMBAerMmilEjh27tqauSXDwLaLR0O3jvmMA=
11781178
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9Z6CpKxl13mS48idsu6F+cEZf0lkyiV+Dq9g=
11791179
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
1180-
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e h1:dFbyAZrkQ9xALiVUf0qikLV2TabucCgPwJZ/Dc6r62Y=
1181-
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e/go.mod h1:d9GdY5DVoSh6+dEQRS4UUcjpVvZlAHgP8U2DAp4YedA=
1180+
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209175552-fde673202d0d h1:7M7CAHVb2ctF9sgbOkfTJmp2eCY23+LjmwznDt8xDVw=
1181+
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209175552-fde673202d0d/go.mod h1:kIjx0Nppwcpv+CZU6dTMb7iouq5SgPsS0JXhb6a+HPU=
11821182
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
11831183
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
1184-
github.com/lightningnetwork/lnd v0.18.4-beta.rc1 h1:z6hFKvtbfo8udPrIb81GbSoKlUWd06d4LRxTkD19IMQ=
1185-
github.com/lightningnetwork/lnd v0.18.4-beta.rc1/go.mod h1:nPRQzLla5uHPQFyyZn8r9Vgddkd23PBUDa9rggEPOfY=
1184+
github.com/lightningnetwork/lnd v0.18.4-beta.rc1.0.20241205204908-f312064bfbd5 h1:YJ/DPJd3YyPWmvv5b74KdpCFi3uBMdmDei54AageGpc=
1185+
github.com/lightningnetwork/lnd v0.18.4-beta.rc1.0.20241205204908-f312064bfbd5/go.mod h1:nPRQzLla5uHPQFyyZn8r9Vgddkd23PBUDa9rggEPOfY=
11861186
github.com/lightningnetwork/lnd/cert v1.2.2 h1:71YK6hogeJtxSxw2teq3eGeuy4rHGKcFf0d0Uy4qBjI=
11871187
github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bqGVxViXhX6Cd7HXM6U=
11881188
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=

itest/assets_test.go

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,12 @@ func addRoutingFee(amt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
718718
}
719719

720720
func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
721-
assetID []byte, btcAmt fn.Option[int64],
722-
expectedStatus lnrpc.Payment_PaymentStatus,
723-
failReason fn.Option[lnrpc.PaymentFailureReason]) {
721+
assetID []byte, btcAmt fn.Option[int64], opts ...payOpt) {
722+
723+
cfg := defaultPayConfig()
724+
for _, opt := range opts {
725+
opt(cfg)
726+
}
724727

725728
ctxb := context.Background()
726729
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -760,12 +763,8 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
760763
if result.Status == lnrpc.Payment_FAILED {
761764
t.Logf("Failure reason: %v", result.FailureReason)
762765
}
763-
require.Equal(t, expectedStatus, result.Status)
764-
765-
expectedReason := failReason.UnwrapOr(
766-
lnrpc.PaymentFailureReason_FAILURE_REASON_NONE,
767-
)
768-
require.Equal(t, expectedReason, result.FailureReason)
766+
require.Equal(t, cfg.payStatus, result.Status)
767+
require.Equal(t, cfg.failureReason, result.FailureReason)
769768
}
770769

771770
func sendKeySendPayment(t *testing.T, src, dst *HarnessNode,
@@ -818,9 +817,7 @@ func createAndPayNormalInvoiceWithBtc(t *testing.T, src, dst *HarnessNode,
818817
})
819818
require.NoError(t, err)
820819

821-
payInvoiceWithSatoshi(
822-
t, src, invoiceResp, lnrpc.Payment_SUCCEEDED, false,
823-
)
820+
payInvoiceWithSatoshi(t, src, invoiceResp)
824821
}
825822

826823
func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
@@ -846,8 +843,12 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
846843
}
847844

848845
func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
849-
invoice *lnrpc.AddInvoiceResponse,
850-
expectedStatus lnrpc.Payment_PaymentStatus, expectTimeout bool) {
846+
invoice *lnrpc.AddInvoiceResponse, opts ...payOpt) {
847+
848+
cfg := defaultPayConfig()
849+
for _, opt := range opts {
850+
opt(cfg)
851+
}
851852

852853
ctxb := context.Background()
853854
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -863,11 +864,12 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
863864
require.NoError(t, err)
864865

865866
result, err := getPaymentResult(stream)
866-
if expectTimeout {
867+
if cfg.expectTimeout {
867868
require.ErrorContains(t, err, "context deadline exceeded")
868869
} else {
869870
require.NoError(t, err)
870-
require.Equal(t, expectedStatus, result.Status)
871+
require.Equal(t, cfg.payStatus, result.Status)
872+
require.Equal(t, cfg.failureReason, result.FailureReason)
871873
}
872874
}
873875

@@ -910,6 +912,7 @@ func payInvoiceWithSatoshiLastHop(t *testing.T, payer *HarnessNode,
910912

911913
type payConfig struct {
912914
smallShards bool
915+
expectTimeout bool
913916
payStatus lnrpc.Payment_PaymentStatus
914917
failureReason lnrpc.PaymentFailureReason
915918
rfq fn.Option[rfqmsg.ID]
@@ -918,6 +921,7 @@ type payConfig struct {
918921
func defaultPayConfig() *payConfig {
919922
return &payConfig{
920923
smallShards: false,
924+
expectTimeout: false,
921925
payStatus: lnrpc.Payment_SUCCEEDED,
922926
failureReason: lnrpc.PaymentFailureReason_FAILURE_REASON_NONE,
923927
}
@@ -931,6 +935,12 @@ func withSmallShards() payOpt {
931935
}
932936
}
933937

938+
func withExpectTimeout() payOpt {
939+
return func(c *payConfig) {
940+
c.expectTimeout = true
941+
}
942+
}
943+
934944
func withFailure(status lnrpc.Payment_PaymentStatus,
935945
reason lnrpc.PaymentFailureReason) payOpt {
936946

0 commit comments

Comments
 (0)