From 8e9af2241f28dfc38502a661070a8f97bce18dd3 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Tue, 14 Jun 2022 13:37:56 +0200 Subject: [PATCH 01/11] rename existing mock --- integration_tests/{lnd-mock.go => lnd_mock_async.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename integration_tests/{lnd-mock.go => lnd_mock_async.go} (100%) diff --git a/integration_tests/lnd-mock.go b/integration_tests/lnd_mock_async.go similarity index 100% rename from integration_tests/lnd-mock.go rename to integration_tests/lnd_mock_async.go From 9e9fc4fbf0311d78c49718a05a64d195844f0c43 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Tue, 14 Jun 2022 16:02:22 +0200 Subject: [PATCH 02/11] implement lnd with zpay32 --- go.mod | 1 + integration_tests/lnd_mock.go | 136 ++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 integration_tests/lnd_mock.go diff --git a/go.mod b/go.mod index 511270f..8a47873 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( require ( github.com/BurntSushi/toml v1.1.0 // indirect github.com/SporkHubr/echo-http-cache v0.0.0-20200706100054-1d7ae9f38029 + github.com/btcsuite/btcd v0.22.0-beta.0.20211005184431-e3449998be39 github.com/go-openapi/spec v0.20.5 // indirect github.com/go-openapi/swag v0.21.1 // indirect github.com/gorilla/websocket v1.5.0 diff --git a/integration_tests/lnd_mock.go b/integration_tests/lnd_mock.go new file mode 100644 index 0000000..079934a --- /dev/null +++ b/integration_tests/lnd_mock.go @@ -0,0 +1,136 @@ +package integration_tests + +import ( + "context" + "time" + + "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/chaincfg" + "github.com/getAlby/lndhub.go/lnd" + "github.com/lightningnetwork/lnd/lnrpc" + "github.com/lightningnetwork/lnd/lnwire" + "github.com/lightningnetwork/lnd/zpay32" + "google.golang.org/grpc" +) + +type MockLND struct { + Sub *MockSubscribeInvoices + fee int64 + addIndexCounter uint64 +} + +type MockSubscribeInvoices struct { + invoiceChan chan (*lnrpc.Invoice) +} + +func (mockSub *MockSubscribeInvoices) Recv() (*lnrpc.Invoice, error) { + inv := <-mockSub.invoiceChan + return inv, nil +} + +func (mlnd *MockLND) ListChannels(ctx context.Context, req *lnrpc.ListChannelsRequest, options ...grpc.CallOption) (*lnrpc.ListChannelsResponse, error) { + return &lnrpc.ListChannelsResponse{ + Channels: []*lnrpc.Channel{}, + }, nil +} + +func (mlnd *MockLND) SendPaymentSync(ctx context.Context, req *lnrpc.SendRequest, options ...grpc.CallOption) (*lnrpc.SendResponse, error) { + return &lnrpc.SendResponse{ + PaymentError: "", + PaymentPreimage: []byte("preimage"), + PaymentRoute: &lnrpc.Route{ + TotalTimeLock: 0, + TotalFees: mlnd.fee, + TotalAmt: req.Amt + mlnd.fee, + Hops: []*lnrpc.Hop{}, + TotalFeesMsat: 1000 * mlnd.fee, + TotalAmtMsat: 1000 * (req.Amt + mlnd.fee), + }, + PaymentHash: req.PaymentHash, + }, nil +} + +func (mlnd *MockLND) AddInvoice(ctx context.Context, req *lnrpc.Invoice, options ...grpc.CallOption) (*lnrpc.AddInvoiceResponse, error) { + msat := lnwire.MilliSatoshi(req.ValueMsat) + invoice := &zpay32.Invoice{ + Net: &chaincfg.Params{}, + MilliSat: &msat, + Timestamp: time.Now(), + PaymentHash: &[32]byte{}, + PaymentAddr: &[32]byte{}, + Destination: &btcec.PublicKey{}, + Description: new(string), + DescriptionHash: &[32]byte{}, + FallbackAddr: nil, + } + copy(req.RHash, invoice.PaymentHash[:]) + copy(req.PaymentAddr, invoice.PaymentAddr[:]) + copy(req.DescriptionHash, invoice.DescriptionHash[:]) + pr, err := invoice.Encode(zpay32.MessageSigner{ + SignCompact: func(msg []byte) ([]byte, error) { + return []byte{}, nil + }, + }) + if err != nil { + return nil, err + } + mlnd.addIndexCounter += 1 + return &lnrpc.AddInvoiceResponse{ + RHash: req.RHash, + PaymentRequest: pr, + AddIndex: mlnd.addIndexCounter, + PaymentAddr: []byte{}, + }, nil +} + +func (mlnd *MockLND) SubscribeInvoices(ctx context.Context, req *lnrpc.InvoiceSubscription, options ...grpc.CallOption) (lnd.SubscribeInvoicesWrapper, error) { + return mlnd.Sub, nil +} + +func (mlnd *MockLND) GetInfo(ctx context.Context, req *lnrpc.GetInfoRequest, options ...grpc.CallOption) (*lnrpc.GetInfoResponse, error) { + return &lnrpc.GetInfoResponse{ + Version: "v1.0.0", + CommitHash: "abc123", + IdentityPubkey: "123pubkey", + Alias: "Mocky McMockface", + Color: "", + NumPendingChannels: 1, + NumActiveChannels: 10, + NumInactiveChannels: 3, + NumPeers: 10, + BlockHeight: 1000, + BlockHash: "hashhashash", + BestHeaderTimestamp: 123456, + SyncedToChain: true, + SyncedToGraph: true, + Testnet: false, + Chains: []*lnrpc.Chain{{ + Chain: "BTC", + Network: "mainnet", + }}, + Uris: []string{"https://mocky.mcmockface.com"}, + Features: map[uint32]*lnrpc.Feature{}, + }, nil +} + +func (mlnd *MockLND) DecodeBolt11(ctx context.Context, bolt11 string, options ...grpc.CallOption) (*lnrpc.PayReq, error) { + inv, err := zpay32.Decode(bolt11, &chaincfg.MainNetParams) + if err != nil { + return nil, err + } + return &lnrpc.PayReq{ + Destination: string(inv.Destination.SerializeCompressed()), + PaymentHash: string(inv.PaymentHash[:]), + NumSatoshis: int64(*inv.MilliSat) / 1000, + Timestamp: inv.Timestamp.Unix(), + Expiry: int64(inv.Expiry()), + Description: *inv.Description, + DescriptionHash: string(inv.DescriptionHash[:]), + FallbackAddr: inv.FallbackAddr.EncodeAddress(), + CltvExpiry: int64(inv.MinFinalCLTVExpiry()), + RouteHints: []*lnrpc.RouteHint{}, + PaymentAddr: []byte{}, + NumMsat: int64(*inv.MilliSat), + Features: map[uint32]*lnrpc.Feature{}, + }, nil +} From 9574b41a08bc878006da2a072d91cfa5cf49906a Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 11:39:54 +0200 Subject: [PATCH 03/11] working on test refactoring --- integration_tests/checkpayment_test.go | 16 +- integration_tests/gettxs_test.go | 33 ++-- integration_tests/incoming_payment_test.go | 76 ++++------ integration_tests/internal_payment_test.go | 57 ++++--- integration_tests/keysend_test.go | 46 +++--- integration_tests/lnd_mock.go | 141 +++++++++++++----- integration_tests/outgoing_payment_test.go | 1 + .../payment_failure_async_test.go | 44 ++---- integration_tests/payment_failure_test.go | 44 ++---- integration_tests/util.go | 49 +++--- integration_tests/webhook_test.go | 11 +- integration_tests/websocket_test.go | 105 ++++++------- 12 files changed, 299 insertions(+), 324 deletions(-) diff --git a/integration_tests/checkpayment_test.go b/integration_tests/checkpayment_test.go index a0d8051..5a52f3b 100644 --- a/integration_tests/checkpayment_test.go +++ b/integration_tests/checkpayment_test.go @@ -15,7 +15,6 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" "github.com/lightningnetwork/lnd/lnrpc" @@ -25,7 +24,6 @@ import ( type CheckPaymentTestSuite struct { TestSuite - fundingClient *lnd.LNDWrapper service *service.LndhubService userLogin ExpectedCreateUserResponseBody userToken string @@ -33,15 +31,6 @@ type CheckPaymentTestSuite struct { } func (suite *CheckPaymentTestSuite) SetupSuite() { - lndClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd2RegtestAddress, - MacaroonHex: lnd2RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) - } - suite.fundingClient = lndClient - svc, err := LndHubTestServiceInit(nil) if err != nil { log.Fatalf("Error initializing test service: %v", err) @@ -85,12 +74,11 @@ func (suite *CheckPaymentTestSuite) TestCheckPaymentNotFound() { func (suite *CheckPaymentTestSuite) TestCheckPaymentProperIsPaidResponse() { // create incoming invoice and fund account invoice := suite.createAddInvoiceReq(1000, "integration test check payments for user", suite.userToken) - sendPaymentRequest := lnrpc.SendRequest{ + //TODO fund + _ = lnrpc.SendRequest{ PaymentRequest: invoice.PayReq, FeeLimit: nil, } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) // wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) diff --git a/integration_tests/gettxs_test.go b/integration_tests/gettxs_test.go index ead6a8b..a1ac771 100644 --- a/integration_tests/gettxs_test.go +++ b/integration_tests/gettxs_test.go @@ -15,7 +15,6 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" "github.com/lightningnetwork/lnd/lnrpc" @@ -26,23 +25,21 @@ import ( type GetTxTestSuite struct { TestSuite Service *service.LndhubService - fundingClient *lnd.LNDWrapper userLogin ExpectedCreateUserResponseBody userToken string + mockLND *MockLND invoiceUpdateSubCancelFn context.CancelFunc } func (suite *GetTxTestSuite) SetupSuite() { - lndClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd2RegtestAddress, - MacaroonHex: lnd2RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) + mockLND := &MockLND{ + Sub: &MockSubscribeInvoices{ + invoiceChan: make(chan (*lnrpc.Invoice)), + }, + fee: 0, + addIndexCounter: 0, } - suite.fundingClient = lndClient - - svc, err := LndHubTestServiceInit(nil) + svc, err := LndHubTestServiceInit(mockLND) if err != nil { log.Fatalf("Error initializing test service: %v", err) } @@ -56,6 +53,7 @@ func (suite *GetTxTestSuite) SetupSuite() { suite.invoiceUpdateSubCancelFn = cancel go svc.InvoiceUpdateSubscription(ctx) suite.Service = svc + suite.mockLND = mockLND e := echo.New() e.HTTPErrorHandler = responses.HTTPErrorHandler @@ -88,17 +86,14 @@ func (suite *GetTxTestSuite) TestGetOutgoingInvoices() { assert.Equal(suite.T(), http.StatusOK, rec.Code) assert.NoError(suite.T(), json.NewDecoder(rec.Body).Decode(&responseBody)) assert.Empty(suite.T(), responseBody) - // create incoming invoice and fund account + // fund account invoice := suite.createAddInvoiceReq(1000, "integration test internal payment alice", suite.userToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoice.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + err := suite.mockLND.mockPaidInvoice(invoice) assert.NoError(suite.T(), err) - //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + //wait for a short time to allow the payment to be processed asynchronously + time.Sleep(10 * time.Millisecond) + // create invoice invoice = suite.createAddInvoiceReq(500, "integration test internal payment alice", suite.userToken) // pay invoice, this will create outgoing invoice and settle it diff --git a/integration_tests/incoming_payment_test.go b/integration_tests/incoming_payment_test.go index 66e0727..3b4496a 100644 --- a/integration_tests/incoming_payment_test.go +++ b/integration_tests/incoming_payment_test.go @@ -5,7 +5,6 @@ import ( "context" "crypto/rand" "crypto/sha256" - "encoding/hex" "encoding/json" "fmt" "log" @@ -20,18 +19,15 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" "github.com/labstack/gommon/random" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) type IncomingPaymentTestSuite struct { TestSuite - fundingClient *lnd.LNDWrapper service *service.LndhubService userLogin ExpectedCreateUserResponseBody userToken string @@ -39,15 +35,6 @@ type IncomingPaymentTestSuite struct { } func (suite *IncomingPaymentTestSuite) SetupSuite() { - lndClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd2RegtestAddress, - MacaroonHex: lnd2RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) - } - suite.fundingClient = lndClient - svc, err := LndHubTestServiceInit(nil) if err != nil { log.Fatalf("Error initializing test service: %v", err) @@ -92,15 +79,16 @@ func (suite *IncomingPaymentTestSuite) TestIncomingPayment() { //assert the user has no balance to start with assert.Equal(suite.T(), int64(0), balance.BTC.AvailableBalance) fundingSatAmt := 10 - invoiceResponse := suite.createAddInvoiceReq(fundingSatAmt, "integration test IncomingPaymentTestSuite", suite.userToken) + //TODO fund + //invoiceResponse := suite.createAddInvoiceReq(fundingSatAmt, "integration test IncomingPaymentTestSuite", suite.userToken) //try to pay invoice with external node // Prepare the LNRPC call - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) @@ -129,18 +117,19 @@ func (suite *IncomingPaymentTestSuite) TestIncomingPaymentZeroAmt() { assert.Equal(suite.T(), http.StatusOK, rec.Code) assert.NoError(suite.T(), json.NewDecoder(rec.Body).Decode(&balance)) initialBalance := balance.BTC.AvailableBalance - fundingSatAmt := 0 + //fundingSatAmt := 0 sendSatAmt := 10 - invoiceResponse := suite.createAddInvoiceReq(fundingSatAmt, "integration test IncomingPaymentTestSuite", suite.userToken) + //todo fund + //invoiceResponse := suite.createAddInvoiceReq(fundingSatAmt, "integration test IncomingPaymentTestSuite", suite.userToken) //try to pay invoice with external node // Prepare the LNRPC call - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - Amt: int64(sendSatAmt), - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // Amt: int64(sendSatAmt), + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) @@ -175,21 +164,20 @@ func (suite *IncomingPaymentTestSuite) TestIncomingPaymentKeysend() { preImage, err := randBytesFromStr(32, random.Hex) assert.NoError(suite.T(), err) pHash.Write(preImage) - destBytes, err := hex.DecodeString(suite.service.IdentityPubkey) - assert.NoError(suite.T(), err) - sendPaymentRequest := lnrpc.SendRequest{ - Dest: destBytes, - Amt: int64(keysendSatAmt), - PaymentHash: pHash.Sum(nil), - DestFeatures: []lnrpc.FeatureBit{lnrpc.FeatureBit_TLV_ONION_REQ}, - DestCustomRecords: map[uint64][]byte{ - service.TLV_WALLET_ID: []byte(suite.userLogin.Login), - service.KEYSEND_CUSTOM_RECORD: preImage, - }, - FeeLimit: nil, - } - _, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //todo fund + //jsendPaymentRequest := lnrpc.SendRequest{ + //j Dest: destBytes, + //j Amt: int64(keysendSatAmt), + //j PaymentHash: pHash.Sum(nil), + //j DestFeatures: []lnrpc.FeatureBit{lnrpc.FeatureBit_TLV_ONION_REQ}, + //j DestCustomRecords: map[uint64][]byte{ + //j service.TLV_WALLET_ID: []byte(suite.userLogin.Login), + //j service.KEYSEND_CUSTOM_RECORD: preImage, + //j }, + //j FeeLimit: nil, + //j} + //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) diff --git a/integration_tests/internal_payment_test.go b/integration_tests/internal_payment_test.go index c0fe93e..303de33 100644 --- a/integration_tests/internal_payment_test.go +++ b/integration_tests/internal_payment_test.go @@ -20,7 +20,6 @@ import ( "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -37,15 +36,6 @@ type PaymentTestSuite struct { } func (suite *PaymentTestSuite) SetupSuite() { - lndClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd3RegtestAddress, - MacaroonHex: lnd3RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) - } - suite.fundingClient = lndClient - svc, err := LndHubTestServiceInit(nil) if err != nil { log.Fatalf("Error initializing test service: %v", err) @@ -93,14 +83,15 @@ func (suite *PaymentTestSuite) TestInternalPayment() { bobSatRequested := 500 // currently fee is 0 for internal payments fee := 0 + //todo fund //fund alice account - invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) @@ -145,13 +136,14 @@ func (suite *PaymentTestSuite) TestInternalPaymentFail() { // currently fee is 0 for internal payments fee := 0 //fund alice account - invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //todo + //invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) @@ -199,17 +191,18 @@ func (suite *PaymentTestSuite) TestInternalPaymentFail() { assert.Equal(suite.T(), int64(aliceFundingSats)-int64(bobSatRequested+fee), int64(aliceBalance)) } func (suite *PaymentTestSuite) TestInternalPaymentKeysend() { - aliceFundingSats := 1000 + //aliceFundingSats := 1000 bobAmt := 100 memo := "integration test internal keysend from alice" + //todo //fund alice account - invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal keysend alice", suite.aliceToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal keysend alice", suite.aliceToken) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) diff --git a/integration_tests/keysend_test.go b/integration_tests/keysend_test.go index 150dad0..5f60d46 100644 --- a/integration_tests/keysend_test.go +++ b/integration_tests/keysend_test.go @@ -12,17 +12,14 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) type KeySendTestSuite struct { TestSuite - fundingClient *lnd.LNDWrapper service *service.LndhubService aliceLogin ExpectedCreateUserResponseBody aliceToken string @@ -30,14 +27,6 @@ type KeySendTestSuite struct { } func (suite *KeySendTestSuite) SetupSuite() { - lndClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd2RegtestAddress, - MacaroonHex: lnd2RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) - } - suite.fundingClient = lndClient svc, err := LndHubTestServiceInit(nil) if err != nil { @@ -84,18 +73,20 @@ func (suite *KeySendTestSuite) TestKeysendPayment() { // 1 sat + 1 ppm fee := 1 //fund alice account - invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //todo + // invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) + // sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // FeeLimit: nil, + // } + // _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + // assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) - suite.createKeySendReq(int64(externalSatRequested), "key send test", simnetLnd3PubKey, suite.aliceToken) + //todo + //suite.createKeySendReq(int64(externalSatRequested), "key send test", simnetLnd3PubKey, suite.aliceToken) // check that balance was reduced userId := getUserIdFromToken(suite.aliceToken) @@ -107,16 +98,17 @@ func (suite *KeySendTestSuite) TestKeysendPayment() { } func (suite *KeySendTestSuite) TestKeysendPaymentNonExistentDestination() { - aliceFundingSats := 1000 + //aliceFundingSats := 1000 externalSatRequested := 500 //fund alice account - invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //todo + //invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) diff --git a/integration_tests/lnd_mock.go b/integration_tests/lnd_mock.go index 079934a..448c199 100644 --- a/integration_tests/lnd_mock.go +++ b/integration_tests/lnd_mock.go @@ -2,6 +2,10 @@ package integration_tests import ( "context" + "crypto/ecdsa" + "crypto/sha256" + "encoding/hex" + "math/big" "time" "github.com/btcsuite/btcd/btcec" @@ -23,6 +27,31 @@ type MockSubscribeInvoices struct { invoiceChan chan (*lnrpc.Invoice) } +const privkey = "0123456789abcdef" + +func getPubkey() ecdsa.PublicKey { + privKeyBytes, _ := hex.DecodeString(privkey) + x, y := btcec.S256().ScalarBaseMult(privKeyBytes) + return ecdsa.PublicKey{ + Curve: btcec.S256(), + X: x, + Y: y, + } +} + +func signMsg(msg []byte) ([]byte, error) { + privKeyBytes, err := hex.DecodeString(privkey) + if err != nil { + return nil, err + } + ecdsaPrivKey := &ecdsa.PrivateKey{ + PublicKey: getPubkey(), + D: new(big.Int).SetBytes(privKeyBytes), + } + return btcec.SignCompact(btcec.S256(), (*btcec.PrivateKey)(ecdsaPrivKey), + msg, true) +} + func (mockSub *MockSubscribeInvoices) Recv() (*lnrpc.Invoice, error) { inv := <-mockSub.invoiceChan return inv, nil @@ -51,38 +80,76 @@ func (mlnd *MockLND) SendPaymentSync(ctx context.Context, req *lnrpc.SendRequest } func (mlnd *MockLND) AddInvoice(ctx context.Context, req *lnrpc.Invoice, options ...grpc.CallOption) (*lnrpc.AddInvoiceResponse, error) { - msat := lnwire.MilliSatoshi(req.ValueMsat) + pHash := sha256.New() + pHash.Write(req.RPreimage) + pHash.Sum(nil) + msat := lnwire.MilliSatoshi(1000 * req.Value) invoice := &zpay32.Invoice{ - Net: &chaincfg.Params{}, - MilliSat: &msat, - Timestamp: time.Now(), - PaymentHash: &[32]byte{}, - PaymentAddr: &[32]byte{}, - Destination: &btcec.PublicKey{}, - Description: new(string), - DescriptionHash: &[32]byte{}, - FallbackAddr: nil, - } - copy(req.RHash, invoice.PaymentHash[:]) - copy(req.PaymentAddr, invoice.PaymentAddr[:]) - copy(req.DescriptionHash, invoice.DescriptionHash[:]) - pr, err := invoice.Encode(zpay32.MessageSigner{ - SignCompact: func(msg []byte) ([]byte, error) { - return []byte{}, nil + Net: &chaincfg.RegressionNetParams, + MilliSat: &msat, + Timestamp: time.Now(), + PaymentHash: &[32]byte{}, + PaymentAddr: &[32]byte{}, + Features: &lnwire.FeatureVector{ + RawFeatureVector: &lnwire.RawFeatureVector{}, }, + FallbackAddr: nil, + } + copy(invoice.PaymentHash[:], pHash.Sum(nil)) + copy(invoice.PaymentAddr[:], req.PaymentAddr) + if len(req.DescriptionHash) != 0 { + invoice.DescriptionHash = &[32]byte{} + copy(req.DescriptionHash, invoice.DescriptionHash[:]) + } + if req.Memo != "" { + invoice.Description = &req.Memo + } + pr, err := invoice.Encode(zpay32.MessageSigner{ + SignCompact: signMsg, }) if err != nil { return nil, err } mlnd.addIndexCounter += 1 return &lnrpc.AddInvoiceResponse{ - RHash: req.RHash, + RHash: invoice.PaymentHash[:], PaymentRequest: pr, AddIndex: mlnd.addIndexCounter, - PaymentAddr: []byte{}, }, nil } +func (mlnd *MockLND) mockPaidInvoice(added *ExpectedAddInvoiceResponseBody) error { + inv, err := mlnd.DecodeBolt11(context.Background(), added.PayReq) + if err != nil { + return err + } + rhash, err := hex.DecodeString(added.RHash) + if err != nil { + return err + } + mlnd.Sub.invoiceChan <- &lnrpc.Invoice{ + Memo: inv.Description, + RPreimage: []byte("123preimage"), + RHash: rhash, + Value: inv.NumSatoshis, + ValueMsat: inv.NumMsat, + Settled: true, + CreationDate: time.Now().Unix(), + SettleDate: time.Now().Unix(), + PaymentRequest: added.PayReq, + DescriptionHash: []byte(inv.DescriptionHash), + FallbackAddr: inv.FallbackAddr, + CltvExpiry: uint64(inv.CltvExpiry), + AmtPaid: inv.NumSatoshis, + AmtPaidSat: inv.NumSatoshis, + AmtPaidMsat: inv.NumMsat, + State: lnrpc.Invoice_SETTLED, + Htlcs: []*lnrpc.InvoiceHTLC{}, + IsKeysend: false, + } + return nil +} + func (mlnd *MockLND) SubscribeInvoices(ctx context.Context, req *lnrpc.InvoiceSubscription, options ...grpc.CallOption) (lnd.SubscribeInvoicesWrapper, error) { return mlnd.Sub, nil } @@ -106,7 +173,7 @@ func (mlnd *MockLND) GetInfo(ctx context.Context, req *lnrpc.GetInfoRequest, opt Testnet: false, Chains: []*lnrpc.Chain{{ Chain: "BTC", - Network: "mainnet", + Network: "regtest", }}, Uris: []string{"https://mocky.mcmockface.com"}, Features: map[uint32]*lnrpc.Feature{}, @@ -114,23 +181,25 @@ func (mlnd *MockLND) GetInfo(ctx context.Context, req *lnrpc.GetInfoRequest, opt } func (mlnd *MockLND) DecodeBolt11(ctx context.Context, bolt11 string, options ...grpc.CallOption) (*lnrpc.PayReq, error) { - inv, err := zpay32.Decode(bolt11, &chaincfg.MainNetParams) + inv, err := zpay32.Decode(bolt11, &chaincfg.RegressionNetParams) if err != nil { return nil, err } - return &lnrpc.PayReq{ - Destination: string(inv.Destination.SerializeCompressed()), - PaymentHash: string(inv.PaymentHash[:]), - NumSatoshis: int64(*inv.MilliSat) / 1000, - Timestamp: inv.Timestamp.Unix(), - Expiry: int64(inv.Expiry()), - Description: *inv.Description, - DescriptionHash: string(inv.DescriptionHash[:]), - FallbackAddr: inv.FallbackAddr.EncodeAddress(), - CltvExpiry: int64(inv.MinFinalCLTVExpiry()), - RouteHints: []*lnrpc.RouteHint{}, - PaymentAddr: []byte{}, - NumMsat: int64(*inv.MilliSat), - Features: map[uint32]*lnrpc.Feature{}, - }, nil + result := &lnrpc.PayReq{ + Destination: string(inv.Destination.SerializeCompressed()), + PaymentHash: string(inv.PaymentHash[:]), + NumSatoshis: int64(*inv.MilliSat) / 1000, + Timestamp: inv.Timestamp.Unix(), + Expiry: int64(inv.Expiry()), + Description: *inv.Description, + CltvExpiry: int64(inv.MinFinalCLTVExpiry()), + RouteHints: []*lnrpc.RouteHint{}, + PaymentAddr: []byte{}, + NumMsat: int64(*inv.MilliSat), + Features: map[uint32]*lnrpc.Feature{}, + } + if inv.DescriptionHash != nil { + result.DescriptionHash = string(inv.DescriptionHash[:]) + } + return result, nil } diff --git a/integration_tests/outgoing_payment_test.go b/integration_tests/outgoing_payment_test.go index bbc98c8..73810d3 100644 --- a/integration_tests/outgoing_payment_test.go +++ b/integration_tests/outgoing_payment_test.go @@ -15,6 +15,7 @@ import ( func (suite *PaymentTestSuite) TestOutGoingPayment() { aliceFundingSats := 1000 + //todo externalSatRequested := 500 // 1 sat + 1 ppm fee := 1 diff --git a/integration_tests/payment_failure_async_test.go b/integration_tests/payment_failure_async_test.go index d88a825..d684e7f 100644 --- a/integration_tests/payment_failure_async_test.go +++ b/integration_tests/payment_failure_async_test.go @@ -16,14 +16,12 @@ import ( "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) type PaymentTestAsyncErrorsSuite struct { TestSuite - fundingClient *lnd.LNDWrapper service *service.LndhubService userLogin ExpectedCreateUserResponseBody userToken string @@ -32,25 +30,15 @@ type PaymentTestAsyncErrorsSuite struct { } func (suite *PaymentTestAsyncErrorsSuite) SetupSuite() { - // use real client for funding only - fundingClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd2RegtestAddress, - MacaroonHex: lnd2RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) - } - // inject fake lnd client with failing send payment sync into service lndClient, err := NewLNDMockWrapperAsync(lnd.LNDoptions{ - Address: lnd1RegtestAddress, - MacaroonHex: lnd1RegtestMacaroonHex, + Address: mockLNDAddress, + MacaroonHex: mockLNDMacaroonHex, }) suite.serviceClient = lndClient if err != nil { log.Fatalf("Error setting up test client: %v", err) } - suite.fundingClient = fundingClient svc, err := LndHubTestServiceInit(lndClient) if err != nil { @@ -85,26 +73,26 @@ func (suite *PaymentTestAsyncErrorsSuite) TestExternalAsyncFailingInvoice() { userFundingSats := 1000 externalSatRequested := 500 // fund user account - invoiceResponse := suite.createAddInvoiceReq(userFundingSats, "integration test external payment user", suite.userToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //invoiceResponse := suite.createAddInvoiceReq(userFundingSats, "integration test external payment user", suite.userToken) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) // wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) // create external invoice - externalInvoice := lnrpc.Invoice{ - Memo: "integration tests: external pay from user", - Value: int64(externalSatRequested), - } - invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - assert.NoError(suite.T(), err) + //externalInvoice := lnrpc.Invoice{ + // Memo: "integration tests: external pay from user", + // Value: int64(externalSatRequested), + //} + //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) + //assert.NoError(suite.T(), err) // pay external from user, req will be canceled after 2 sec - go suite.createPayInvoiceReqWithCancel(invoice.PaymentRequest, suite.userToken) + //go suite.createPayInvoiceReqWithCancel(invoice.PaymentRequest, suite.userToken) // wait for request to fail time.Sleep(5 * time.Second) diff --git a/integration_tests/payment_failure_test.go b/integration_tests/payment_failure_test.go index c66734c..f599149 100644 --- a/integration_tests/payment_failure_test.go +++ b/integration_tests/payment_failure_test.go @@ -16,14 +16,12 @@ import ( "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) type PaymentTestErrorsSuite struct { TestSuite - fundingClient *lnd.LNDWrapper service *service.LndhubService userLogin ExpectedCreateUserResponseBody userToken string @@ -31,24 +29,14 @@ type PaymentTestErrorsSuite struct { } func (suite *PaymentTestErrorsSuite) SetupSuite() { - // use real client for funding only - fundingClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd2RegtestAddress, - MacaroonHex: lnd2RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) - } - // inject fake lnd client with failing send payment sync into service lndClient, err := NewLNDMockWrapper(lnd.LNDoptions{ - Address: lnd1RegtestAddress, - MacaroonHex: lnd1RegtestMacaroonHex, + Address: mockLNDAddress, + MacaroonHex: mockLNDMacaroonHex, }) if err != nil { log.Fatalf("Error setting up test client: %v", err) } - suite.fundingClient = fundingClient svc, err := LndHubTestServiceInit(lndClient) if err != nil { @@ -83,26 +71,26 @@ func (suite *PaymentTestErrorsSuite) TestExternalFailingInvoice() { userFundingSats := 1000 externalSatRequested := 500 //fund user account - invoiceResponse := suite.createAddInvoiceReq(userFundingSats, "integration test external payment user", suite.userToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //invoiceResponse := suite.createAddInvoiceReq(userFundingSats, "integration test external payment user", suite.userToken) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoiceResponse.PayReq, + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) //create external invoice - externalInvoice := lnrpc.Invoice{ - Memo: "integration tests: external pay from user", - Value: int64(externalSatRequested), - } - invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - assert.NoError(suite.T(), err) + //externalInvoice := lnrpc.Invoice{ + // Memo: "integration tests: external pay from user", + // Value: int64(externalSatRequested), + //} + //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) + //assert.NoError(suite.T(), err) //pay external from user, mock will fail immediately - _ = suite.createPayInvoiceReqError(invoice.PaymentRequest, suite.userToken) + //_ = suite.createPayInvoiceReqError(invoice.PaymentRequest, suite.userToken) userId := getUserIdFromToken(suite.userToken) diff --git a/integration_tests/util.go b/integration_tests/util.go index b28b835..096fe1a 100644 --- a/integration_tests/util.go +++ b/integration_tests/util.go @@ -23,18 +23,24 @@ import ( "github.com/uptrace/bun/migrate" ) +//not used anymore +// const ( +// lnd1RegtestAddress = "rpc.lnd1.regtest.getalby.com:443" +// lnd1RegtestMacaroonHex = "0201036c6e6402f801030a10e2133a1cac2c5b4d56e44e32dc64c8551201301a160a0761646472657373120472656164120577726974651a130a04696e666f120472656164120577726974651a170a08696e766f69636573120472656164120577726974651a210a086d616361726f6f6e120867656e6572617465120472656164120577726974651a160a076d657373616765120472656164120577726974651a170a086f6666636861696e120472656164120577726974651a160a076f6e636861696e120472656164120577726974651a140a057065657273120472656164120577726974651a180a067369676e6572120867656e657261746512047265616400000620c4f9783e0873fa50a2091806f5ebb919c5dc432e33800b401463ada6485df0ed" +// lnd2RegtestAddress = "rpc.lnd2.regtest.getalby.com:443" +// lnd2RegtestMacaroonHex = "0201036C6E6402F801030A101782922F4358E80655920FC7A7C3E9291201301A160A0761646472657373120472656164120577726974651A130A04696E666F120472656164120577726974651A170A08696E766F69636573120472656164120577726974651A210A086D616361726F6F6E120867656E6572617465120472656164120577726974651A160A076D657373616765120472656164120577726974651A170A086F6666636861696E120472656164120577726974651A160A076F6E636861696E120472656164120577726974651A140A057065657273120472656164120577726974651A180A067369676E6572120867656E657261746512047265616400000620628FFB2938C8540DD3AA5E578D9B43456835FAA176E175FFD4F9FBAE540E3BE9" +// // Use lnd3 for a funding client when testing out fee handling for payments done by lnd-1, since lnd3 doesn't have a direct channel to lnd1. +// // This will cause payment to be routed through lnd2, which will charge a fee (lnd default fee 1 sat base + 1 ppm). +// lnd3RegtestAddress = "rpc.lnd3.regtest.getalby.com:443" +// lnd3RegtestMacaroonHex = "0201036c6e6402f801030a102a5aa69a5efdf4b4a55a5304b164641f1201301a160a0761646472657373120472656164120577726974651a130a04696e666f120472656164120577726974651a170a08696e766f69636573120472656164120577726974651a210a086d616361726f6f6e120867656e6572617465120472656164120577726974651a160a076d657373616765120472656164120577726974651a170a086f6666636861696e120472656164120577726974651a160a076f6e636861696e120472656164120577726974651a140a057065657273120472656164120577726974651a180a067369676e6572120867656e657261746512047265616400000620defbb5a809262297fd661a9ab6d3deb4b7acca4f1309c79addb952f0dc2d8c82" +// simnetLnd1PubKey = "0242898f86064c2fd72de22059c947a83ba23e9d97aedeae7b6dba647123f1d71b" +// simnetLnd2PubKey = "025c1d5d1b4c983cc6350fc2d756fbb59b4dc365e45e87f8e3afe07e24013e8220" +// simnetLnd3PubKey = "03c7092d076f799ab18806743634b4c9bb34e351bdebc91d5b35963f3dc63ec5aa" +// ) + const ( - lnd1RegtestAddress = "rpc.lnd1.regtest.getalby.com:443" - lnd1RegtestMacaroonHex = "0201036c6e6402f801030a10e2133a1cac2c5b4d56e44e32dc64c8551201301a160a0761646472657373120472656164120577726974651a130a04696e666f120472656164120577726974651a170a08696e766f69636573120472656164120577726974651a210a086d616361726f6f6e120867656e6572617465120472656164120577726974651a160a076d657373616765120472656164120577726974651a170a086f6666636861696e120472656164120577726974651a160a076f6e636861696e120472656164120577726974651a140a057065657273120472656164120577726974651a180a067369676e6572120867656e657261746512047265616400000620c4f9783e0873fa50a2091806f5ebb919c5dc432e33800b401463ada6485df0ed" - lnd2RegtestAddress = "rpc.lnd2.regtest.getalby.com:443" - lnd2RegtestMacaroonHex = "0201036C6E6402F801030A101782922F4358E80655920FC7A7C3E9291201301A160A0761646472657373120472656164120577726974651A130A04696E666F120472656164120577726974651A170A08696E766F69636573120472656164120577726974651A210A086D616361726F6F6E120867656E6572617465120472656164120577726974651A160A076D657373616765120472656164120577726974651A170A086F6666636861696E120472656164120577726974651A160A076F6E636861696E120472656164120577726974651A140A057065657273120472656164120577726974651A180A067369676E6572120867656E657261746512047265616400000620628FFB2938C8540DD3AA5E578D9B43456835FAA176E175FFD4F9FBAE540E3BE9" - // Use lnd3 for a funding client when testing out fee handling for payments done by lnd-1, since lnd3 doesn't have a direct channel to lnd1. - // This will cause payment to be routed through lnd2, which will charge a fee (lnd default fee 1 sat base + 1 ppm). - lnd3RegtestAddress = "rpc.lnd3.regtest.getalby.com:443" - lnd3RegtestMacaroonHex = "0201036c6e6402f801030a102a5aa69a5efdf4b4a55a5304b164641f1201301a160a0761646472657373120472656164120577726974651a130a04696e666f120472656164120577726974651a170a08696e766f69636573120472656164120577726974651a210a086d616361726f6f6e120867656e6572617465120472656164120577726974651a160a076d657373616765120472656164120577726974651a170a086f6666636861696e120472656164120577726974651a160a076f6e636861696e120472656164120577726974651a140a057065657273120472656164120577726974651a180a067369676e6572120867656e657261746512047265616400000620defbb5a809262297fd661a9ab6d3deb4b7acca4f1309c79addb952f0dc2d8c82" - simnetLnd1PubKey = "0242898f86064c2fd72de22059c947a83ba23e9d97aedeae7b6dba647123f1d71b" - simnetLnd2PubKey = "025c1d5d1b4c983cc6350fc2d756fbb59b4dc365e45e87f8e3afe07e24013e8220" - simnetLnd3PubKey = "03c7092d076f799ab18806743634b4c9bb34e351bdebc91d5b35963f3dc63ec5aa" + mockLNDAddress = "mock.lnd.local" + mockLNDMacaroonHex = "omnomnom" ) func LndHubTestServiceInit(lndClientMock lnd.LightningClientWrapper) (svc *service.LndhubService, err error) { @@ -47,8 +53,8 @@ func LndHubTestServiceInit(lndClientMock lnd.LightningClientWrapper) (svc *servi JWTSecret: []byte("SECRET"), JWTAccessTokenExpiry: 3600, JWTRefreshTokenExpiry: 3600, - LNDAddress: lnd1RegtestAddress, - LNDMacaroonHex: lnd1RegtestMacaroonHex, + LNDAddress: mockLNDAddress, + LNDMacaroonHex: mockLNDMacaroonHex, } dbConn, err := db.Open(c.DatabaseUri) if err != nil { @@ -66,27 +72,14 @@ func LndHubTestServiceInit(lndClientMock lnd.LightningClientWrapper) (svc *servi return nil, fmt.Errorf("failed to migrate: %w", err) } - var lndClient lnd.LightningClientWrapper - if lndClientMock == nil { - lndClient, err = lnd.NewLNDclient(lnd.LNDoptions{ - Address: c.LNDAddress, - MacaroonHex: c.LNDMacaroonHex, - }) - if err != nil { - return nil, fmt.Errorf("failed to initialize lnd service client: %w", err) - } - } else { - lndClient = lndClientMock - } - logger := lib.Logger(c.LogFilePath) svc = &service.LndhubService{ Config: c, DB: dbConn, - LndClient: lndClient, + LndClient: lndClientMock, Logger: logger, } - getInfo, err := lndClient.GetInfo(ctx, &lnrpc.GetInfoRequest{}) + getInfo, err := lndClientMock.GetInfo(ctx, &lnrpc.GetInfoRequest{}) if err != nil { logger.Fatalf("Error getting node info: %v", err) } diff --git a/integration_tests/webhook_test.go b/integration_tests/webhook_test.go index b1c21df..237d513 100644 --- a/integration_tests/webhook_test.go +++ b/integration_tests/webhook_test.go @@ -35,19 +35,10 @@ type WebHookTestSuite struct { } func (suite *WebHookTestSuite) SetupSuite() { - lndClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd2RegtestAddress, - MacaroonHex: lnd2RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) - } - suite.fundingClient = lndClient - suite.invoiceChan = make(chan models.Invoice) webhookServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { invoice := models.Invoice{} - err = json.NewDecoder(r.Body).Decode(&invoice) + err := json.NewDecoder(r.Body).Decode(&invoice) if err != nil { suite.echo.Logger.Error(err) close(suite.invoiceChan) diff --git a/integration_tests/websocket_test.go b/integration_tests/websocket_test.go index 910a264..f34c782 100644 --- a/integration_tests/websocket_test.go +++ b/integration_tests/websocket_test.go @@ -15,11 +15,9 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/gorilla/websocket" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -30,7 +28,6 @@ type KeepAlive struct { type WebSocketTestSuite struct { TestSuite - fundingClient *lnd.LNDWrapper service *service.LndhubService userLogin ExpectedCreateUserResponseBody userToken string @@ -55,14 +52,6 @@ func (h *WsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (suite *WebSocketTestSuite) SetupSuite() { - lndClient, err := lnd.NewLNDclient(lnd.LNDoptions{ - Address: lnd2RegtestAddress, - MacaroonHex: lnd2RegtestMacaroonHex, - }) - if err != nil { - log.Fatalf("Error setting up funding client: %v", err) - } - suite.fundingClient = lndClient svc, err := LndHubTestServiceInit(nil) if err != nil { @@ -111,13 +100,13 @@ func (suite *WebSocketTestSuite) TestWebSocket() { assert.Equal(suite.T(), "keepalive", keepAlive.Type) // create incoming invoice and fund account - invoice := suite.createAddInvoiceReq(1000, "integration test websocket 1", suite.userToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoice.PayReq, - FeeLimit: nil, - } - _, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //invoice := suite.createAddInvoiceReq(1000, "integration test websocket 1", suite.userToken) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoice.PayReq, + // FeeLimit: nil, + //} + //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) _, msg, err = ws.ReadMessage() assert.NoError(suite.T(), err) @@ -142,12 +131,12 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubeSubscription() { //read keepalive msg _, _, err = ws2.ReadMessage() assert.NoError(suite.T(), err) - invoice := suite.createAddInvoiceReq(1000, "integration test websocket 2", suite.userToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoice.PayReq, - FeeLimit: nil, - } - _, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //invoice := suite.createAddInvoiceReq(1000, "integration test websocket 2", suite.userToken) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoice.PayReq, + // FeeLimit: nil, + //} + //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) assert.NoError(suite.T(), err) _, msg1, err := ws1.ReadMessage() assert.NoError(suite.T(), err) @@ -164,12 +153,12 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubeSubscription() { assert.Equal(suite.T(), "integration test websocket 2", event2.Invoice.Description) //close 1 subscription, assert that the existing sub still receives their invoices ws1.Close() - invoice = suite.createAddInvoiceReq(1000, "integration test websocket 3", suite.userToken) - sendPaymentRequest = lnrpc.SendRequest{ - PaymentRequest: invoice.PayReq, - FeeLimit: nil, - } - _, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //invoice = suite.createAddInvoiceReq(1000, "integration test websocket 3", suite.userToken) + //sendPaymentRequest = lnrpc.SendRequest{ + // PaymentRequest: invoice.PayReq, + // FeeLimit: nil, + //} + //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) assert.NoError(suite.T(), err) _, msg3, err := ws2.ReadMessage() assert.NoError(suite.T(), err) @@ -194,21 +183,21 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubleUser() { _, _, err = user2Ws.ReadMessage() assert.NoError(suite.T(), err) // add invoice for user 1 - user1Invoice := suite.createAddInvoiceReq(1000, "integration test websocket user 1", suite.userToken) - sendPaymentRequestUser1 := lnrpc.SendRequest{ - PaymentRequest: user1Invoice.PayReq, - FeeLimit: nil, - } - // add invoice for user 2 - user2Invoice := suite.createAddInvoiceReq(1000, "integration test websocket user 2", suite.userToken2) - sendPaymentRequestUser2 := lnrpc.SendRequest{ - PaymentRequest: user2Invoice.PayReq, - FeeLimit: nil, - } + //user1Invoice := suite.createAddInvoiceReq(1000, "integration test websocket user 1", suite.userToken) + //sendPaymentRequestUser1 := lnrpc.SendRequest{ + // PaymentRequest: user1Invoice.PayReq, + // FeeLimit: nil, + //} + //// add invoice for user 2 + //user2Invoice := suite.createAddInvoiceReq(1000, "integration test websocket user 2", suite.userToken2) + //sendPaymentRequestUser2 := lnrpc.SendRequest{ + // PaymentRequest: user2Invoice.PayReq, + // FeeLimit: nil, + //} //pay invoices - _, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequestUser1) - assert.NoError(suite.T(), err) - _, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequestUser2) + //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequestUser1) + //assert.NoError(suite.T(), err) + //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequestUser2) assert.NoError(suite.T(), err) //read user 1 received msg _, user1Msg, err := user1Ws.ReadMessage() @@ -231,21 +220,21 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubleUser() { func (suite *WebSocketTestSuite) TestWebSocketMissingInvoice() { // create incoming invoice and fund account invoice1 := suite.createAddInvoiceReq(1000, "integration test websocket missing invoices", suite.userToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoice1.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //sendPaymentRequest := lnrpc.SendRequest{ + // PaymentRequest: invoice1.PayReq, + // FeeLimit: nil, + //} + //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) - // create 2nd invoice and pay it as well - invoice2 := suite.createAddInvoiceReq(1000, "integration test websocket missing invoices 2nd", suite.userToken) - sendPaymentRequest = lnrpc.SendRequest{ - PaymentRequest: invoice2.PayReq, - FeeLimit: nil, - } - _, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - assert.NoError(suite.T(), err) + //// create 2nd invoice and pay it as well + //invoice2 := suite.createAddInvoiceReq(1000, "integration test websocket missing invoices 2nd", suite.userToken) + //sendPaymentRequest = lnrpc.SendRequest{ + // PaymentRequest: invoice2.PayReq, + // FeeLimit: nil, + //} + //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + //assert.NoError(suite.T(), err) //start listening to websocket after 2nd invoice has been paid //we should get an event for the 2nd invoice if we specify the hash as the query parameter From 12d5f1a345c7a8154ba78129df94604b7c7fb086 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 14:58:05 +0200 Subject: [PATCH 04/11] fixed incoming payment test --- integration_tests/gettxs_test.go | 11 +- integration_tests/incoming_payment_test.go | 85 ++++------- integration_tests/lnd_mock.go | 158 ++++++++++++++------- 3 files changed, 139 insertions(+), 115 deletions(-) diff --git a/integration_tests/gettxs_test.go b/integration_tests/gettxs_test.go index a1ac771..563d561 100644 --- a/integration_tests/gettxs_test.go +++ b/integration_tests/gettxs_test.go @@ -32,12 +32,9 @@ type GetTxTestSuite struct { } func (suite *GetTxTestSuite) SetupSuite() { - mockLND := &MockLND{ - Sub: &MockSubscribeInvoices{ - invoiceChan: make(chan (*lnrpc.Invoice)), - }, - fee: 0, - addIndexCounter: 0, + mockLND, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) } svc, err := LndHubTestServiceInit(mockLND) if err != nil { @@ -88,7 +85,7 @@ func (suite *GetTxTestSuite) TestGetOutgoingInvoices() { assert.Empty(suite.T(), responseBody) // fund account invoice := suite.createAddInvoiceReq(1000, "integration test internal payment alice", suite.userToken) - err := suite.mockLND.mockPaidInvoice(invoice) + err := suite.mockLND.mockPaidInvoice(invoice, 0, false, nil) assert.NoError(suite.T(), err) //wait for a short time to allow the payment to be processed asynchronously diff --git a/integration_tests/incoming_payment_test.go b/integration_tests/incoming_payment_test.go index 3b4496a..e11bbe7 100644 --- a/integration_tests/incoming_payment_test.go +++ b/integration_tests/incoming_payment_test.go @@ -3,12 +3,10 @@ package integration_tests import ( "bytes" "context" - "crypto/rand" "crypto/sha256" "encoding/json" "fmt" "log" - "math/big" "net/http" "net/http/httptest" "testing" @@ -22,6 +20,7 @@ import ( "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" "github.com/labstack/gommon/random" + "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -29,13 +28,19 @@ import ( type IncomingPaymentTestSuite struct { TestSuite service *service.LndhubService + mockLND *MockLND userLogin ExpectedCreateUserResponseBody userToken string invoiceUpdateSubCancelFn context.CancelFunc } func (suite *IncomingPaymentTestSuite) SetupSuite() { - svc, err := LndHubTestServiceInit(nil) + mockLND, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + suite.mockLND = mockLND + svc, err := LndHubTestServiceInit(mockLND) if err != nil { log.Fatalf("Error initializing test service: %v", err) } @@ -79,19 +84,11 @@ func (suite *IncomingPaymentTestSuite) TestIncomingPayment() { //assert the user has no balance to start with assert.Equal(suite.T(), int64(0), balance.BTC.AvailableBalance) fundingSatAmt := 10 - //TODO fund - //invoiceResponse := suite.createAddInvoiceReq(fundingSatAmt, "integration test IncomingPaymentTestSuite", suite.userToken) - //try to pay invoice with external node - // Prepare the LNRPC call - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) - - //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + invoiceResponse := suite.createAddInvoiceReq(fundingSatAmt, "integration test IncomingPaymentTestSuite", suite.userToken) + err := suite.mockLND.mockPaidInvoice(invoiceResponse, 0, false, nil) + assert.NoError(suite.T(), err) + //wait a bit for the payment to be processed + time.Sleep(10 * time.Millisecond) //check balance again req = httptest.NewRequest(http.MethodGet, "/balance", &buf) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", suite.userToken)) @@ -117,22 +114,14 @@ func (suite *IncomingPaymentTestSuite) TestIncomingPaymentZeroAmt() { assert.Equal(suite.T(), http.StatusOK, rec.Code) assert.NoError(suite.T(), json.NewDecoder(rec.Body).Decode(&balance)) initialBalance := balance.BTC.AvailableBalance - //fundingSatAmt := 0 + fundingSatAmt := 0 sendSatAmt := 10 - //todo fund - //invoiceResponse := suite.createAddInvoiceReq(fundingSatAmt, "integration test IncomingPaymentTestSuite", suite.userToken) - //try to pay invoice with external node - // Prepare the LNRPC call - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // Amt: int64(sendSatAmt), - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) - + invoiceResponse := suite.createAddInvoiceReq(fundingSatAmt, "integration test IncomingPaymentTestSuite", suite.userToken) + err := suite.mockLND.mockPaidInvoice(invoiceResponse, int64(sendSatAmt), false, nil) + assert.NoError(suite.T(), err) //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) + //check balance again req = httptest.NewRequest(http.MethodGet, "/balance", &buf) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", suite.userToken)) @@ -164,23 +153,16 @@ func (suite *IncomingPaymentTestSuite) TestIncomingPaymentKeysend() { preImage, err := randBytesFromStr(32, random.Hex) assert.NoError(suite.T(), err) pHash.Write(preImage) - //todo fund - //jsendPaymentRequest := lnrpc.SendRequest{ - //j Dest: destBytes, - //j Amt: int64(keysendSatAmt), - //j PaymentHash: pHash.Sum(nil), - //j DestFeatures: []lnrpc.FeatureBit{lnrpc.FeatureBit_TLV_ONION_REQ}, - //j DestCustomRecords: map[uint64][]byte{ - //j service.TLV_WALLET_ID: []byte(suite.userLogin.Login), - //j service.KEYSEND_CUSTOM_RECORD: preImage, - //j }, - //j FeeLimit: nil, - //j} - //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + err = suite.mockLND.mockPaidInvoice(nil, int64(keysendSatAmt), true, &lnrpc.InvoiceHTLC{ + CustomRecords: map[uint64][]byte{ + service.TLV_WALLET_ID: []byte(suite.userLogin.Login), + service.KEYSEND_CUSTOM_RECORD: preImage, + }, + }) + assert.NoError(suite.T(), err) //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) //check balance again req = httptest.NewRequest(http.MethodGet, "/balance", &buf) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", suite.userToken)) @@ -214,19 +196,6 @@ func (suite *IncomingPaymentTestSuite) TestIncomingPaymentKeysend() { assert.Equal(suite.T(), suite.userLogin.Login, string(login)) } -func randBytesFromStr(length int, from string) ([]byte, error) { - b := make([]byte, length) - fromLenBigInt := big.NewInt(int64(len(from))) - for i := range b { - r, err := rand.Int(rand.Reader, fromLenBigInt) - if err != nil { - return nil, err - } - b[i] = from[r.Int64()] - } - return b, nil -} - func TestIncomingPaymentTestSuite(t *testing.T) { suite.Run(t, new(IncomingPaymentTestSuite)) } diff --git a/integration_tests/lnd_mock.go b/integration_tests/lnd_mock.go index 448c199..2866e48 100644 --- a/integration_tests/lnd_mock.go +++ b/integration_tests/lnd_mock.go @@ -2,7 +2,7 @@ package integration_tests import ( "context" - "crypto/ecdsa" + "crypto/rand" "crypto/sha256" "encoding/hex" "math/big" @@ -11,6 +11,7 @@ import ( "github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/chaincfg" "github.com/getAlby/lndhub.go/lnd" + "github.com/labstack/gommon/random" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/zpay32" @@ -20,38 +21,46 @@ import ( type MockLND struct { Sub *MockSubscribeInvoices fee int64 + privKey *btcec.PrivateKey + pubKey *btcec.PublicKey addIndexCounter uint64 } -type MockSubscribeInvoices struct { - invoiceChan chan (*lnrpc.Invoice) -} - -const privkey = "0123456789abcdef" - -func getPubkey() ecdsa.PublicKey { - privKeyBytes, _ := hex.DecodeString(privkey) - x, y := btcec.S256().ScalarBaseMult(privKeyBytes) - return ecdsa.PublicKey{ - Curve: btcec.S256(), - X: x, - Y: y, - } -} - -func signMsg(msg []byte) ([]byte, error) { +func NewMockLND(privkey string, fee int64, invoiceChan chan (*lnrpc.Invoice)) (*MockLND, error) { privKeyBytes, err := hex.DecodeString(privkey) if err != nil { return nil, err } - ecdsaPrivKey := &ecdsa.PrivateKey{ - PublicKey: getPubkey(), + x, y := btcec.S256().ScalarBaseMult(privKeyBytes) + pubKey := &btcec.PublicKey{ + Curve: btcec.S256(), + X: x, + Y: y, + } + privKey := &btcec.PrivateKey{ + PublicKey: *pubKey.ToECDSA(), D: new(big.Int).SetBytes(privKeyBytes), } - return btcec.SignCompact(btcec.S256(), (*btcec.PrivateKey)(ecdsaPrivKey), + return &MockLND{ + Sub: &MockSubscribeInvoices{ + invoiceChan: invoiceChan, + }, + fee: fee, + privKey: privKey, + pubKey: pubKey, + addIndexCounter: 0, + }, nil +} + +func (mlnd *MockLND) signMsg(msg []byte) ([]byte, error) { + return btcec.SignCompact(btcec.S256(), mlnd.privKey, msg, true) } +type MockSubscribeInvoices struct { + invoiceChan chan (*lnrpc.Invoice) +} + func (mockSub *MockSubscribeInvoices) Recv() (*lnrpc.Invoice, error) { inv := <-mockSub.invoiceChan return inv, nil @@ -105,7 +114,7 @@ func (mlnd *MockLND) AddInvoice(ctx context.Context, req *lnrpc.Invoice, options invoice.Description = &req.Memo } pr, err := invoice.Encode(zpay32.MessageSigner{ - SignCompact: signMsg, + SignCompact: mlnd.signMsg, }) if err != nil { return nil, err @@ -118,35 +127,68 @@ func (mlnd *MockLND) AddInvoice(ctx context.Context, req *lnrpc.Invoice, options }, nil } -func (mlnd *MockLND) mockPaidInvoice(added *ExpectedAddInvoiceResponseBody) error { - inv, err := mlnd.DecodeBolt11(context.Background(), added.PayReq) - if err != nil { - return err +func (mlnd *MockLND) mockPaidInvoice(added *ExpectedAddInvoiceResponseBody, amtPaid int64, keysend bool, htlc *lnrpc.InvoiceHTLC) error { + var incoming *lnrpc.Invoice + if !keysend { + rhash, err := hex.DecodeString(added.RHash) + if err != nil { + return err + } + inv, err := mlnd.DecodeBolt11(context.Background(), added.PayReq) + if err != nil { + return err + } + incoming = &lnrpc.Invoice{ + Memo: inv.Description, + RPreimage: []byte("123preimage"), + RHash: rhash, + Value: inv.NumSatoshis, + ValueMsat: inv.NumMsat, + Settled: true, + CreationDate: time.Now().Unix(), + SettleDate: time.Now().Unix(), + PaymentRequest: added.PayReq, + DescriptionHash: []byte(inv.DescriptionHash), + FallbackAddr: inv.FallbackAddr, + CltvExpiry: uint64(inv.CltvExpiry), + AmtPaid: inv.NumSatoshis, + AmtPaidSat: inv.NumSatoshis, + AmtPaidMsat: inv.NumMsat, + State: lnrpc.Invoice_SETTLED, + Htlcs: []*lnrpc.InvoiceHTLC{}, + IsKeysend: keysend, + } + } else { + preimage, err := makePreimageHex() + if err != nil { + return err + } + pHash := sha256.New() + pHash.Write(preimage) + incoming = &lnrpc.Invoice{ + Memo: "", + RPreimage: preimage, + RHash: pHash.Sum(nil), + Value: amtPaid, + ValueMsat: 1000 * amtPaid, + Settled: true, + CreationDate: time.Now().Unix(), + SettleDate: time.Now().Unix(), + PaymentRequest: "", + AmtPaid: amtPaid, + AmtPaidSat: amtPaid, + AmtPaidMsat: 1000 * amtPaid, + State: lnrpc.Invoice_SETTLED, + Htlcs: []*lnrpc.InvoiceHTLC{htlc}, + IsKeysend: keysend, + } } - rhash, err := hex.DecodeString(added.RHash) - if err != nil { - return err - } - mlnd.Sub.invoiceChan <- &lnrpc.Invoice{ - Memo: inv.Description, - RPreimage: []byte("123preimage"), - RHash: rhash, - Value: inv.NumSatoshis, - ValueMsat: inv.NumMsat, - Settled: true, - CreationDate: time.Now().Unix(), - SettleDate: time.Now().Unix(), - PaymentRequest: added.PayReq, - DescriptionHash: []byte(inv.DescriptionHash), - FallbackAddr: inv.FallbackAddr, - CltvExpiry: uint64(inv.CltvExpiry), - AmtPaid: inv.NumSatoshis, - AmtPaidSat: inv.NumSatoshis, - AmtPaidMsat: inv.NumMsat, - State: lnrpc.Invoice_SETTLED, - Htlcs: []*lnrpc.InvoiceHTLC{}, - IsKeysend: false, + + if amtPaid != 0 { + incoming.AmtPaidSat = amtPaid + incoming.AmtPaidMsat = 1000 * amtPaid } + mlnd.Sub.invoiceChan <- incoming return nil } @@ -155,10 +197,11 @@ func (mlnd *MockLND) SubscribeInvoices(ctx context.Context, req *lnrpc.InvoiceSu } func (mlnd *MockLND) GetInfo(ctx context.Context, req *lnrpc.GetInfoRequest, options ...grpc.CallOption) (*lnrpc.GetInfoResponse, error) { + return &lnrpc.GetInfoResponse{ Version: "v1.0.0", CommitHash: "abc123", - IdentityPubkey: "123pubkey", + IdentityPubkey: hex.EncodeToString(mlnd.pubKey.SerializeCompressed()), Alias: "Mocky McMockface", Color: "", NumPendingChannels: 1, @@ -203,3 +246,18 @@ func (mlnd *MockLND) DecodeBolt11(ctx context.Context, bolt11 string, options .. } return result, nil } +func makePreimageHex() ([]byte, error) { + return randBytesFromStr(32, random.Hex) +} +func randBytesFromStr(length int, from string) ([]byte, error) { + b := make([]byte, length) + fromLenBigInt := big.NewInt(int64(len(from))) + for i := range b { + r, err := rand.Int(rand.Reader, fromLenBigInt) + if err != nil { + return nil, err + } + b[i] = from[r.Int64()] + } + return b, nil +} From c680f77798f8b148370b58973b03774a99584e45 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 16:12:04 +0200 Subject: [PATCH 05/11] mock: add destination and proper signing --- go.mod | 8 +- go.sum | 206 ++++++++++++++------- integration_tests/internal_payment_test.go | 26 +-- integration_tests/lnd_mock.go | 25 ++- integration_tests/outgoing_payment_test.go | 91 ++++----- 5 files changed, 207 insertions(+), 149 deletions(-) diff --git a/go.mod b/go.mod index 8a47873..9f58deb 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/labstack/echo/v4 v4.7.2 github.com/labstack/gommon v0.3.1 - github.com/lightningnetwork/lnd v0.14.1-beta - github.com/stretchr/testify v1.7.0 + github.com/lightningnetwork/lnd v0.15.0-beta.rc6 + github.com/stretchr/testify v1.7.1 github.com/uptrace/bun v1.0.21 github.com/uptrace/bun/dialect/pgdialect v1.0.21 github.com/uptrace/bun/dialect/sqlitedialect v1.0.21 @@ -29,7 +29,8 @@ require ( require ( github.com/BurntSushi/toml v1.1.0 // indirect github.com/SporkHubr/echo-http-cache v0.0.0-20200706100054-1d7ae9f38029 - github.com/btcsuite/btcd v0.22.0-beta.0.20211005184431-e3449998be39 + github.com/btcsuite/btcd v0.23.1 + github.com/btcsuite/btcd/btcec/v2 v2.2.0 github.com/go-openapi/spec v0.20.5 // indirect github.com/go-openapi/swag v0.21.1 // indirect github.com/gorilla/websocket v1.5.0 @@ -38,7 +39,6 @@ require ( github.com/swaggo/echo-swagger v1.3.0 github.com/swaggo/swag v1.8.1 golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba golang.org/x/tools v0.1.10 // indirect google.golang.org/genproto v0.0.0-20220114231437-d2e6a121cae0 // indirect diff --git a/go.sum b/go.sum index 5fa0aca..1dcff68 100644 --- a/go.sum +++ b/go.sum @@ -33,7 +33,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -git.schwanenlied.me/yawning/bsaes.git v0.0.0-20180720073208-c0276d75487e/go.mod h1:BWqTsj8PgcPriQJGl7el20J/7TuT1d/hSyFDXMEpoEo= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= @@ -60,7 +59,7 @@ github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/ github.com/SporkHubr/echo-http-cache v0.0.0-20200706100054-1d7ae9f38029 h1:XjAr0qCBlYmF0xb1rAQXg+FENEWQT8CUQd20DQHeAgI= github.com/SporkHubr/echo-http-cache v0.0.0-20200706100054-1d7ae9f38029/go.mod h1:/JdnJQCTSrjBrEmR8UtcAwsCcFMAeq3c25NK9m21YOA= github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= -github.com/Yawning/aez v0.0.0-20180114000226-4dad034d9db2/go.mod h1:9pIqrY6SXNL8vjRQE5Hd/OL5GyK/9MrGUWs87z/eFfk= +github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344/go.mod h1:9pIqrY6SXNL8vjRQE5Hd/OL5GyK/9MrGUWs87z/eFfk= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= @@ -85,7 +84,6 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.0.0/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg= @@ -96,52 +94,56 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.21.0-beta.0.20201208033208-6bd4c64a54fa/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= -github.com/btcsuite/btcd v0.22.0-beta.0.20210803133449-f5a1fb9965e4/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= -github.com/btcsuite/btcd v0.22.0-beta.0.20211005184431-e3449998be39 h1:o6qacOzpKubr16y0RrE2fBauRZN1rDZ1YsE26ixCgQ0= -github.com/btcsuite/btcd v0.22.0-beta.0.20211005184431-e3449998be39/go.mod h1:3PH+KbvLFfzBTCevQenPiDedjGQGt6aa70dVjJDWGTA= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.22.0-beta.0.20220204213055-eaf0459ff879/go.mod h1:osu7EoKiL36UThEgzYPqdRaxeo0NU8VoXqgcnwpey0g= +github.com/btcsuite/btcd v0.22.0-beta.0.20220207191057-4dc4ff7963b4/go.mod h1:7alexyj/lHlOtr2PJK7L/+HDJZpcGDn/pAU98r7DY08= +github.com/btcsuite/btcd v0.22.0-beta.0.20220316175102-8d5c75c28923/go.mod h1:taIcYprAW2g6Z9S0gGUxyR+zDwimyDMK5ePOX+iJ2ds= +github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd v0.23.1 h1:IB8cVQcC2X5mHbnfirLG5IZnkWYNTPlLZVrxUYSotbE= +github.com/btcsuite/btcd v0.23.1/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/btcsuite/btcd/btcec/v2 v2.1.1/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= +github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= +github.com/btcsuite/btcd/btcutil v1.1.1 h1:hDcDaXiP0uEzR8Biqo2weECKqEw0uHDZ9ixIWevVQqY= +github.com/btcsuite/btcd/btcutil v1.1.1/go.mod h1:nbKlBMNm9FGsdvKvu0essceubPiAcI57pYBNnsLAa34= +github.com/btcsuite/btcd/btcutil/psbt v1.1.4 h1:Edx4AfBn+YPam2KP5AobDitulGp4r1Oibm8oruzkMdI= +github.com/btcsuite/btcd/btcutil/psbt v1.1.4/go.mod h1:9AyU6EQVJ9Iw9zPyNT1lcdHd6cnEZdno5wLu5FY74os= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= -github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= -github.com/btcsuite/btcutil v1.0.3-0.20210527170813-e2ba6805a890 h1:9aGy5p7oXRUB4MCTmWm0+jzuh79GpjPIfv1leA5POD4= -github.com/btcsuite/btcutil v1.0.3-0.20210527170813-e2ba6805a890/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= -github.com/btcsuite/btcutil/psbt v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:LVveMu4VaNSkIRTZu2+ut0HDBRuYjqGocxDMNS1KuGQ= -github.com/btcsuite/btcutil/psbt v1.0.3-0.20210527170813-e2ba6805a890 h1:0xUNvvwJ7RjzBs4nCF+YrK28S5P/b4uHkpPxY1ovGY4= -github.com/btcsuite/btcutil/psbt v1.0.3-0.20210527170813-e2ba6805a890/go.mod h1:LVveMu4VaNSkIRTZu2+ut0HDBRuYjqGocxDMNS1KuGQ= -github.com/btcsuite/btcwallet v0.13.0 h1:gtLWwueRm27KQiHJpycybv3uMdK1eo87JexfTfzvEhk= -github.com/btcsuite/btcwallet v0.13.0/go.mod h1:iLN1lG1MW0eREm+SikmPO8AZPz5NglBTEK/ErqkjGpo= -github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU= -github.com/btcsuite/btcwallet/wallet/txauthor v1.1.0 h1:8pO0pvPX1rFRfRiol4oV6kX7dY5y4chPwhfVwUfvwtk= -github.com/btcsuite/btcwallet/wallet/txauthor v1.1.0/go.mod h1:ktYuJyumYtwG+QQ832Q+kqvxWJRAei3Nqs5qhSn4nww= -github.com/btcsuite/btcwallet/wallet/txrules v1.0.0/go.mod h1:UwQE78yCerZ313EXZwEiu3jNAtfXj2n2+c8RWiE/WNA= -github.com/btcsuite/btcwallet/wallet/txrules v1.1.0 h1:Vg8G8zhNVjaCdwJg2QOmLoWn4RTP7K0J9xlwY8CJnLY= -github.com/btcsuite/btcwallet/wallet/txrules v1.1.0/go.mod h1:Zn9UTqpiTH+HOd5BLzSBzULzlOPmcoeyQIA0cp0WbQQ= -github.com/btcsuite/btcwallet/wallet/txsizes v1.0.0/go.mod h1:pauEU8UuMFiThe5PB3EO+gO5kx87Me5NvdQDsTuq6cs= +github.com/btcsuite/btcwallet v0.15.1 h1:SKfh/l2Bgz9sJwHZvfiVbZ8Pl3N/8fFcWWXzsAPz9GU= +github.com/btcsuite/btcwallet v0.15.1/go.mod h1:7OFsQ8ypiRwmr67hE0z98uXgJgXGAihE79jCib9x6ag= +github.com/btcsuite/btcwallet/wallet/txauthor v1.2.3 h1:M2yr5UlULvpqtxUqpMxTME/pA92Z9cpqeyvAFk9lAg0= +github.com/btcsuite/btcwallet/wallet/txauthor v1.2.3/go.mod h1:T2xSiKGpUkSLCh68aF+FMXmKK9mFqNdHl9VaqOr+JjU= +github.com/btcsuite/btcwallet/wallet/txrules v1.2.0 h1:BtEN5Empw62/RVnZ0VcJaVtVlBijnLlJY+dwjAye2Bg= +github.com/btcsuite/btcwallet/wallet/txrules v1.2.0/go.mod h1:AtkqiL7ccKWxuLYtZm8Bu8G6q82w4yIZdgq6riy60z0= github.com/btcsuite/btcwallet/wallet/txsizes v1.1.0 h1:wZnOolEAeNOHzHTnznw/wQv+j35ftCIokNrnOTOU5o8= github.com/btcsuite/btcwallet/wallet/txsizes v1.1.0/go.mod h1:pauEU8UuMFiThe5PB3EO+gO5kx87Me5NvdQDsTuq6cs= -github.com/btcsuite/btcwallet/walletdb v1.3.4/go.mod h1:oJDxAEUHVtnmIIBaa22wSBPTVcs6hUp5NKWmI8xDwwU= github.com/btcsuite/btcwallet/walletdb v1.3.5/go.mod h1:oJDxAEUHVtnmIIBaa22wSBPTVcs6hUp5NKWmI8xDwwU= -github.com/btcsuite/btcwallet/walletdb v1.3.6-0.20210803004036-eebed51155ec h1:zcAU3Ij8SmqaE+ITtS76fua2Niq7DRNp46sJRhi8PiI= github.com/btcsuite/btcwallet/walletdb v1.3.6-0.20210803004036-eebed51155ec/go.mod h1:oJDxAEUHVtnmIIBaa22wSBPTVcs6hUp5NKWmI8xDwwU= -github.com/btcsuite/btcwallet/wtxmgr v1.3.0/go.mod h1:awQsh1n/0ZrEQ+JZgWvHeo153ubzEisf/FyNtwI0dDk= -github.com/btcsuite/btcwallet/wtxmgr v1.3.1-0.20210822222949-9b5a201c344c h1:owWPexGfK4eSK4/Zy+XK2lET5qsnW7FRAc8OCOdD0Fg= -github.com/btcsuite/btcwallet/wtxmgr v1.3.1-0.20210822222949-9b5a201c344c/go.mod h1:UM38ixX8VwJ9qey4umf//0H3ndn5kSImFZ46V54Nd5Q= +github.com/btcsuite/btcwallet/walletdb v1.4.0 h1:/C5JRF+dTuE2CNMCO/or5N8epsrhmSM4710uBQoYPTQ= +github.com/btcsuite/btcwallet/walletdb v1.4.0/go.mod h1:oJDxAEUHVtnmIIBaa22wSBPTVcs6hUp5NKWmI8xDwwU= +github.com/btcsuite/btcwallet/wtxmgr v1.5.0 h1:WO0KyN4l6H3JWnlFxfGR7r3gDnlGT7W2cL8vl6av4SU= +github.com/btcsuite/btcwallet/wtxmgr v1.5.0/go.mod h1:TQVDhFxseiGtZwEPvLgtfyxuNUDsIdaJdshvWzR0HJ4= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8/go.mod h1:tYvUd8KLhm/oXvUeSEs2VlLghFjQt9+ZaF9ghH0JNjc= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0 h1:Tvd0BfvqX9o823q1j2UZ/epQo09eJh6dTcRp79ilIN4= github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0 h1:ZxaA6lo2EpxGddsA8JwWOcxlzRybb444sgmeJQMJGQE= github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/casbin/casbin/v2 v2.40.6/go.mod h1:sEL80qBYTbd+BPeL4iyvwYzFT3qwLaESq5aFKVLbLfA= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -195,6 +197,10 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/lru v1.0.0 h1:Kbsb1SFDsIlaupWPwsPp+dkxiBY1frcS07PCPgotKz8= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= @@ -208,6 +214,8 @@ github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5Jflh github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dvyukov/go-fuzz v0.0.0-20210602112143-b1f3d6f4ef4e h1:qTP1telKJHlToHlwPQNmVg4yfMDMHe4Z3SYmzkrvA2M= +github.com/dvyukov/go-fuzz v0.0.0-20210602112143-b1f3d6f4ef4e/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= @@ -237,6 +245,7 @@ github.com/frankban/quicktest v1.2.2/go.mod h1:Qh/WofXFeiAFII1aEBu529AtJo6Zg2VHs github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs= @@ -259,7 +268,6 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= -github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= @@ -269,7 +277,6 @@ github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXym github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= github.com/go-openapi/spec v0.20.5 h1:skHa8av4VnAtJU5zyAUXrrdK/NDiVX8lchbG+BfcdrE= github.com/go-openapi/spec v0.20.5/go.mod h1:QbfOSIVt3/sac+a1wzmKbbcLXm5NdZnyBZYtCijp43o= -github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU= @@ -368,7 +375,6 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -479,8 +485,9 @@ github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/U github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg= github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc= github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= -github.com/jedib0t/go-pretty v4.3.0+incompatible/go.mod h1:XemHduiw8R651AF9Pt4FwCTKeG3oo7hrHJAoznj9nag= +github.com/jedib0t/go-pretty/v6 v6.2.7/go.mod h1:FMkOpgGD3EZ91cW8g/96RfxoV7bdeJyzXPYgz1L1ln0= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= @@ -502,20 +509,48 @@ github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/juju/ansiterm v0.0.0-20160907234532-b99631de12cf/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU= +github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU= github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c h1:3UvYABOQRhJAApj9MdCN+Ydv841ETSoy6xLzdmmr/9A= github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c/go.mod h1:nD0vlnrUjcjJhqN5WuCWZyzfd5AHZAC9/ajvbSx69xA= -github.com/juju/errors v0.0.0-20190806202954-0232dcc7464d h1:hJXjZMxj0SWlMoQkzeZDLi2cmeiWKa7y1B8Rg+qaoEc= -github.com/juju/errors v0.0.0-20190806202954-0232dcc7464d/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 h1:UUHMLvzt/31azWTN/ifGWef4WUqvXk0iRqdhdy/2uzI= -github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/cmd v0.0.0-20171107070456-e74f39857ca0/go.mod h1:yWJQHl73rdSX4DHVKGqkAip+huBslxRwS8m9CrOLq18= +github.com/juju/collections v0.0.0-20200605021417-0d0ec82b7271 h1:4R626WTwa7pRYQFiIRLVPepMhm05eZMEx+wIurRnMLc= +github.com/juju/collections v0.0.0-20200605021417-0d0ec82b7271/go.mod h1:5XgO71dV1JClcOJE+4dzdn4HrI5LiyKd7PlVG6eZYhY= +github.com/juju/errors v0.0.0-20150916125642-1b5e39b83d18/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/errors v0.0.0-20200330140219-3fe23663418f/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/errors v0.0.0-20220203013757-bd733f3c86b9 h1:EJHbsNpQyupmMeWTq7inn+5L/WZ7JfzCVPJ+DP9McCQ= +github.com/juju/errors v0.0.0-20220203013757-bd733f3c86b9/go.mod h1:TRm7EVGA3mQOqSVcBySRY7a9Y1/gyVhh/WTCnc5sD4U= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/juju/httpprof v0.0.0-20141217160036-14bf14c30767/go.mod h1:+MaLYz4PumRkkyHYeXJ2G5g5cIW0sli2bOfpmbaMV/g= +github.com/juju/loggo v0.0.0-20170605014607-8232ab8918d9/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/loggo v0.0.0-20210728185423-eebad3a902c4 h1:NO5tuyw++EGLnz56Q8KMyDZRwJwWO8jQnj285J3FOmY= +github.com/juju/loggo v0.0.0-20210728185423-eebad3a902c4/go.mod h1:NIXFioti1SmKAlKNuUwbMenNdef59IF52+ZzuOmHYkg= +github.com/juju/mgo/v2 v2.0.0-20210302023703-70d5d206e208 h1:/WiCm+Vpj87e4QWuWwPD/bNE9kDrWCLvPBHOQNcG2+A= +github.com/juju/mgo/v2 v2.0.0-20210302023703-70d5d206e208/go.mod h1:0OChplkvPTZ174D2FYZXg4IB9hbEwyHkD+zT+/eK+Fg= +github.com/juju/mutex v0.0.0-20171110020013-1fe2a4bf0a3a/go.mod h1:Y3oOzHH8CQ0Ppt0oCKJ2JFO81/EsWenH5AEqigLH+yY= +github.com/juju/retry v0.0.0-20151029024821-62c620325291/go.mod h1:OohPQGsr4pnxwD5YljhQ+TZnuVRYpa5irjugL1Yuif4= github.com/juju/retry v0.0.0-20180821225755-9058e192b216 h1:/eQL7EJQKFHByJe3DeE8Z36yqManj9UY5zppDoQi4FU= github.com/juju/retry v0.0.0-20180821225755-9058e192b216/go.mod h1:OohPQGsr4pnxwD5YljhQ+TZnuVRYpa5irjugL1Yuif4= -github.com/juju/testing v0.0.0-20190723135506-ce30eb24acd2 h1:Pp8RxiF4rSoXP9SED26WCfNB28/dwTDpPXS8XMJR8rc= +github.com/juju/testing v0.0.0-20180402130637-44801989f0f7/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/juju/testing v0.0.0-20190723135506-ce30eb24acd2/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= -github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d h1:irPlN9z5VCe6BTsqVsxheCZH99OFSmqSVyTigW4mEoY= -github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d/go.mod h1:6/KLg8Wz/y2KVGWEpkK9vMNGkOnu4k/cqs8Z1fKjTOk= -github.com/juju/version v0.0.0-20180108022336-b64dbd566305 h1:lQxPJ1URr2fjsKnJRt/BxiIxjLt9IKGvS+0injMHbag= +github.com/juju/testing v0.0.0-20210302031854-2c7ee8570c07/go.mod h1:7lxZW0B50+xdGFkvhAb8bwAGt6IU87JB1H9w4t8MNVM= +github.com/juju/testing v0.0.0-20220202055744-1ad0816210a6/go.mod h1:QgWc2UdIPJ8t3rnvv95tFNOsQDfpXYEZDbP281o3b2c= +github.com/juju/testing v0.0.0-20220203020004-a0ff61f03494 h1:XEDzpuZb8Ma7vLja3+5hzUqVTvAqm5Y+ygvnDs5iTMM= +github.com/juju/testing v0.0.0-20220203020004-a0ff61f03494/go.mod h1:rUquetT0ALL48LHZhyRGvjjBH8xZaZ8dFClulKK5wK4= +github.com/juju/utils v0.0.0-20180424094159-2000ea4ff043/go.mod h1:6/KLg8Wz/y2KVGWEpkK9vMNGkOnu4k/cqs8Z1fKjTOk= +github.com/juju/utils v0.0.0-20200116185830-d40c2fe10647 h1:wQpkHVbIIpz1PCcLYku9KFWsJ7aEMQXHBBmLy3tRBTk= +github.com/juju/utils v0.0.0-20200116185830-d40c2fe10647/go.mod h1:6/KLg8Wz/y2KVGWEpkK9vMNGkOnu4k/cqs8Z1fKjTOk= +github.com/juju/utils/v2 v2.0.0-20200923005554-4646bfea2ef1/go.mod h1:fdlDtQlzundleLLz/ggoYinEt/LmnrpNKcNTABQATNI= +github.com/juju/utils/v3 v3.0.0-20220130232349-cd7ecef0e94a h1:5ZWDCeCF0RaITrZGemzmDFIhjR/MVSvBUqgSyaeTMbE= +github.com/juju/utils/v3 v3.0.0-20220130232349-cd7ecef0e94a/go.mod h1:LzwbbEN7buYjySp4nqnti6c6olSqRXUk6RkbSUUP1n8= +github.com/juju/version v0.0.0-20161031051906-1f41e27e54f2/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/juju/version v0.0.0-20180108022336-b64dbd566305/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= +github.com/juju/version v0.0.0-20191219164919-81c1be00b9a6 h1:nrqc9b4YKpKV4lPI3GPPFbo5FUuxkWxgZE2Z8O4lgaw= +github.com/juju/version v0.0.0-20191219164919-81c1be00b9a6/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= +github.com/juju/version/v2 v2.0.0-20211007103408-2e8da085dc23 h1:wtEPbidt1VyHlb8RSztU6ySQj29FLsOQiI9XiJhXDM4= +github.com/juju/version/v2 v2.0.0-20211007103408-2e8da085dc23/go.mod h1:Ljlbryh9sYaUSGXucslAEDf0A2XUSGvDbHJgW8ps6nc= +github.com/julienschmidt/httprouter v1.1.1-0.20151013225520-77a895ad01eb/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= @@ -584,32 +619,38 @@ github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg= github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI/f/O0Avg7t8sqkPo78HFzjmeYFl6DPnc= github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk= -github.com/lightninglabs/neutrino v0.12.1/go.mod h1:GlKninWpRBbL7b8G0oQ36/8downfnFwKsr0hbRA6E/E= -github.com/lightninglabs/neutrino v0.13.0 h1:j3PKWEJCwqwMn/qLASz2j0IuCF6AumS9DaM0i0pM/nY= -github.com/lightninglabs/neutrino v0.13.0/go.mod h1:GlKninWpRBbL7b8G0oQ36/8downfnFwKsr0hbRA6E/E= +github.com/lightninglabs/neutrino v0.14.2 h1:yrnZUCYMZ5ECtXhgDrzqPq2oX8awoAN2D/cgCewJcCo= +github.com/lightninglabs/neutrino v0.14.2/go.mod h1:OICUeTCn+4Tu27YRJIpWvvqySxx4oH4vgdP33Sw9RDc= github.com/lightninglabs/protobuf-hex-display v1.4.3-hex-display/go.mod h1:2oKOBU042GKFHrdbgGiKax4xVrFiZu51lhacUZQ9MnE= -github.com/lightningnetwork/lightning-onion v1.0.2-0.20210520211913-522b799e65b1 h1:h1BsjPzWea790mAXISoiT/qr0JRcixTCDNLmjsDThSw= -github.com/lightningnetwork/lightning-onion v1.0.2-0.20210520211913-522b799e65b1/go.mod h1:rigfi6Af/KqsF7Za0hOgcyq2PNH4AN70AaMRxcJkff4= -github.com/lightningnetwork/lnd v0.14.1-beta h1:v9hOlJ1xYivYQ634Nt71up5QDh8mXVpYh4MXUbbWTRw= -github.com/lightningnetwork/lnd v0.14.1-beta/go.mod h1:o7zDwjZXm/bPP48qjwsqnZvvITyQl+fUv6UVoV4o+J8= -github.com/lightningnetwork/lnd/cert v1.1.0/go.mod h1:3MWXVLLPI0Mg0XETm9fT4N9Vyy/8qQLmaM5589bEggM= +github.com/lightningnetwork/lightning-onion v1.0.2-0.20220211021909-bb84a1ccb0c5 h1:TkKwqFcQTGYoI+VEqyxA8rxpCin8qDaYX0AfVRinT3k= +github.com/lightningnetwork/lightning-onion v1.0.2-0.20220211021909-bb84a1ccb0c5/go.mod h1:7dDx73ApjEZA0kcknI799m2O5kkpfg4/gr7N092ojNo= +github.com/lightningnetwork/lnd v0.15.0-beta.rc6 h1:CY+vmWgfJcdRpDSrklwq+TYFx9JhLMy6CANOPdaKA3o= +github.com/lightningnetwork/lnd v0.15.0-beta.rc6/go.mod h1:Tm7LZrYeR2JQH1gEOKmd0NTCgjJ1Bnujkx4lcz9b5+A= +github.com/lightningnetwork/lnd/cert v1.1.1/go.mod h1:1P46svkkd73oSoeI4zjkVKgZNwGq8bkGuPR8z+5vQUs= github.com/lightningnetwork/lnd/clock v1.0.1/go.mod h1:KnQudQ6w0IAMZi1SgvecLZQZ43ra2vpDNj7H/aasemg= github.com/lightningnetwork/lnd/clock v1.1.0 h1:/yfVAwtPmdx45aQBoXQImeY7sOIEr7IXlImRMBOZ7GQ= github.com/lightningnetwork/lnd/clock v1.1.0/go.mod h1:KnQudQ6w0IAMZi1SgvecLZQZ43ra2vpDNj7H/aasemg= github.com/lightningnetwork/lnd/healthcheck v1.0.0/go.mod h1:u92p1JGFJNMSkMvztKEwmt1P3TRnLeJBXZ3M85xkU1E= -github.com/lightningnetwork/lnd/healthcheck v1.2.0 h1:00bkNn+hGJM9j3Ht+ulf8YNcSx1HEYSDv5pf4HB1/uQ= -github.com/lightningnetwork/lnd/healthcheck v1.2.0/go.mod h1:WSz3lsUjErJQZ3gb+zW32nM3WIHNiZ3A40GVoaQY5wU= -github.com/lightningnetwork/lnd/kvdb v1.2.1 h1:QevYLPh6bh1SLIvlUaPbrpX/YMKzSPBfmGVvn2i8IlU= -github.com/lightningnetwork/lnd/kvdb v1.2.1/go.mod h1:x+IpsuDynubjokUofavLXroeGfS/WrqUXXTK6vN/gp4= +github.com/lightningnetwork/lnd/healthcheck v1.2.2 h1:im+qcpgSuteqRCGeorT9yqVXuLrS6A7/acYzGgarMS4= +github.com/lightningnetwork/lnd/healthcheck v1.2.2/go.mod h1:IWY0GChlarRbXFkFDdE4WY5POYJabe/7/H1iCZt4ZKs= +github.com/lightningnetwork/lnd/kvdb v1.3.1 h1:gEz3zudNNRrCLEvqRaktYoKwsUblyHX+MKjR0aI3QnM= +github.com/lightningnetwork/lnd/kvdb v1.3.1/go.mod h1:x+IpsuDynubjokUofavLXroeGfS/WrqUXXTK6vN/gp4= github.com/lightningnetwork/lnd/queue v1.0.1/go.mod h1:vaQwexir73flPW43Mrm7JOgJHmcEFBWWSl9HlyASoms= github.com/lightningnetwork/lnd/queue v1.1.0 h1:YpCJjlIvVxN/R7ww2aNiY8ex7U2fucZDLJ67tI3HFx8= github.com/lightningnetwork/lnd/queue v1.1.0/go.mod h1:YTkTVZCxz8tAYreH27EO3s8572ODumWrNdYW2E/YKxg= github.com/lightningnetwork/lnd/ticker v1.0.0/go.mod h1:iaLXJiVgI1sPANIF2qYYUJXjoksPNvGNYowB8aRbpX0= github.com/lightningnetwork/lnd/ticker v1.1.0 h1:ShoBiRP3pIxZHaETndfQ5kEe+S4NdAY1hiX7YbZ4QE4= github.com/lightningnetwork/lnd/ticker v1.1.0/go.mod h1:ubqbSVCn6RlE0LazXuBr7/Zi6QT0uQo++OgIRBxQUrk= +github.com/lightningnetwork/lnd/tlv v1.0.2/go.mod h1:fICAfsqk1IOsC1J7G9IdsWX1EqWRMqEDCNxZJSKr9C4= +github.com/lightningnetwork/lnd/tlv v1.0.3 h1:0xBZcPuXagP6f7TY/RnLNR4igE21ov6qUdTr5NyvhhI= +github.com/lightningnetwork/lnd/tlv v1.0.3/go.mod h1:dzR/aZetBri+ZY/fHbwV06fNn/3UID6htQzbHfREFdo= +github.com/lightningnetwork/lnd/tor v1.0.0/go.mod h1:RDtaAdwfAm+ONuPYwUhNIH1RAvKPv+75lHPOegUcz64= +github.com/lightningnetwork/lnd/tor v1.0.1 h1:A11FrpU0Y//g+fA827W4VnjOeoIvExONdchlLX8wYkA= +github.com/lightningnetwork/lnd/tor v1.0.1/go.mod h1:RDtaAdwfAm+ONuPYwUhNIH1RAvKPv+75lHPOegUcz64= github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 h1:sjOGyegMIhvgfq5oaue6Td+hxZuf3tDC8lAPrFldqFw= github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796/go.mod h1:3p7ZTf9V1sNPI5H8P3NkTFF4LuwMdPl2DodF60qAKqY= github.com/ltcsuite/ltcutil v0.0.0-20181217130922-17f3b04680b6/go.mod h1:8Vg/LTOO0KYa/vlHWJ6XZAevPQThGH5sufO0Hrou/lA= +github.com/lunixbochs/vtclean v0.0.0-20160125035106-4fbf7632a2c6/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -617,6 +658,11 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/masterzen/azure-sdk-for-go v3.2.0-beta.0.20161014135628-ee4f0065d00c+incompatible/go.mod h1:mf8fjOu33zCqxUjuiU3I8S1lJMyEAlH+0F2+M5xl3hE= +github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc= +github.com/masterzen/winrm v0.0.0-20161014151040-7a535cd943fc/go.mod h1:CfZSN7zwz5gJiFhZJz49Uzk7mEBHIceWmbFmYx7Hf7E= +github.com/masterzen/xmlpath v0.0.0-20140218185901-13f4951698ad/go.mod h1:A0zPC53iKKKcXYxr4ROjpQRQ5FgJXtelNdSmHHuq/tY= +github.com/mattn/go-colorable v0.0.6/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -628,6 +674,7 @@ github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -637,7 +684,7 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk= github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -674,10 +721,12 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/nwaples/rardecode v1.1.2 h1:Cj0yZY6T1Zx1R7AhTbyGSALm44/Mmq+BAPc4B/p/d3M= github.com/nwaples/rardecode v1.1.2/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -685,13 +734,16 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c= github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -717,6 +769,7 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -749,6 +802,7 @@ github.com/rabbitmq/amqp091-go v1.1.0/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0V github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -808,8 +862,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/swaggo/echo-swagger v1.3.0 h1:xxL/4jbCY4Z3udUvqOas+IpTMKbxrKdEKwtS7He0Qhg= github.com/swaggo/echo-swagger v1.3.0/go.mod h1:snY6MlGK+pQAfJNEfX5qaOzt/QuM/WINVxGgQaZVJgg= @@ -818,7 +873,8 @@ github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2/go.mod h1:lKJPbtWzJ9J github.com/swaggo/swag v1.7.9/go.mod h1:gZ+TJ2w/Ve1RwQsA2IRoSOTidHz6DX+PIG8GWvbnoLU= github.com/swaggo/swag v1.8.1 h1:JuARzFX1Z1njbCGz+ZytBR15TFJwF2Q7fu8puJHhQYI= github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -847,7 +903,7 @@ github.com/uptrace/bun/driver/sqliteshim v1.0.21 h1:9cBMi0TosIeomB+N35mXk1Dh8cSK github.com/uptrace/bun/driver/sqliteshim v1.0.21/go.mod h1:xXz8OSqmYnRtxbEktkTjpmEZy7YDroVnX0RVpEs+5zE= github.com/uptrace/bun/extra/bundebug v1.0.21 h1:ILYJLqhx97I9WM+GbCYnF1QjNN63gpI2fvoj04atf8s= github.com/uptrace/bun/extra/bundebug v1.0.21/go.mod h1:n/2QqdhgXrLHDOYqezHmJzBNKf/2NNjE5xMi2fZ38iY= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -894,6 +950,7 @@ github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= github.com/ziflex/lecho/v3 v3.1.0 h1:65bSzSc0yw7EEhi44lMnkOI877ZzbE7tGDWfYCQXZwI= github.com/ziflex/lecho/v3 v3.1.0/go.mod h1:dwQ6xCAKmSBHhwZ6XmiAiDptD7iklVkW7xQYGUncX0Q= +gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec/go.mod h1:BZ1RAoRPbCxum9Grlv5aeksu2H8BiKehBYooU2LFiOQ= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5-0.20200615073812-232d8fc87f50/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= @@ -912,7 +969,6 @@ go.etcd.io/etcd/raft/v3 v3.5.0 h1:kw2TmO3yFTgE+F0mdKkG7xMxkit2duBDa2Hu6D/HMlw= go.etcd.io/etcd/raft/v3 v3.5.0/go.mod h1:UFOHSIvO/nKwd4lhkwabrTD3cqW5yVyYYf/KlD00Szc= go.etcd.io/etcd/server/v3 v3.5.0 h1:jk8D/lwGEDlQU9kZXUFMSANkE22Sg5+mW27ip8xcF9E= go.etcd.io/etcd/server/v3 v3.5.0/go.mod h1:3Ah5ruV+M+7RZr0+Y/5mNLwC+eQlni+mQmOVdCRJoS4= -go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -965,6 +1021,7 @@ go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/arch v0.0.0-20190909030613-46d78d1859ac/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20180214000028-650f4a345ab4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -979,10 +1036,9 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= @@ -1009,6 +1065,7 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1035,8 +1092,10 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1076,7 +1135,9 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -1113,6 +1174,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1121,7 +1183,6 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1134,6 +1195,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1156,10 +1218,12 @@ golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1180,7 +1244,6 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210915083310-ed5796bab164/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1188,8 +1251,8 @@ golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= @@ -1274,6 +1337,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= @@ -1387,17 +1451,20 @@ google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+Rur google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v1 v1.0.0-20161222125816-442357a80af5/go.mod h1:u0ALmqvLRxLI95fkdCEWrE6mhWYZW1aMOJHp5YXLHTg= gopkg.in/errgo.v1 v1.0.1 h1:oQFRXzZ7CkBGdm1XZm/EbQYaYNNEElNBOd09M6cqNso= gopkg.in/errgo.v1 v1.0.1/go.mod h1:3NjfXwocQRYAPTq4/fzX+CwUhPRcR/azYRhj8G+LqMo= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= +gopkg.in/httprequest.v1 v1.1.1/go.mod h1:/CkavNL+g3qLOrpFHVrEx4NKepeqR4XTZWNj4sGGjz0= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -1406,13 +1473,16 @@ gopkg.in/macaroon-bakery.v2 v2.0.1/go.mod h1:B4/T17l+ZWGwxFSZQmlBwp25x+og7OkhETf gopkg.in/macaroon.v2 v2.0.0/go.mod h1:+I6LnTMkm/uV5ew/0nsulNjL16SK4+C8yDmRUzHR17I= gopkg.in/macaroon.v2 v2.1.0 h1:HZcsjBCzq9t0eBPMKqTN/uSN6JOm78ZJ2INbqcBQOUI= gopkg.in/macaroon.v2 v2.1.0/go.mod h1:OUb+TQP/OP0WOerC2Jp/3CwhIKyIa9kQjuc7H24e6/o= +gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637/go.mod h1:BHsqpu/nsuzkT5BpiH1EMZPLyqSMM8JbIavyFACoFNk= +gopkg.in/yaml.v2 v2.0.0-20170712054546-1be3d31502d6/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1437,6 +1507,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= +launchpad.net/xmlpath v0.0.0-20130614043138-000000000004/go.mod h1:vqyExLOM3qBx7mvYRkoxjSCF945s0mbe7YynlKYXtsA= lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w= diff --git a/integration_tests/internal_payment_test.go b/integration_tests/internal_payment_test.go index 303de33..a750014 100644 --- a/integration_tests/internal_payment_test.go +++ b/integration_tests/internal_payment_test.go @@ -17,16 +17,16 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" + "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) type PaymentTestSuite struct { TestSuite - fundingClient *lnd.LNDWrapper + mlnd *MockLND service *service.LndhubService aliceLogin ExpectedCreateUserResponseBody aliceToken string @@ -36,7 +36,12 @@ type PaymentTestSuite struct { } func (suite *PaymentTestSuite) SetupSuite() { - svc, err := LndHubTestServiceInit(nil) + mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + suite.mlnd = mlnd + svc, err := LndHubTestServiceInit(mlnd) if err != nil { log.Fatalf("Error initializing test service: %v", err) } @@ -83,18 +88,13 @@ func (suite *PaymentTestSuite) TestInternalPayment() { bobSatRequested := 500 // currently fee is 0 for internal payments fee := 0 - //todo fund //fund alice account - //invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) + assert.NoError(suite.T(), err) - //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + //wait a bit for the payment to be processed + time.Sleep(10 * time.Millisecond) //create invoice for bob bobInvoice := suite.createAddInvoiceReq(bobSatRequested, "integration test internal payment bob", suite.bobToken) diff --git a/integration_tests/lnd_mock.go b/integration_tests/lnd_mock.go index 2866e48..e26a1a0 100644 --- a/integration_tests/lnd_mock.go +++ b/integration_tests/lnd_mock.go @@ -8,7 +8,8 @@ import ( "math/big" "time" - "github.com/btcsuite/btcd/btcec" + btcec "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/btcsuite/btcd/chaincfg" "github.com/getAlby/lndhub.go/lnd" "github.com/labstack/gommon/random" @@ -31,16 +32,7 @@ func NewMockLND(privkey string, fee int64, invoiceChan chan (*lnrpc.Invoice)) (* if err != nil { return nil, err } - x, y := btcec.S256().ScalarBaseMult(privKeyBytes) - pubKey := &btcec.PublicKey{ - Curve: btcec.S256(), - X: x, - Y: y, - } - privKey := &btcec.PrivateKey{ - PublicKey: *pubKey.ToECDSA(), - D: new(big.Int).SetBytes(privKeyBytes), - } + privKey, pubKey := btcec.PrivKeyFromBytes(privKeyBytes) return &MockLND{ Sub: &MockSubscribeInvoices{ invoiceChan: invoiceChan, @@ -52,9 +44,16 @@ func NewMockLND(privkey string, fee int64, invoiceChan chan (*lnrpc.Invoice)) (* }, nil } +// DoubleHashB calculates hash(hash(b)) and returns the resulting bytes. +func DoubleHashB(b []byte) []byte { + first := sha256.Sum256(b) + second := sha256.Sum256(first[:]) + return second[:] +} + func (mlnd *MockLND) signMsg(msg []byte) ([]byte, error) { - return btcec.SignCompact(btcec.S256(), mlnd.privKey, - msg, true) + hash := DoubleHashB(msg) + return ecdsa.SignCompact(mlnd.privKey, hash, true) } type MockSubscribeInvoices struct { diff --git a/integration_tests/outgoing_payment_test.go b/integration_tests/outgoing_payment_test.go index 73810d3..eea092d 100644 --- a/integration_tests/outgoing_payment_test.go +++ b/integration_tests/outgoing_payment_test.go @@ -9,7 +9,6 @@ import ( "time" "github.com/getAlby/lndhub.go/common" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" ) @@ -21,28 +20,24 @@ func (suite *PaymentTestSuite) TestOutGoingPayment() { fee := 1 //fund alice account invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) //create external invoice - externalInvoice := lnrpc.Invoice{ - Memo: "integration tests: external pay from alice", - Value: int64(externalSatRequested), - } - invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - assert.NoError(suite.T(), err) - //pay external from alice - payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ - Invoice: invoice.PaymentRequest, - }, suite.aliceToken) - assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) + //externalInvoice := lnrpc.Invoice{ + // Memo: "integration tests: external pay from alice", + // Value: int64(externalSatRequested), + //} + //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) + //assert.NoError(suite.T(), err) + ////pay external from alice + //payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ + // Invoice: invoice.PaymentRequest, + //}, suite.aliceToken) + //assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) // check that balance was reduced userId := getUserIdFromToken(suite.aliceToken) @@ -110,28 +105,24 @@ func (suite *PaymentTestSuite) TestOutGoingPaymentWithNegativeBalance() { fee := 1 //fund alice account invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) //create external invoice - externalInvoice := lnrpc.Invoice{ - Memo: "integration tests: external pay from alice", - Value: int64(externalSatRequested), - } - invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - assert.NoError(suite.T(), err) - //pay external from alice - payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ - Invoice: invoice.PaymentRequest, - }, suite.aliceToken) - assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) + //externalInvoice := lnrpc.Invoice{ + // Memo: "integration tests: external pay from alice", + // Value: int64(externalSatRequested), + //} + //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) + //assert.NoError(suite.T(), err) + ////pay external from alice + //payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ + // Invoice: invoice.PaymentRequest, + //}, suite.aliceToken) + //assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) // check that balance was reduced userId := getUserIdFromToken(suite.aliceToken) @@ -184,31 +175,27 @@ func (suite *PaymentTestSuite) TestOutGoingPaymentWithNegativeBalance() { func (suite *PaymentTestSuite) TestZeroAmountInvoice() { aliceFundingSats := 1000 - amtToPay := 1000 + //amtToPay := 1000 //fund alice account invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test zero amount payment alice", suite.aliceToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoiceResponse.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) //create external invoice - externalInvoice := lnrpc.Invoice{ - Memo: "integration tests: zero amount pay from alice", - Value: 0, - } - invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - assert.NoError(suite.T(), err) - //pay external from alice - payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ - Invoice: invoice.PaymentRequest, - Amount: amtToPay, - }, suite.aliceToken) - assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) - assert.Equal(suite.T(), int64(amtToPay), payResponse.Amount) + //externalInvoice := lnrpc.Invoice{ + // Memo: "integration tests: zero amount pay from alice", + // Value: 0, + //} + //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) + //assert.NoError(suite.T(), err) + ////pay external from alice + //payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ + // Invoice: invoice.PaymentRequest, + // Amount: amtToPay, + //}, suite.aliceToken) + //assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) + //assert.Equal(suite.T(), int64(amtToPay), payResponse.Amount) } From 1067224dfef7d61c44349a92e57ec2b3fc360a42 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 16:31:58 +0200 Subject: [PATCH 06/11] fix bug in decoding --- integration_tests/lnd_mock.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/integration_tests/lnd_mock.go b/integration_tests/lnd_mock.go index e26a1a0..0e6de8f 100644 --- a/integration_tests/lnd_mock.go +++ b/integration_tests/lnd_mock.go @@ -44,16 +44,9 @@ func NewMockLND(privkey string, fee int64, invoiceChan chan (*lnrpc.Invoice)) (* }, nil } -// DoubleHashB calculates hash(hash(b)) and returns the resulting bytes. -func DoubleHashB(b []byte) []byte { - first := sha256.Sum256(b) - second := sha256.Sum256(first[:]) - return second[:] -} - func (mlnd *MockLND) signMsg(msg []byte) ([]byte, error) { - hash := DoubleHashB(msg) - return ecdsa.SignCompact(mlnd.privKey, hash, true) + hash := sha256.Sum256(msg) + return ecdsa.SignCompact(mlnd.privKey, hash[:], true) } type MockSubscribeInvoices struct { @@ -228,7 +221,7 @@ func (mlnd *MockLND) DecodeBolt11(ctx context.Context, bolt11 string, options .. return nil, err } result := &lnrpc.PayReq{ - Destination: string(inv.Destination.SerializeCompressed()), + Destination: hex.EncodeToString(inv.Destination.SerializeCompressed()), PaymentHash: string(inv.PaymentHash[:]), NumSatoshis: int64(*inv.MilliSat) / 1000, Timestamp: inv.Timestamp.Unix(), From 8952227beedb063116133f8f1950c7e4d4a11d10 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 16:40:06 +0200 Subject: [PATCH 07/11] fix another test --- integration_tests/internal_payment_test.go | 27 +++++++--------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/integration_tests/internal_payment_test.go b/integration_tests/internal_payment_test.go index a750014..087efee 100644 --- a/integration_tests/internal_payment_test.go +++ b/integration_tests/internal_payment_test.go @@ -135,15 +135,10 @@ func (suite *PaymentTestSuite) TestInternalPaymentFail() { bobSatRequested := 500 // currently fee is 0 for internal payments fee := 0 - //fund alice account - //todo - //invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) + + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) + assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) @@ -191,18 +186,12 @@ func (suite *PaymentTestSuite) TestInternalPaymentFail() { assert.Equal(suite.T(), int64(aliceFundingSats)-int64(bobSatRequested+fee), int64(aliceBalance)) } func (suite *PaymentTestSuite) TestInternalPaymentKeysend() { - //aliceFundingSats := 1000 + aliceFundingSats := 1000 bobAmt := 100 memo := "integration test internal keysend from alice" - //todo - //fund alice account - //invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal keysend alice", suite.aliceToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test internal keysend alice", suite.aliceToken) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) + assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) From c9d7ddd9c7923fe9120c996ea2812fa28d775e8e Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 17:54:15 +0200 Subject: [PATCH 08/11] one more file to refactor --- integration_tests/internal_payment_test.go | 6 ++ integration_tests/invoice_test.go | 7 +- integration_tests/keysend_test.go | 44 ++++----- integration_tests/lnd_mock_async.go | 22 ++--- integration_tests/outgoing_payment_test.go | 93 +++++++++---------- .../payment_failure_async_test.go | 45 +++++---- integration_tests/payment_failure_test.go | 45 +++++---- integration_tests/subscription_start_test.go | 6 +- integration_tests/webhook_test.go | 16 ++-- 9 files changed, 146 insertions(+), 138 deletions(-) diff --git a/integration_tests/internal_payment_test.go b/integration_tests/internal_payment_test.go index 087efee..27c26e5 100644 --- a/integration_tests/internal_payment_test.go +++ b/integration_tests/internal_payment_test.go @@ -27,6 +27,7 @@ import ( type PaymentTestSuite struct { TestSuite mlnd *MockLND + externalLND *MockLND service *service.LndhubService aliceLogin ExpectedCreateUserResponseBody aliceToken string @@ -41,6 +42,11 @@ func (suite *PaymentTestSuite) SetupSuite() { log.Fatalf("Error initializing test service: %v", err) } suite.mlnd = mlnd + externalLND, err := NewMockLND("1234567890abcdefabcd", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + suite.externalLND = externalLND svc, err := LndHubTestServiceInit(mlnd) if err != nil { log.Fatalf("Error initializing test service: %v", err) diff --git a/integration_tests/invoice_test.go b/integration_tests/invoice_test.go index 2fe1398..aafaa51 100644 --- a/integration_tests/invoice_test.go +++ b/integration_tests/invoice_test.go @@ -12,6 +12,7 @@ import ( "github.com/getAlby/lndhub.go/lib/service" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" + "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -23,7 +24,11 @@ type InvoiceTestSuite struct { } func (suite *InvoiceTestSuite) SetupSuite() { - svc, err := LndHubTestServiceInit(nil) + mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + svc, err := LndHubTestServiceInit(mlnd) if err != nil { log.Fatalf("Error initializing test service: %v", err) } diff --git a/integration_tests/keysend_test.go b/integration_tests/keysend_test.go index 5f60d46..a996afe 100644 --- a/integration_tests/keysend_test.go +++ b/integration_tests/keysend_test.go @@ -14,6 +14,7 @@ import ( "github.com/getAlby/lndhub.go/lib/tokens" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" + "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -21,14 +22,20 @@ import ( type KeySendTestSuite struct { TestSuite service *service.LndhubService + mlnd *MockLND aliceLogin ExpectedCreateUserResponseBody aliceToken string invoiceUpdateSubCancelFn context.CancelFunc } func (suite *KeySendTestSuite) SetupSuite() { - - svc, err := LndHubTestServiceInit(nil) + fee := int64(1) + mlnd, err := NewMockLND("1234567890abcdef", fee, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + suite.mlnd = mlnd + svc, err := LndHubTestServiceInit(mlnd) if err != nil { log.Fatalf("Error initializing test service: %v", err) } @@ -70,23 +77,15 @@ func (suite *KeySendTestSuite) TearDownSuite() { func (suite *KeySendTestSuite) TestKeysendPayment() { aliceFundingSats := 1000 externalSatRequested := 500 - // 1 sat + 1 ppm - fee := 1 //fund alice account - //todo - // invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) - // sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // FeeLimit: nil, - // } - // _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - // assert.NoError(suite.T(), err) + invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) + assert.NoError(suite.T(), err) //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) - //todo - //suite.createKeySendReq(int64(externalSatRequested), "key send test", simnetLnd3PubKey, suite.aliceToken) + suite.createKeySendReq(int64(externalSatRequested), "key send test", "03abcdef123456789a", suite.aliceToken) // check that balance was reduced userId := getUserIdFromToken(suite.aliceToken) @@ -94,21 +93,16 @@ func (suite *KeySendTestSuite) TestKeysendPayment() { if err != nil { fmt.Printf("Error when getting balance %v\n", err.Error()) } - assert.Equal(suite.T(), int64(aliceFundingSats)-int64(externalSatRequested+fee), aliceBalance) + assert.Equal(suite.T(), int64(aliceFundingSats)-int64(externalSatRequested+int(suite.mlnd.fee)), aliceBalance) } func (suite *KeySendTestSuite) TestKeysendPaymentNonExistentDestination() { - //aliceFundingSats := 1000 + aliceFundingSats := 1000 externalSatRequested := 500 //fund alice account - //todo - //invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) + assert.NoError(suite.T(), err) //wait a bit for the callback event to hit time.Sleep(100 * time.Millisecond) diff --git a/integration_tests/lnd_mock_async.go b/integration_tests/lnd_mock_async.go index ee2cb24..fc49b3c 100644 --- a/integration_tests/lnd_mock_async.go +++ b/integration_tests/lnd_mock_async.go @@ -12,17 +12,12 @@ import ( const SendPaymentMockError = "mocked send payment error" type LNDMockWrapper struct { - *lnd.LNDWrapper + lnd.LightningClientWrapper } -func NewLNDMockWrapper(lndOptions lnd.LNDoptions) (result *LNDMockWrapper, err error) { - lnd, err := lnd.NewLNDclient(lndOptions) - if err != nil { - return nil, err - } - +func NewLNDMockWrapper(lnd lnd.LightningClientWrapper) (result *LNDMockWrapper, err error) { return &LNDMockWrapper{ - LNDWrapper: lnd, + lnd, }, nil } @@ -35,17 +30,12 @@ func (wrapper *LNDMockWrapper) SendPaymentSync(ctx context.Context, req *lnrpc.S var errorMessageChannel = make(chan string, 1) type LNDMockWrapperAsync struct { - *lnd.LNDWrapper + lnd.LightningClientWrapper } -func NewLNDMockWrapperAsync(lndOptions lnd.LNDoptions) (result *LNDMockWrapperAsync, err error) { - lnd, err := lnd.NewLNDclient(lndOptions) - if err != nil { - return nil, err - } - +func NewLNDMockWrapperAsync(lnd lnd.LightningClientWrapper) (result *LNDMockWrapperAsync, err error) { return &LNDMockWrapperAsync{ - LNDWrapper: lnd, + lnd, }, nil } diff --git a/integration_tests/outgoing_payment_test.go b/integration_tests/outgoing_payment_test.go index eea092d..5ec4ccb 100644 --- a/integration_tests/outgoing_payment_test.go +++ b/integration_tests/outgoing_payment_test.go @@ -9,35 +9,35 @@ import ( "time" "github.com/getAlby/lndhub.go/common" + "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" ) func (suite *PaymentTestSuite) TestOutGoingPayment() { aliceFundingSats := 1000 - //todo externalSatRequested := 500 // 1 sat + 1 ppm - fee := 1 + suite.mlnd.fee = 1 //fund alice account invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) assert.NoError(suite.T(), err) //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) //create external invoice - //externalInvoice := lnrpc.Invoice{ - // Memo: "integration tests: external pay from alice", - // Value: int64(externalSatRequested), - //} - //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - //assert.NoError(suite.T(), err) - ////pay external from alice - //payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ - // Invoice: invoice.PaymentRequest, - //}, suite.aliceToken) - //assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) + externalInvoice := lnrpc.Invoice{ + Memo: "integration tests: external pay from alice", + Value: int64(externalSatRequested), + } + invoice, err := suite.externalLND.AddInvoice(context.Background(), &externalInvoice) + assert.NoError(suite.T(), err) + //pay external from alice + payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ + Invoice: invoice.PaymentRequest, + }, suite.aliceToken) + assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) // check that balance was reduced userId := getUserIdFromToken(suite.aliceToken) @@ -45,7 +45,7 @@ func (suite *PaymentTestSuite) TestOutGoingPayment() { if err != nil { fmt.Printf("Error when getting balance %v\n", err.Error()) } - assert.Equal(suite.T(), int64(aliceFundingSats)-int64(externalSatRequested+fee), aliceBalance) + assert.Equal(suite.T(), int64(aliceFundingSats)-int64(externalSatRequested+int(suite.mlnd.fee)), aliceBalance) // check that no additional transaction entry was created transactonEntries, err := suite.service.TransactionEntriesFor(context.Background(), userId) @@ -77,7 +77,7 @@ func (suite *PaymentTestSuite) TestOutGoingPayment() { assert.Equal(suite.T(), int64(0), transactonEntries[1].ParentID) assert.Equal(suite.T(), outgoingInvoices[0].ID, transactonEntries[1].InvoiceID) - assert.Equal(suite.T(), int64(fee), transactonEntries[2].Amount) + assert.Equal(suite.T(), int64(suite.mlnd.fee), transactonEntries[2].Amount) assert.Equal(suite.T(), feeAccount.ID, transactonEntries[2].CreditAccountID) assert.Equal(suite.T(), currentAccount.ID, transactonEntries[2].DebitAccountID) assert.Equal(suite.T(), outgoingInvoices[0].ID, transactonEntries[2].InvoiceID) @@ -94,7 +94,7 @@ func (suite *PaymentTestSuite) TestOutGoingPayment() { responseBody := &[]ExpectedOutgoingInvoice{} assert.Equal(suite.T(), http.StatusOK, rec.Code) assert.NoError(suite.T(), json.NewDecoder(rec.Body).Decode(&responseBody)) - assert.Equal(suite.T(), int64(fee), (*responseBody)[0].Fee) + assert.Equal(suite.T(), int64(suite.mlnd.fee), (*responseBody)[0].Fee) } func (suite *PaymentTestSuite) TestOutGoingPaymentWithNegativeBalance() { @@ -102,27 +102,26 @@ func (suite *PaymentTestSuite) TestOutGoingPaymentWithNegativeBalance() { aliceFundingSats := 1000 externalSatRequested := 1000 // 1 sat + 1 ppm - fee := 1 + suite.mlnd.fee = 1 //fund alice account invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test external payment alice", suite.aliceToken) err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) assert.NoError(suite.T(), err) //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) - //create external invoice - //externalInvoice := lnrpc.Invoice{ - // Memo: "integration tests: external pay from alice", - // Value: int64(externalSatRequested), - //} - //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - //assert.NoError(suite.T(), err) - ////pay external from alice - //payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ - // Invoice: invoice.PaymentRequest, - //}, suite.aliceToken) - //assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) + externalInvoice := lnrpc.Invoice{ + Memo: "integration tests: external pay from alice", + Value: int64(externalSatRequested), + } + invoice, err := suite.externalLND.AddInvoice(context.Background(), &externalInvoice) + assert.NoError(suite.T(), err) + //pay external from alice + payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ + Invoice: invoice.PaymentRequest, + }, suite.aliceToken) + assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) // check that balance was reduced userId := getUserIdFromToken(suite.aliceToken) @@ -131,7 +130,7 @@ func (suite *PaymentTestSuite) TestOutGoingPaymentWithNegativeBalance() { if err != nil { fmt.Printf("Error when getting balance %v\n", err.Error()) } - assert.Equal(suite.T(), int64(aliceFundingSats)-int64(externalSatRequested+fee), aliceBalance) + assert.Equal(suite.T(), int64(aliceFundingSats)-int64(externalSatRequested)+suite.mlnd.fee, aliceBalance) assert.Equal(suite.T(), int64(-1), aliceBalance) // check that no additional transaction entry was created @@ -164,7 +163,7 @@ func (suite *PaymentTestSuite) TestOutGoingPaymentWithNegativeBalance() { assert.Equal(suite.T(), int64(0), transactonEntries[1].ParentID) assert.Equal(suite.T(), outgoingInvoices[0].ID, transactonEntries[1].InvoiceID) - assert.Equal(suite.T(), int64(fee), transactonEntries[2].Amount) + assert.Equal(suite.T(), int64(suite.mlnd.fee), transactonEntries[2].Amount) assert.Equal(suite.T(), feeAccount.ID, transactonEntries[2].CreditAccountID) assert.Equal(suite.T(), currentAccount.ID, transactonEntries[2].DebitAccountID) assert.Equal(suite.T(), outgoingInvoices[0].ID, transactonEntries[2].InvoiceID) @@ -175,27 +174,27 @@ func (suite *PaymentTestSuite) TestOutGoingPaymentWithNegativeBalance() { func (suite *PaymentTestSuite) TestZeroAmountInvoice() { aliceFundingSats := 1000 - //amtToPay := 1000 + amtToPay := 1000 //fund alice account invoiceResponse := suite.createAddInvoiceReq(aliceFundingSats, "integration test zero amount payment alice", suite.aliceToken) err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) assert.NoError(suite.T(), err) //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) //create external invoice - //externalInvoice := lnrpc.Invoice{ - // Memo: "integration tests: zero amount pay from alice", - // Value: 0, - //} - //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - //assert.NoError(suite.T(), err) + externalInvoice := lnrpc.Invoice{ + Memo: "integration tests: zero amount pay from alice", + Value: 0, + } + invoice, err := suite.externalLND.AddInvoice(context.Background(), &externalInvoice) + assert.NoError(suite.T(), err) ////pay external from alice - //payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ - // Invoice: invoice.PaymentRequest, - // Amount: amtToPay, - //}, suite.aliceToken) - //assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) - //assert.Equal(suite.T(), int64(amtToPay), payResponse.Amount) + payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ + Invoice: invoice.PaymentRequest, + Amount: amtToPay, + }, suite.aliceToken) + assert.NotEmpty(suite.T(), payResponse.PaymentPreimage) + assert.Equal(suite.T(), int64(amtToPay), payResponse.Amount) } diff --git a/integration_tests/payment_failure_async_test.go b/integration_tests/payment_failure_async_test.go index d684e7f..c518058 100644 --- a/integration_tests/payment_failure_async_test.go +++ b/integration_tests/payment_failure_async_test.go @@ -13,15 +13,17 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" + "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) type PaymentTestAsyncErrorsSuite struct { TestSuite + mlnd *MockLND + externalLND *MockLND service *service.LndhubService userLogin ExpectedCreateUserResponseBody userToken string @@ -30,11 +32,18 @@ type PaymentTestAsyncErrorsSuite struct { } func (suite *PaymentTestAsyncErrorsSuite) SetupSuite() { + mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + externalLND, err := NewMockLND("1234567890abcdefabcd", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + suite.externalLND = externalLND + suite.mlnd = mlnd // inject fake lnd client with failing send payment sync into service - lndClient, err := NewLNDMockWrapperAsync(lnd.LNDoptions{ - Address: mockLNDAddress, - MacaroonHex: mockLNDMacaroonHex, - }) + lndClient, err := NewLNDMockWrapperAsync(mlnd) suite.serviceClient = lndClient if err != nil { log.Fatalf("Error setting up test client: %v", err) @@ -73,26 +82,22 @@ func (suite *PaymentTestAsyncErrorsSuite) TestExternalAsyncFailingInvoice() { userFundingSats := 1000 externalSatRequested := 500 // fund user account - //invoiceResponse := suite.createAddInvoiceReq(userFundingSats, "integration test external payment user", suite.userToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + invoiceResponse := suite.createAddInvoiceReq(userFundingSats, "integration test external payment user", suite.userToken) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) + assert.NoError(suite.T(), err) // wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) // create external invoice - //externalInvoice := lnrpc.Invoice{ - // Memo: "integration tests: external pay from user", - // Value: int64(externalSatRequested), - //} - //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - //assert.NoError(suite.T(), err) + externalInvoice := lnrpc.Invoice{ + Memo: "integration tests: external pay from user", + Value: int64(externalSatRequested), + } + invoice, err := suite.externalLND.AddInvoice(context.Background(), &externalInvoice) + assert.NoError(suite.T(), err) // pay external from user, req will be canceled after 2 sec - //go suite.createPayInvoiceReqWithCancel(invoice.PaymentRequest, suite.userToken) + go suite.createPayInvoiceReqWithCancel(invoice.PaymentRequest, suite.userToken) // wait for request to fail time.Sleep(5 * time.Second) diff --git a/integration_tests/payment_failure_test.go b/integration_tests/payment_failure_test.go index f599149..b8e84f3 100644 --- a/integration_tests/payment_failure_test.go +++ b/integration_tests/payment_failure_test.go @@ -13,9 +13,9 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" + "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -23,17 +23,26 @@ import ( type PaymentTestErrorsSuite struct { TestSuite service *service.LndhubService + mlnd *MockLND + externalLND *MockLND userLogin ExpectedCreateUserResponseBody userToken string invoiceUpdateSubCancelFn context.CancelFunc } func (suite *PaymentTestErrorsSuite) SetupSuite() { + mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + externalLND, err := NewMockLND("1234567890abcdefabcd", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } // inject fake lnd client with failing send payment sync into service - lndClient, err := NewLNDMockWrapper(lnd.LNDoptions{ - Address: mockLNDAddress, - MacaroonHex: mockLNDMacaroonHex, - }) + lndClient, err := NewLNDMockWrapper(mlnd) + suite.mlnd = mlnd + suite.externalLND = externalLND if err != nil { log.Fatalf("Error setting up test client: %v", err) } @@ -71,26 +80,22 @@ func (suite *PaymentTestErrorsSuite) TestExternalFailingInvoice() { userFundingSats := 1000 externalSatRequested := 500 //fund user account - //invoiceResponse := suite.createAddInvoiceReq(userFundingSats, "integration test external payment user", suite.userToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoiceResponse.PayReq, - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + invoiceResponse := suite.createAddInvoiceReq(userFundingSats, "integration test external payment user", suite.userToken) + err := suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) + assert.NoError(suite.T(), err) //wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) //create external invoice - //externalInvoice := lnrpc.Invoice{ - // Memo: "integration tests: external pay from user", - // Value: int64(externalSatRequested), - //} - //invoice, err := suite.fundingClient.AddInvoice(context.Background(), &externalInvoice) - //assert.NoError(suite.T(), err) + externalInvoice := lnrpc.Invoice{ + Memo: "integration tests: external pay from user", + Value: int64(externalSatRequested), + } + invoice, err := suite.externalLND.AddInvoice(context.Background(), &externalInvoice) + assert.NoError(suite.T(), err) //pay external from user, mock will fail immediately - //_ = suite.createPayInvoiceReqError(invoice.PaymentRequest, suite.userToken) + _ = suite.createPayInvoiceReqError(invoice.PaymentRequest, suite.userToken) userId := getUserIdFromToken(suite.userToken) diff --git a/integration_tests/subscription_start_test.go b/integration_tests/subscription_start_test.go index d339a67..2f99459 100644 --- a/integration_tests/subscription_start_test.go +++ b/integration_tests/subscription_start_test.go @@ -39,7 +39,11 @@ func TestSubscriptionStartTestSuite(t *testing.T) { suite.Run(t, new(SubscriptionStartTestSuite)) } func (suite *SubscriptionStartTestSuite) SetupSuite() { - svc, err := LndHubTestServiceInit(nil) + mockLND, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + svc, err := LndHubTestServiceInit(mockLND) if err != nil { log.Fatalf("Error initializing test service: %v", err) } diff --git a/integration_tests/webhook_test.go b/integration_tests/webhook_test.go index 237d513..7fcc634 100644 --- a/integration_tests/webhook_test.go +++ b/integration_tests/webhook_test.go @@ -15,7 +15,6 @@ import ( "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lib/tokens" - "github.com/getAlby/lndhub.go/lnd" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" "github.com/lightningnetwork/lnd/lnrpc" @@ -25,8 +24,8 @@ import ( type WebHookTestSuite struct { TestSuite - fundingClient *lnd.LNDWrapper service *service.LndhubService + mlnd *MockLND userLogin ExpectedCreateUserResponseBody userToken string webHookServer *httptest.Server @@ -47,7 +46,12 @@ func (suite *WebHookTestSuite) SetupSuite() { suite.invoiceChan <- invoice })) suite.webHookServer = webhookServer - svc, err := LndHubTestServiceInit(nil) + mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + svc, err := LndHubTestServiceInit(mlnd) + suite.mlnd = mlnd if err != nil { log.Fatalf("Error initializing test service: %v", err) } @@ -79,11 +83,7 @@ func (suite *WebHookTestSuite) SetupSuite() { func (suite *WebHookTestSuite) TestWebHook() { // create incoming invoice and fund account invoice := suite.createAddInvoiceReq(1000, "integration test webhook", suite.userToken) - sendPaymentRequest := lnrpc.SendRequest{ - PaymentRequest: invoice.PayReq, - FeeLimit: nil, - } - _, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + err := suite.mlnd.mockPaidInvoice(invoice, 0, false, nil) assert.NoError(suite.T(), err) invoiceFromWebhook := <-suite.invoiceChan assert.Equal(suite.T(), "integration test webhook", invoiceFromWebhook.Memo) From 057a8f3c57f2ea7c4cd22da39b6b6b4428cc9eec Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 18:00:58 +0200 Subject: [PATCH 09/11] praise the lord --- integration_tests/websocket_test.go | 77 ++++++++++------------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/integration_tests/websocket_test.go b/integration_tests/websocket_test.go index f34c782..8c5ca98 100644 --- a/integration_tests/websocket_test.go +++ b/integration_tests/websocket_test.go @@ -18,6 +18,7 @@ import ( "github.com/go-playground/validator/v10" "github.com/gorilla/websocket" "github.com/labstack/echo/v4" + "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -29,6 +30,7 @@ type KeepAlive struct { type WebSocketTestSuite struct { TestSuite service *service.LndhubService + mlnd *MockLND userLogin ExpectedCreateUserResponseBody userToken string userToken2 string @@ -52,11 +54,15 @@ func (h *WsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (suite *WebSocketTestSuite) SetupSuite() { - - svc, err := LndHubTestServiceInit(nil) + mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) if err != nil { log.Fatalf("Error initializing test service: %v", err) } + svc, err := LndHubTestServiceInit(mlnd) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + suite.mlnd = mlnd users, userTokens, err := createUsers(svc, 2) if err != nil { log.Fatalf("Error creating test users: %v", err) @@ -100,13 +106,9 @@ func (suite *WebSocketTestSuite) TestWebSocket() { assert.Equal(suite.T(), "keepalive", keepAlive.Type) // create incoming invoice and fund account - //invoice := suite.createAddInvoiceReq(1000, "integration test websocket 1", suite.userToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoice.PayReq, - // FeeLimit: nil, - //} - //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + invoice := suite.createAddInvoiceReq(1000, "integration test websocket 1", suite.userToken) + err = suite.mlnd.mockPaidInvoice(invoice, 0, false, nil) + assert.NoError(suite.T(), err) _, msg, err = ws.ReadMessage() assert.NoError(suite.T(), err) @@ -131,12 +133,8 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubeSubscription() { //read keepalive msg _, _, err = ws2.ReadMessage() assert.NoError(suite.T(), err) - //invoice := suite.createAddInvoiceReq(1000, "integration test websocket 2", suite.userToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoice.PayReq, - // FeeLimit: nil, - //} - //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + invoice := suite.createAddInvoiceReq(1000, "integration test websocket 2", suite.userToken) + err = suite.mlnd.mockPaidInvoice(invoice, 0, false, nil) assert.NoError(suite.T(), err) _, msg1, err := ws1.ReadMessage() assert.NoError(suite.T(), err) @@ -153,12 +151,8 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubeSubscription() { assert.Equal(suite.T(), "integration test websocket 2", event2.Invoice.Description) //close 1 subscription, assert that the existing sub still receives their invoices ws1.Close() - //invoice = suite.createAddInvoiceReq(1000, "integration test websocket 3", suite.userToken) - //sendPaymentRequest = lnrpc.SendRequest{ - // PaymentRequest: invoice.PayReq, - // FeeLimit: nil, - //} - //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) + invoice = suite.createAddInvoiceReq(1000, "integration test websocket 3", suite.userToken) + err = suite.mlnd.mockPaidInvoice(invoice, 0, false, nil) assert.NoError(suite.T(), err) _, msg3, err := ws2.ReadMessage() assert.NoError(suite.T(), err) @@ -169,7 +163,6 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubeSubscription() { } func (suite *WebSocketTestSuite) TestWebSocketDoubleUser() { - //create subs for 2 different users, assert that they each get their own invoice updates user1Ws, _, err := websocket.DefaultDialer.Dial(suite.wsUrl, nil) assert.NoError(suite.T(), err) @@ -183,21 +176,13 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubleUser() { _, _, err = user2Ws.ReadMessage() assert.NoError(suite.T(), err) // add invoice for user 1 - //user1Invoice := suite.createAddInvoiceReq(1000, "integration test websocket user 1", suite.userToken) - //sendPaymentRequestUser1 := lnrpc.SendRequest{ - // PaymentRequest: user1Invoice.PayReq, - // FeeLimit: nil, - //} - //// add invoice for user 2 - //user2Invoice := suite.createAddInvoiceReq(1000, "integration test websocket user 2", suite.userToken2) - //sendPaymentRequestUser2 := lnrpc.SendRequest{ - // PaymentRequest: user2Invoice.PayReq, - // FeeLimit: nil, - //} - //pay invoices - //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequestUser1) - //assert.NoError(suite.T(), err) - //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequestUser2) + user1Invoice := suite.createAddInvoiceReq(1000, "integration test websocket user 1", suite.userToken) + // add invoice for user 2 + user2Invoice := suite.createAddInvoiceReq(1000, "integration test websocket user 2", suite.userToken2) + //mock pay invoices + err = suite.mlnd.mockPaidInvoice(user1Invoice, 0, false, nil) + assert.NoError(suite.T(), err) + err = suite.mlnd.mockPaidInvoice(user2Invoice, 0, false, nil) assert.NoError(suite.T(), err) //read user 1 received msg _, user1Msg, err := user1Ws.ReadMessage() @@ -220,21 +205,13 @@ func (suite *WebSocketTestSuite) TestWebSocketDoubleUser() { func (suite *WebSocketTestSuite) TestWebSocketMissingInvoice() { // create incoming invoice and fund account invoice1 := suite.createAddInvoiceReq(1000, "integration test websocket missing invoices", suite.userToken) - //sendPaymentRequest := lnrpc.SendRequest{ - // PaymentRequest: invoice1.PayReq, - // FeeLimit: nil, - //} - //_, err := suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + err := suite.mlnd.mockPaidInvoice(invoice1, 0, false, nil) + assert.NoError(suite.T(), err) //// create 2nd invoice and pay it as well - //invoice2 := suite.createAddInvoiceReq(1000, "integration test websocket missing invoices 2nd", suite.userToken) - //sendPaymentRequest = lnrpc.SendRequest{ - // PaymentRequest: invoice2.PayReq, - // FeeLimit: nil, - //} - //_, err = suite.fundingClient.SendPaymentSync(context.Background(), &sendPaymentRequest) - //assert.NoError(suite.T(), err) + invoice2 := suite.createAddInvoiceReq(1000, "integration test websocket missing invoices 2nd", suite.userToken) + err = suite.mlnd.mockPaidInvoice(invoice2, 0, false, nil) + assert.NoError(suite.T(), err) //start listening to websocket after 2nd invoice has been paid //we should get an event for the 2nd invoice if we specify the hash as the query parameter From 40e34086d7cb24ce053fb81e67fef47a5d855ebd Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 18:27:03 +0200 Subject: [PATCH 10/11] all tests passing --- integration_tests/auth_test.go | 2 +- integration_tests/checkpayment_test.go | 16 +++++++--------- integration_tests/create_test.go | 2 +- integration_tests/getinfo_test.go | 4 ++-- integration_tests/gettxs_test.go | 6 +----- integration_tests/incoming_payment_test.go | 5 +---- integration_tests/internal_payment_test.go | 5 +---- integration_tests/invoice_test.go | 7 +------ integration_tests/keysend_test.go | 7 ++----- integration_tests/lnd_mock.go | 9 +++++++++ integration_tests/outgoing_payment_test.go | 2 +- integration_tests/payment_failure_async_test.go | 5 +---- integration_tests/payment_failure_test.go | 5 +---- integration_tests/subscription_start_test.go | 13 ++++--------- integration_tests/webhook_test.go | 6 +----- integration_tests/websocket_test.go | 6 +----- 16 files changed, 35 insertions(+), 65 deletions(-) diff --git a/integration_tests/auth_test.go b/integration_tests/auth_test.go index ac19437..14af729 100644 --- a/integration_tests/auth_test.go +++ b/integration_tests/auth_test.go @@ -30,7 +30,7 @@ type UserAuthTestSuite struct { } func (suite *UserAuthTestSuite) SetupSuite() { - svc, err := LndHubTestServiceInit(nil) + svc, err := LndHubTestServiceInit(newDefaultMockLND()) if err != nil { log.Fatalf("Error initializing test service: %v", err) } diff --git a/integration_tests/checkpayment_test.go b/integration_tests/checkpayment_test.go index 5a52f3b..86b9da9 100644 --- a/integration_tests/checkpayment_test.go +++ b/integration_tests/checkpayment_test.go @@ -17,7 +17,6 @@ import ( "github.com/getAlby/lndhub.go/lib/tokens" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -25,16 +24,19 @@ import ( type CheckPaymentTestSuite struct { TestSuite service *service.LndhubService + mlnd *MockLND userLogin ExpectedCreateUserResponseBody userToken string invoiceUpdateSubCancelFn context.CancelFunc } func (suite *CheckPaymentTestSuite) SetupSuite() { - svc, err := LndHubTestServiceInit(nil) + mockLND := newDefaultMockLND() + svc, err := LndHubTestServiceInit(mockLND) if err != nil { log.Fatalf("Error initializing test service: %v", err) } + suite.mlnd = mockLND users, userTokens, err := createUsers(svc, 1) if err != nil { log.Fatalf("Error creating test users: %v", err) @@ -74,14 +76,10 @@ func (suite *CheckPaymentTestSuite) TestCheckPaymentNotFound() { func (suite *CheckPaymentTestSuite) TestCheckPaymentProperIsPaidResponse() { // create incoming invoice and fund account invoice := suite.createAddInvoiceReq(1000, "integration test check payments for user", suite.userToken) - //TODO fund - _ = lnrpc.SendRequest{ - PaymentRequest: invoice.PayReq, - FeeLimit: nil, - } - + err := suite.mlnd.mockPaidInvoice(invoice, 0, false, nil) + assert.NoError(suite.T(), err) // wait a bit for the callback event to hit - time.Sleep(100 * time.Millisecond) + time.Sleep(10 * time.Millisecond) // create invoice invoice = suite.createAddInvoiceReq(500, "integration test check payments for user", suite.userToken) // pay invoice, this will create outgoing invoice and settle it diff --git a/integration_tests/create_test.go b/integration_tests/create_test.go index 42202fe..ed214e0 100644 --- a/integration_tests/create_test.go +++ b/integration_tests/create_test.go @@ -25,7 +25,7 @@ type CreateUserTestSuite struct { } func (suite *CreateUserTestSuite) SetupSuite() { - svc, err := LndHubTestServiceInit(nil) + svc, err := LndHubTestServiceInit(newDefaultMockLND()) if err != nil { log.Fatalf("Error initializing test service: %v", err) } diff --git a/integration_tests/getinfo_test.go b/integration_tests/getinfo_test.go index 8df60a7..b6d0719 100644 --- a/integration_tests/getinfo_test.go +++ b/integration_tests/getinfo_test.go @@ -28,7 +28,7 @@ type GetInfoTestSuite struct { } func (suite *GetInfoTestSuite) SetupSuite() { - svc, err := LndHubTestServiceInit(nil) + svc, err := LndHubTestServiceInit(newDefaultMockLND()) if err != nil { log.Fatalf("Error initializing test service: %v", err) } @@ -60,7 +60,7 @@ func (suite *GetInfoTestSuite) TestGetInfoWithDefaultAlias() { assert.Equal(suite.T(), http.StatusOK, rec.Code) assert.NoError(suite.T(), json.NewDecoder(rec.Body).Decode(getInfoResponse)) assert.NotNil(suite.T(), getInfoResponse) - assert.Equal(suite.T(), "alby-simnet-lnd1", getInfoResponse.Alias) + assert.Equal(suite.T(), "Mocky McMockface", getInfoResponse.Alias) } func (suite *GetInfoTestSuite) TestGetInfoWithGivenAlias() { diff --git a/integration_tests/gettxs_test.go b/integration_tests/gettxs_test.go index 563d561..a1a6f05 100644 --- a/integration_tests/gettxs_test.go +++ b/integration_tests/gettxs_test.go @@ -17,7 +17,6 @@ import ( "github.com/getAlby/lndhub.go/lib/tokens" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -32,10 +31,7 @@ type GetTxTestSuite struct { } func (suite *GetTxTestSuite) SetupSuite() { - mockLND, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } + mockLND := newDefaultMockLND() svc, err := LndHubTestServiceInit(mockLND) if err != nil { log.Fatalf("Error initializing test service: %v", err) diff --git a/integration_tests/incoming_payment_test.go b/integration_tests/incoming_payment_test.go index e11bbe7..5cb9588 100644 --- a/integration_tests/incoming_payment_test.go +++ b/integration_tests/incoming_payment_test.go @@ -35,10 +35,7 @@ type IncomingPaymentTestSuite struct { } func (suite *IncomingPaymentTestSuite) SetupSuite() { - mockLND, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } + mockLND := newDefaultMockLND() suite.mockLND = mockLND svc, err := LndHubTestServiceInit(mockLND) if err != nil { diff --git a/integration_tests/internal_payment_test.go b/integration_tests/internal_payment_test.go index 27c26e5..c155bef 100644 --- a/integration_tests/internal_payment_test.go +++ b/integration_tests/internal_payment_test.go @@ -37,10 +37,7 @@ type PaymentTestSuite struct { } func (suite *PaymentTestSuite) SetupSuite() { - mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } + mlnd := newDefaultMockLND() suite.mlnd = mlnd externalLND, err := NewMockLND("1234567890abcdefabcd", 0, make(chan (*lnrpc.Invoice))) if err != nil { diff --git a/integration_tests/invoice_test.go b/integration_tests/invoice_test.go index aafaa51..55c0369 100644 --- a/integration_tests/invoice_test.go +++ b/integration_tests/invoice_test.go @@ -12,7 +12,6 @@ import ( "github.com/getAlby/lndhub.go/lib/service" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -24,11 +23,7 @@ type InvoiceTestSuite struct { } func (suite *InvoiceTestSuite) SetupSuite() { - mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } - svc, err := LndHubTestServiceInit(mlnd) + svc, err := LndHubTestServiceInit(newDefaultMockLND()) if err != nil { log.Fatalf("Error initializing test service: %v", err) } diff --git a/integration_tests/keysend_test.go b/integration_tests/keysend_test.go index a996afe..b93a08a 100644 --- a/integration_tests/keysend_test.go +++ b/integration_tests/keysend_test.go @@ -14,7 +14,6 @@ import ( "github.com/getAlby/lndhub.go/lib/tokens" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -30,10 +29,8 @@ type KeySendTestSuite struct { func (suite *KeySendTestSuite) SetupSuite() { fee := int64(1) - mlnd, err := NewMockLND("1234567890abcdef", fee, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } + mlnd := newDefaultMockLND() + mlnd.fee = fee suite.mlnd = mlnd svc, err := LndHubTestServiceInit(mlnd) if err != nil { diff --git a/integration_tests/lnd_mock.go b/integration_tests/lnd_mock.go index 0e6de8f..77327ac 100644 --- a/integration_tests/lnd_mock.go +++ b/integration_tests/lnd_mock.go @@ -5,6 +5,7 @@ import ( "crypto/rand" "crypto/sha256" "encoding/hex" + "log" "math/big" "time" @@ -253,3 +254,11 @@ func randBytesFromStr(length int, from string) ([]byte, error) { } return b, nil } + +func newDefaultMockLND() *MockLND { + mockLND, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) + if err != nil { + log.Fatalf("Error initializing test service: %v", err) + } + return mockLND +} diff --git a/integration_tests/outgoing_payment_test.go b/integration_tests/outgoing_payment_test.go index 5ec4ccb..affea15 100644 --- a/integration_tests/outgoing_payment_test.go +++ b/integration_tests/outgoing_payment_test.go @@ -130,7 +130,7 @@ func (suite *PaymentTestSuite) TestOutGoingPaymentWithNegativeBalance() { if err != nil { fmt.Printf("Error when getting balance %v\n", err.Error()) } - assert.Equal(suite.T(), int64(aliceFundingSats)-int64(externalSatRequested)+suite.mlnd.fee, aliceBalance) + assert.Equal(suite.T(), int64(aliceFundingSats)-(int64(externalSatRequested)+suite.mlnd.fee), aliceBalance) assert.Equal(suite.T(), int64(-1), aliceBalance) // check that no additional transaction entry was created diff --git a/integration_tests/payment_failure_async_test.go b/integration_tests/payment_failure_async_test.go index c518058..7f29ae8 100644 --- a/integration_tests/payment_failure_async_test.go +++ b/integration_tests/payment_failure_async_test.go @@ -32,10 +32,7 @@ type PaymentTestAsyncErrorsSuite struct { } func (suite *PaymentTestAsyncErrorsSuite) SetupSuite() { - mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } + mlnd := newDefaultMockLND() externalLND, err := NewMockLND("1234567890abcdefabcd", 0, make(chan (*lnrpc.Invoice))) if err != nil { log.Fatalf("Error initializing test service: %v", err) diff --git a/integration_tests/payment_failure_test.go b/integration_tests/payment_failure_test.go index b8e84f3..4ead195 100644 --- a/integration_tests/payment_failure_test.go +++ b/integration_tests/payment_failure_test.go @@ -31,10 +31,7 @@ type PaymentTestErrorsSuite struct { } func (suite *PaymentTestErrorsSuite) SetupSuite() { - mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } + mlnd := newDefaultMockLND() externalLND, err := NewMockLND("1234567890abcdefabcd", 0, make(chan (*lnrpc.Invoice))) if err != nil { log.Fatalf("Error initializing test service: %v", err) diff --git a/integration_tests/subscription_start_test.go b/integration_tests/subscription_start_test.go index 2f99459..2cde79f 100644 --- a/integration_tests/subscription_start_test.go +++ b/integration_tests/subscription_start_test.go @@ -25,10 +25,9 @@ import ( type SubscriptionStartTestSuite struct { TestSuite - service *service.LndhubService - userLogin ExpectedCreateUserResponseBody - userToken string - invoiceUpdateSubCancelFn context.CancelFunc + service *service.LndhubService + userLogin ExpectedCreateUserResponseBody + userToken string } func (suite *SubscriptionStartTestSuite) TearDownSuite() { @@ -39,11 +38,7 @@ func TestSubscriptionStartTestSuite(t *testing.T) { suite.Run(t, new(SubscriptionStartTestSuite)) } func (suite *SubscriptionStartTestSuite) SetupSuite() { - mockLND, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } - svc, err := LndHubTestServiceInit(mockLND) + svc, err := LndHubTestServiceInit(newDefaultMockLND()) if err != nil { log.Fatalf("Error initializing test service: %v", err) } diff --git a/integration_tests/webhook_test.go b/integration_tests/webhook_test.go index 7fcc634..85605e3 100644 --- a/integration_tests/webhook_test.go +++ b/integration_tests/webhook_test.go @@ -17,7 +17,6 @@ import ( "github.com/getAlby/lndhub.go/lib/tokens" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -46,10 +45,7 @@ func (suite *WebHookTestSuite) SetupSuite() { suite.invoiceChan <- invoice })) suite.webHookServer = webhookServer - mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } + mlnd := newDefaultMockLND() svc, err := LndHubTestServiceInit(mlnd) suite.mlnd = mlnd if err != nil { diff --git a/integration_tests/websocket_test.go b/integration_tests/websocket_test.go index 8c5ca98..dd5989f 100644 --- a/integration_tests/websocket_test.go +++ b/integration_tests/websocket_test.go @@ -18,7 +18,6 @@ import ( "github.com/go-playground/validator/v10" "github.com/gorilla/websocket" "github.com/labstack/echo/v4" - "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -54,10 +53,7 @@ func (h *WsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (suite *WebSocketTestSuite) SetupSuite() { - mlnd, err := NewMockLND("1234567890abcdef", 0, make(chan (*lnrpc.Invoice))) - if err != nil { - log.Fatalf("Error initializing test service: %v", err) - } + mlnd := newDefaultMockLND() svc, err := LndHubTestServiceInit(mlnd) if err != nil { log.Fatalf("Error initializing test service: %v", err) From 13fcf0218250ce298a46dc208ccc0a21cca6581a Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 15 Jun 2022 18:44:24 +0200 Subject: [PATCH 11/11] too many / --- integration_tests/outgoing_payment_test.go | 2 +- integration_tests/websocket_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/outgoing_payment_test.go b/integration_tests/outgoing_payment_test.go index affea15..61afe51 100644 --- a/integration_tests/outgoing_payment_test.go +++ b/integration_tests/outgoing_payment_test.go @@ -190,7 +190,7 @@ func (suite *PaymentTestSuite) TestZeroAmountInvoice() { } invoice, err := suite.externalLND.AddInvoice(context.Background(), &externalInvoice) assert.NoError(suite.T(), err) - ////pay external from alice + //pay external from alice payResponse := suite.createPayInvoiceReq(&ExpectedPayInvoiceRequestBody{ Invoice: invoice.PaymentRequest, Amount: amtToPay, diff --git a/integration_tests/websocket_test.go b/integration_tests/websocket_test.go index dd5989f..cc93066 100644 --- a/integration_tests/websocket_test.go +++ b/integration_tests/websocket_test.go @@ -204,7 +204,7 @@ func (suite *WebSocketTestSuite) TestWebSocketMissingInvoice() { err := suite.mlnd.mockPaidInvoice(invoice1, 0, false, nil) assert.NoError(suite.T(), err) - //// create 2nd invoice and pay it as well + //create 2nd invoice and pay it as well invoice2 := suite.createAddInvoiceReq(1000, "integration test websocket missing invoices 2nd", suite.userToken) err = suite.mlnd.mockPaidInvoice(invoice2, 0, false, nil) assert.NoError(suite.T(), err)