mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 21:35:24 +01:00
lntemp+lntest: fix make lint
This commit is contained in:
parent
f3ad66b363
commit
178e4b0103
@ -160,6 +160,7 @@ func (h *HarnessRPC) BuildRoute(
|
||||
|
||||
resp, err := h.Router.BuildRoute(ctxt, req)
|
||||
h.NoError(err, "BuildRoute")
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ func (h *HarnessRPC) DeriveSharedKeyErr(req *signrpc.SharedKeyRequest) error {
|
||||
|
||||
_, err := h.Signer.DeriveSharedKey(ctxt, req)
|
||||
require.Error(h, err, "expected error from calling DeriveSharedKey")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@ -72,6 +73,8 @@ func (h *HarnessRPC) MuSig2CreateSession(
|
||||
}
|
||||
|
||||
// MuSig2CombineKeys makes a RPC call to the node's SignerClient and asserts.
|
||||
//
|
||||
//nolint:lll
|
||||
func (h *HarnessRPC) MuSig2CombineKeys(
|
||||
req *signrpc.MuSig2CombineKeysRequest) *signrpc.MuSig2CombineKeysResponse {
|
||||
|
||||
@ -85,6 +88,8 @@ func (h *HarnessRPC) MuSig2CombineKeys(
|
||||
}
|
||||
|
||||
// MuSig2RegisterNonces makes a RPC call to the node's SignerClient and asserts.
|
||||
//
|
||||
//nolint:lll
|
||||
func (h *HarnessRPC) MuSig2RegisterNonces(
|
||||
req *signrpc.MuSig2RegisterNoncesRequest) *signrpc.MuSig2RegisterNoncesResponse {
|
||||
|
||||
@ -124,12 +129,12 @@ func (h *HarnessRPC) MuSig2SignErr(req *signrpc.MuSig2SignRequest) error {
|
||||
|
||||
// MuSig2CombineSig makes a RPC call to the node's SignerClient and asserts.
|
||||
func (h *HarnessRPC) MuSig2CombineSig(
|
||||
req *signrpc.MuSig2CombineSigRequest) *signrpc.MuSig2CombineSigResponse {
|
||||
r *signrpc.MuSig2CombineSigRequest) *signrpc.MuSig2CombineSigResponse {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
resp, err := h.Signer.MuSig2CombineSig(ctxt, req)
|
||||
resp, err := h.Signer.MuSig2CombineSig(ctxt, r)
|
||||
h.NoError(err, "MuSig2CombineSig")
|
||||
|
||||
return resp
|
||||
|
@ -204,6 +204,8 @@ func (h *HarnessRPC) ImportAccount(
|
||||
}
|
||||
|
||||
// ImportPublicKey makes a RPC call to the node's WalletKitClient and asserts.
|
||||
//
|
||||
//nolint:lll
|
||||
func (h *HarnessRPC) ImportPublicKey(
|
||||
req *walletrpc.ImportPublicKeyRequest) *walletrpc.ImportPublicKeyResponse {
|
||||
|
||||
@ -230,6 +232,8 @@ func (h *HarnessRPC) SignPsbt(
|
||||
}
|
||||
|
||||
// ImportTapscript makes a RPC call to the node's WalletKitClient and asserts.
|
||||
//
|
||||
//nolint:lll
|
||||
func (h *HarnessRPC) ImportTapscript(
|
||||
req *walletrpc.ImportTapscriptRequest) *walletrpc.ImportTapscriptResponse {
|
||||
|
||||
|
@ -80,7 +80,7 @@ func testSendPaymentAMPInvoiceCase(ht *lntemp.HarnessTest,
|
||||
// Ensure we get a notification of the invoice being added by Bob.
|
||||
rpcInvoice := ht.ReceiveInvoiceUpdate(bobInvoiceSubscription)
|
||||
|
||||
require.False(ht, rpcInvoice.Settled) // nolint:staticcheck
|
||||
require.False(ht, rpcInvoice.Settled)
|
||||
require.Equal(ht, lnrpc.Invoice_OPEN, rpcInvoice.State)
|
||||
require.Equal(ht, int64(0), rpcInvoice.AmtPaidSat)
|
||||
require.Equal(ht, int64(0), rpcInvoice.AmtPaidMsat)
|
||||
@ -156,7 +156,7 @@ func testSendPaymentAMPInvoiceCase(ht *lntemp.HarnessTest,
|
||||
|
||||
// Assert that the invoice is settled for the total payment amount and
|
||||
// has the correct payment address.
|
||||
require.True(ht, rpcInvoice.Settled) // nolint:staticcheck
|
||||
require.True(ht, rpcInvoice.Settled)
|
||||
require.Equal(ht, lnrpc.Invoice_SETTLED, rpcInvoice.State)
|
||||
require.Equal(ht, int64(paymentAmt), rpcInvoice.AmtPaidSat)
|
||||
require.Equal(ht, int64(paymentAmt*1000), rpcInvoice.AmtPaidMsat)
|
||||
@ -232,7 +232,7 @@ func testSendPaymentAMPInvoiceRepeat(ht *lntemp.HarnessTest) {
|
||||
|
||||
// We should get an initial notification that the HTLC has been added.
|
||||
rpcInvoice := ht.ReceiveInvoiceUpdate(invSubscription)
|
||||
require.False(ht, rpcInvoice.Settled) // nolint:staticcheck
|
||||
require.False(ht, rpcInvoice.Settled)
|
||||
require.Equal(ht, lnrpc.Invoice_OPEN, rpcInvoice.State)
|
||||
require.Equal(ht, int64(0), rpcInvoice.AmtPaidSat)
|
||||
require.Equal(ht, int64(0), rpcInvoice.AmtPaidMsat)
|
||||
@ -248,7 +248,7 @@ func testSendPaymentAMPInvoiceRepeat(ht *lntemp.HarnessTest) {
|
||||
|
||||
// The notification should signal that the invoice is now settled, and
|
||||
// should also include the set ID, and show the proper amount paid.
|
||||
require.True(ht, invoiceNtfn.Settled) // nolint:staticcheck
|
||||
require.True(ht, invoiceNtfn.Settled)
|
||||
require.Equal(ht, lnrpc.Invoice_SETTLED, invoiceNtfn.State)
|
||||
require.Equal(ht, paymentAmt, int(invoiceNtfn.AmtPaidSat))
|
||||
require.Equal(ht, 1, len(invoiceNtfn.AmpInvoiceState))
|
||||
@ -271,7 +271,7 @@ func testSendPaymentAMPInvoiceRepeat(ht *lntemp.HarnessTest) {
|
||||
// The invoice should still be shown as settled, and also include the
|
||||
// information about this newly generated setID, showing 2x the amount
|
||||
// paid.
|
||||
require.True(ht, invoiceNtfn.Settled) // nolint:staticcheck
|
||||
require.True(ht, invoiceNtfn.Settled)
|
||||
require.Equal(ht, paymentAmt*2, int(invoiceNtfn.AmtPaidSat))
|
||||
|
||||
var secondSetID []byte
|
||||
@ -347,7 +347,7 @@ func testSendPaymentAMPInvoiceRepeat(ht *lntemp.HarnessTest) {
|
||||
backlogInv := ht.ReceiveInvoiceUpdate(invSub2)
|
||||
require.Equal(ht, 1, len(backlogInv.Htlcs))
|
||||
require.Equal(ht, 2, len(backlogInv.AmpInvoiceState))
|
||||
require.True(ht, backlogInv.Settled) // nolint:staticcheck
|
||||
require.True(ht, backlogInv.Settled)
|
||||
require.Equal(ht, paymentAmt*2, int(backlogInv.AmtPaidSat))
|
||||
}
|
||||
|
||||
@ -422,7 +422,7 @@ func testSendPaymentAMP(ht *lntemp.HarnessTest) {
|
||||
|
||||
// Assert that the invoice is settled for the total payment amount and
|
||||
// has the correct payment address.
|
||||
require.True(ht, rpcInvoice.Settled) // nolint:staticcheck
|
||||
require.True(ht, rpcInvoice.Settled)
|
||||
require.Equal(ht, lnrpc.Invoice_SETTLED, rpcInvoice.State)
|
||||
require.Equal(ht, int64(paymentAmt), rpcInvoice.AmtPaidSat)
|
||||
require.Equal(ht, int64(paymentAmt*1000), rpcInvoice.AmtPaidMsat)
|
||||
@ -561,7 +561,7 @@ func testSendToRouteAMP(ht *lntemp.HarnessTest) {
|
||||
rpcInvoice, err := bobInvoiceSubscription.Recv()
|
||||
require.NoError(ht, err)
|
||||
|
||||
require.False(ht, rpcInvoice.Settled) // nolint:staticcheck
|
||||
require.False(ht, rpcInvoice.Settled)
|
||||
require.Equal(ht, lnrpc.Invoice_OPEN, rpcInvoice.State)
|
||||
require.Equal(ht, int64(0), rpcInvoice.AmtPaidSat)
|
||||
require.Equal(ht, int64(0), rpcInvoice.AmtPaidMsat)
|
||||
@ -619,7 +619,7 @@ func testSendToRouteAMP(ht *lntemp.HarnessTest) {
|
||||
|
||||
// Assert that the invoice is settled for the total payment amount and
|
||||
// has the correct payment address.
|
||||
require.True(ht, rpcInvoice.Settled) // nolint:staticcheck
|
||||
require.True(ht, rpcInvoice.Settled)
|
||||
require.Equal(ht, lnrpc.Invoice_SETTLED, rpcInvoice.State)
|
||||
require.Equal(ht, int64(paymentAmt), rpcInvoice.AmtPaidSat)
|
||||
require.Equal(ht, int64(paymentAmt*1000), rpcInvoice.AmtPaidMsat)
|
||||
|
@ -363,6 +363,7 @@ func newInterceptorTestScenario(
|
||||
|
||||
ht.EnsureConnected(alice, bob)
|
||||
ht.EnsureConnected(bob, carol)
|
||||
|
||||
return &interceptorTestScenario{
|
||||
ht: ht,
|
||||
alice: alice,
|
||||
@ -377,22 +378,28 @@ func newInterceptorTestScenario(
|
||||
// 3. settling htlc externally.
|
||||
// 4. held htlc that is resumed later.
|
||||
func (c *interceptorTestScenario) prepareTestCases() []*interceptorTestCase {
|
||||
var (
|
||||
actionFail = routerrpc.ResolveHoldForwardAction_FAIL
|
||||
actionResume = routerrpc.ResolveHoldForwardAction_RESUME
|
||||
actionSettle = routerrpc.ResolveHoldForwardAction_SETTLE
|
||||
)
|
||||
|
||||
cases := []*interceptorTestCase{
|
||||
{
|
||||
amountMsat: 1000, shouldHold: false,
|
||||
interceptorAction: routerrpc.ResolveHoldForwardAction_FAIL,
|
||||
interceptorAction: actionFail,
|
||||
},
|
||||
{
|
||||
amountMsat: 1000, shouldHold: false,
|
||||
interceptorAction: routerrpc.ResolveHoldForwardAction_RESUME,
|
||||
interceptorAction: actionResume,
|
||||
},
|
||||
{
|
||||
amountMsat: 1000, shouldHold: false,
|
||||
interceptorAction: routerrpc.ResolveHoldForwardAction_SETTLE,
|
||||
interceptorAction: actionSettle,
|
||||
},
|
||||
{
|
||||
amountMsat: 1000, shouldHold: true,
|
||||
interceptorAction: routerrpc.ResolveHoldForwardAction_RESUME,
|
||||
interceptorAction: actionResume,
|
||||
},
|
||||
}
|
||||
|
||||
@ -432,6 +439,7 @@ func (c *interceptorTestScenario) sendPaymentAndAssertAction(
|
||||
PaymentHash: tc.invoice.RHash,
|
||||
Route: route,
|
||||
}
|
||||
|
||||
return c.alice.RPC.SendToRouteV2(sendReq)
|
||||
}
|
||||
|
||||
@ -483,5 +491,6 @@ func (c *interceptorTestScenario) buildRoute(amtMsat int64,
|
||||
}
|
||||
|
||||
routeResp := c.alice.RPC.BuildRoute(req)
|
||||
|
||||
return routeResp.Route
|
||||
}
|
||||
|
@ -347,6 +347,7 @@ func runBasicChannelCreationAndUpdates(ht *lntemp.HarnessTest,
|
||||
if i%3 == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
return fmt.Errorf("expected open or active" +
|
||||
"channel ntfn, got pending open " +
|
||||
"channel ntfn instead")
|
||||
@ -355,6 +356,7 @@ func runBasicChannelCreationAndUpdates(ht *lntemp.HarnessTest,
|
||||
if i%3 == 1 {
|
||||
continue
|
||||
}
|
||||
|
||||
return fmt.Errorf("expected pending open or " +
|
||||
"active channel ntfn, got open" +
|
||||
"channel ntfn instead")
|
||||
@ -494,8 +496,11 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
|
||||
// for each channel.
|
||||
switch update := chanUpdate.Channel.(type) {
|
||||
case *lnrpc.ChannelEventUpdate_InactiveChannel:
|
||||
if chanUpdate.Type != lnrpc.ChannelEventUpdate_INACTIVE_CHANNEL {
|
||||
return fmt.Errorf("update type mismatch: expected %v, got %v",
|
||||
if chanUpdate.Type !=
|
||||
lnrpc.ChannelEventUpdate_INACTIVE_CHANNEL {
|
||||
|
||||
return fmt.Errorf("update type mismatch: "+
|
||||
"expected %v, got %v",
|
||||
lnrpc.ChannelEventUpdate_INACTIVE_CHANNEL,
|
||||
chanUpdate.Type)
|
||||
}
|
||||
@ -504,7 +509,8 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
|
||||
if chanUpdate.Type !=
|
||||
lnrpc.ChannelEventUpdate_CLOSED_CHANNEL {
|
||||
|
||||
return fmt.Errorf("update type mismatch: expected %v, got %v",
|
||||
return fmt.Errorf("update type mismatch: "+
|
||||
"expected %v, got %v",
|
||||
lnrpc.ChannelEventUpdate_CLOSED_CHANNEL,
|
||||
chanUpdate.Type)
|
||||
}
|
||||
@ -517,14 +523,17 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
|
||||
}
|
||||
|
||||
if update.ClosedChannel.CloseInitiator != closeInitiator {
|
||||
return fmt.Errorf("expected close intiator: %v, got: %v",
|
||||
closeInitiator,
|
||||
return fmt.Errorf("expected close intiator: %v, "+
|
||||
"got: %v", closeInitiator,
|
||||
update.ClosedChannel.CloseInitiator)
|
||||
}
|
||||
|
||||
case *lnrpc.ChannelEventUpdate_FullyResolvedChannel:
|
||||
if chanUpdate.Type != lnrpc.ChannelEventUpdate_FULLY_RESOLVED_CHANNEL {
|
||||
return fmt.Errorf("update type mismatch: expected %v, got %v",
|
||||
if chanUpdate.Type !=
|
||||
lnrpc.ChannelEventUpdate_FULLY_RESOLVED_CHANNEL {
|
||||
|
||||
return fmt.Errorf("update type mismatch: "+
|
||||
"expected %v, got %v",
|
||||
lnrpc.ChannelEventUpdate_FULLY_RESOLVED_CHANNEL,
|
||||
chanUpdate.Type)
|
||||
}
|
||||
|
@ -670,7 +670,9 @@ func runSignPsbtSegWitV0P2WKH(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
||||
|
||||
// runSignPsbtSegWitV0NP2WKH tests that the SignPsbt RPC works correctly for a
|
||||
// SegWit v0 np2wkh input.
|
||||
func runSignPsbtSegWitV0NP2WKH(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
||||
func runSignPsbtSegWitV0NP2WKH(ht *lntemp.HarnessTest,
|
||||
alice *node.HarnessNode) {
|
||||
|
||||
// We test that we can sign a PSBT that spends funds from an input that
|
||||
// the wallet doesn't know about. To set up that test case, we first
|
||||
// derive an address manually that the wallet won't be watching on
|
||||
|
@ -389,6 +389,7 @@ func runSignVerifyMessage(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
||||
resp := alice.RPC.DeriveKey(keyLoc)
|
||||
pub, err := btcec.ParsePubKey(resp.RawKeyBytes)
|
||||
require.NoError(ht, err, "failed to parse node pubkey")
|
||||
|
||||
return pub
|
||||
}
|
||||
|
||||
|
@ -461,12 +461,14 @@ func testWalletImportAccount(ht *lntemp.HarnessTest) {
|
||||
addrType walletrpc.AddressType
|
||||
}{
|
||||
{
|
||||
name: "standard BIP-0049",
|
||||
addrType: walletrpc.AddressType_NESTED_WITNESS_PUBKEY_HASH,
|
||||
name: "standard BIP-0049",
|
||||
addrType: walletrpc.
|
||||
AddressType_NESTED_WITNESS_PUBKEY_HASH,
|
||||
},
|
||||
{
|
||||
name: "lnd BIP-0049 variant",
|
||||
addrType: walletrpc.AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH,
|
||||
name: "lnd BIP-0049 variant",
|
||||
addrType: walletrpc.
|
||||
AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH,
|
||||
},
|
||||
{
|
||||
name: "standard BIP-0084",
|
||||
@ -577,7 +579,8 @@ func runWalletImportAccountScenario(ht *lntemp.HarnessTest,
|
||||
// some assertions we'll make later on.
|
||||
balanceResp := dave.RPC.WalletBalance()
|
||||
require.Contains(ht, balanceResp.AccountBalance, importedAccount)
|
||||
confBalance := balanceResp.AccountBalance[importedAccount].ConfirmedBalance
|
||||
confBalance := balanceResp.AccountBalance[importedAccount].
|
||||
ConfirmedBalance
|
||||
|
||||
// Send coins to Carol's address and confirm them, making sure the
|
||||
// balance updates accordingly.
|
||||
@ -588,9 +591,13 @@ func runWalletImportAccountScenario(ht *lntemp.HarnessTest,
|
||||
}
|
||||
alice.RPC.SendCoins(req)
|
||||
|
||||
ht.AssertWalletAccountBalance(dave, importedAccount, confBalance, utxoAmt)
|
||||
ht.AssertWalletAccountBalance(
|
||||
dave, importedAccount, confBalance, utxoAmt,
|
||||
)
|
||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||
ht.AssertWalletAccountBalance(dave, importedAccount, confBalance+utxoAmt, 0)
|
||||
ht.AssertWalletAccountBalance(
|
||||
dave, importedAccount, confBalance+utxoAmt, 0,
|
||||
)
|
||||
|
||||
// Now that we have enough funds, it's time to fund the channel, make a
|
||||
// test payment, and close it. This contains several balance assertions
|
||||
@ -610,8 +617,9 @@ func testWalletImportPubKey(ht *lntemp.HarnessTest) {
|
||||
addrType walletrpc.AddressType
|
||||
}{
|
||||
{
|
||||
name: "BIP-0049",
|
||||
addrType: walletrpc.AddressType_NESTED_WITNESS_PUBKEY_HASH,
|
||||
name: "BIP-0049",
|
||||
addrType: walletrpc.
|
||||
AddressType_NESTED_WITNESS_PUBKEY_HASH,
|
||||
},
|
||||
{
|
||||
name: "BIP-0084",
|
||||
@ -686,7 +694,9 @@ func testWalletImportPubKeyScenario(ht *lntemp.HarnessTest,
|
||||
require.NoError(ht, err)
|
||||
externalAccountExtKey, err := accountPubKey.Derive(0)
|
||||
require.NoError(ht, err)
|
||||
externalAddrExtKey, err := externalAccountExtKey.Derive(keyIndex)
|
||||
externalAddrExtKey, err := externalAccountExtKey.Derive(
|
||||
keyIndex,
|
||||
)
|
||||
require.NoError(ht, err)
|
||||
externalAddrPubKey, err := externalAddrExtKey.ECPubKey()
|
||||
require.NoError(ht, err)
|
||||
|
@ -870,7 +870,6 @@ func testOptionScidUpgrade(ht *lntemp.HarnessTest) {
|
||||
// should be run in a goroutine and is used to test nodes with the zero-conf
|
||||
// feature bit.
|
||||
func acceptChannel(t *testing.T, zeroConf bool, stream rpc.AcceptorClient) {
|
||||
|
||||
t.Helper()
|
||||
|
||||
req, err := stream.Recv()
|
||||
|
Loading…
Reference in New Issue
Block a user