diff --git a/lntest/itest/lnd_single_hop_invoice_test.go b/lntest/itest/lnd_single_hop_invoice_test.go index 55fe8774a..f75ad5f25 100644 --- a/lntest/itest/lnd_single_hop_invoice_test.go +++ b/lntest/itest/lnd_single_hop_invoice_test.go @@ -12,6 +12,8 @@ import ( "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lntest" "github.com/lightningnetwork/lnd/lntest/wait" + "github.com/lightningnetwork/lnd/lntypes" + "github.com/lightningnetwork/lnd/record" ) func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) { @@ -138,6 +140,38 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf(err.Error()) } + // Next send a key send payment. + keySendPreimage := lntypes.Preimage{3, 4, 5, 11} + keySendHash := keySendPreimage.Hash() + + sendReq = &lnrpc.SendRequest{ + Dest: net.Bob.PubKey[:], + Amt: paymentAmt, + FinalCltvDelta: 40, + PaymentHash: keySendHash[:], + DestCustomRecords: map[uint64][]byte{ + record.KeySendType: keySendPreimage[:], + }, + } + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + resp, err = net.Alice.SendPaymentSync(ctxt, sendReq) + if err != nil { + t.Fatalf("unable to send payment: %v", err) + } + if resp.PaymentError != "" { + t.Fatalf("error when attempting recv: %v", resp.PaymentError) + } + + // The key send payment should also have succeeded, with the balances + // being update accordingly. + err = wait.NoError( + assertAmountSent(3*paymentAmt, net.Alice, net.Bob), + 3*time.Second, + ) + if err != nil { + t.Fatalf(err.Error()) + } + ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout) closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false) } diff --git a/lntest/node.go b/lntest/node.go index b6636089d..cbe8e3816 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -152,6 +152,8 @@ type nodeConfig struct { RPCPort int RESTPort int ProfilePort int + + AcceptKeySend bool } func (cfg nodeConfig) P2PAddr() string { @@ -225,6 +227,10 @@ func (cfg nodeConfig) genArgs() []string { args = append(args, cfg.ExtraArgs...) } + if cfg.AcceptKeySend { + args = append(args, "--accept-key-send") + } + return args } @@ -304,6 +310,11 @@ func newNode(cfg nodeConfig) (*HarnessNode, error) { cfg.P2PPort, cfg.RPCPort, cfg.RESTPort, cfg.ProfilePort = generateListeningPorts() + // Run all tests with accept key send. The key send code is very + // isolated and it is highly unlikely that it would affect regular + // itests when enabled. + cfg.AcceptKeySend = true + numActiveNodesMtx.Lock() nodeNum := numActiveNodes numActiveNodes++