lntemp+lntest: fix make lint

This commit is contained in:
yyforyongyu 2022-10-25 21:27:40 +08:00
parent f9ede5af73
commit fe376385d1
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
3 changed files with 51 additions and 36 deletions

View File

@ -14,6 +14,8 @@ import (
// UpdateChanStatus makes a UpdateChanStatus RPC call to node's RouterClient // UpdateChanStatus makes a UpdateChanStatus RPC call to node's RouterClient
// and asserts. // and asserts.
//
//nolint:lll
func (h *HarnessRPC) UpdateChanStatus( func (h *HarnessRPC) UpdateChanStatus(
req *routerrpc.UpdateChanStatusRequest) *routerrpc.UpdateChanStatusResponse { req *routerrpc.UpdateChanStatusRequest) *routerrpc.UpdateChanStatusResponse {

View File

@ -487,7 +487,7 @@ func executePgQuery(query string) error {
postgresDatabaseDsn("postgres"), postgresDatabaseDsn("postgres"),
) )
if err != nil { if err != nil {
return fmt.Errorf("unable to connect to database: %v", err) return fmt.Errorf("unable to connect to database: %w", err)
} }
defer pool.Close() defer pool.Close()

View File

@ -901,73 +901,86 @@ func testQueryRoutes(ht *lntemp.HarnessTest) {
for i, route := range routesRes.Routes { for i, route := range routesRes.Routes {
expectedTotalFeesMSat := expectedTotalFeesMSat :=
lnwire.MilliSatoshi(len(route.Hops)-1) * feePerHopMSat lnwire.MilliSatoshi(len(route.Hops)-1) * feePerHopMSat
expectedTotalAmtMSat := (paymentAmt * mSat) + expectedTotalFeesMSat
if route.TotalFees != route.TotalFeesMsat/mSat { // nolint:staticcheck expectedTotalAmtMSat :=
(paymentAmt * mSat) + expectedTotalFeesMSat
if route.TotalFees != route.TotalFeesMsat/mSat {
ht.Fatalf("route %v: total fees %v (msat) does not "+ ht.Fatalf("route %v: total fees %v (msat) does not "+
"round down to %v (sat)", "round down to %v (sat)",
i, route.TotalFeesMsat, route.TotalFees) // nolint:staticcheck i, route.TotalFeesMsat, route.TotalFees)
} }
if route.TotalFeesMsat != int64(expectedTotalFeesMSat) { if route.TotalFeesMsat != int64(expectedTotalFeesMSat) {
ht.Fatalf("route %v: total fees in msat expected %v got %v", ht.Fatalf("route %v: total fees in msat expected %v "+
i, expectedTotalFeesMSat, route.TotalFeesMsat) "got %v", i, expectedTotalFeesMSat,
route.TotalFeesMsat)
} }
if route.TotalAmt != route.TotalAmtMsat/mSat { // nolint:staticcheck if route.TotalAmt != route.TotalAmtMsat/mSat {
ht.Fatalf("route %v: total amt %v (msat) does not "+ ht.Fatalf("route %v: total amt %v (msat) does not "+
"round down to %v (sat)", "round down to %v (sat)",
i, route.TotalAmtMsat, route.TotalAmt) // nolint:staticcheck i, route.TotalAmtMsat, route.TotalAmt)
} }
if route.TotalAmtMsat != int64(expectedTotalAmtMSat) { if route.TotalAmtMsat != int64(expectedTotalAmtMSat) {
ht.Fatalf("route %v: total amt in msat expected %v got %v", ht.Fatalf("route %v: total amt in msat expected %v "+
i, expectedTotalAmtMSat, route.TotalAmtMsat) "got %v", i, expectedTotalAmtMSat,
route.TotalAmtMsat)
} }
// For all hops except the last, we check that fee equals feePerHop // For all hops except the last, we check that fee equals
// and amount to forward deducts feePerHop on each hop. // feePerHop and amount to forward deducts feePerHop on each
// hop.
expectedAmtToForwardMSat := expectedTotalAmtMSat expectedAmtToForwardMSat := expectedTotalAmtMSat
for j, hop := range route.Hops[:len(route.Hops)-1] { for j, hop := range route.Hops[:len(route.Hops)-1] {
expectedAmtToForwardMSat -= feePerHopMSat expectedAmtToForwardMSat -= feePerHopMSat
if hop.Fee != hop.FeeMsat/mSat { // nolint:staticcheck if hop.Fee != hop.FeeMsat/mSat {
ht.Fatalf("route %v hop %v: fee %v (msat) does not "+ ht.Fatalf("route %v hop %v: fee %v (msat) "+
"round down to %v (sat)", "does not round down to %v (sat)",
i, j, hop.FeeMsat, hop.Fee) // nolint:staticcheck i, j, hop.FeeMsat, hop.Fee)
} }
if hop.FeeMsat != int64(feePerHopMSat) { if hop.FeeMsat != int64(feePerHopMSat) {
ht.Fatalf("route %v hop %v: fee in msat expected %v got %v", ht.Fatalf("route %v hop %v: fee in msat "+
"expected %v got %v",
i, j, feePerHopMSat, hop.FeeMsat) i, j, feePerHopMSat, hop.FeeMsat)
} }
if hop.AmtToForward != hop.AmtToForwardMsat/mSat { // nolint:staticcheck if hop.AmtToForward != hop.AmtToForwardMsat/mSat {
ht.Fatalf("route %v hop %v: amt to forward %v (msat) does not "+ ht.Fatalf("route %v hop %v: amt to forward %v"+
"round down to %v (sat)", "(msat) does not round down to %v(sat)",
i, j, hop.AmtToForwardMsat, hop.AmtToForward) // nolint:staticcheck i, j, hop.AmtToForwardMsat,
hop.AmtToForward)
} }
if hop.AmtToForwardMsat != int64(expectedAmtToForwardMSat) { if hop.AmtToForwardMsat !=
ht.Fatalf("route %v hop %v: amt to forward in msat "+ int64(expectedAmtToForwardMSat) {
"expected %v got %v",
i, j, expectedAmtToForwardMSat, hop.AmtToForwardMsat) ht.Fatalf("route %v hop %v: amt to forward "+
"in msat expected %v got %v",
i, j, expectedAmtToForwardMSat,
hop.AmtToForwardMsat)
} }
} }
// Last hop should have zero fee and amount to forward should equal
// payment amount. // Last hop should have zero fee and amount to forward should
// equal payment amount.
hop := route.Hops[len(route.Hops)-1] hop := route.Hops[len(route.Hops)-1]
if hop.Fee != 0 || hop.FeeMsat != 0 { // nolint:staticcheck if hop.Fee != 0 || hop.FeeMsat != 0 {
ht.Fatalf("route %v hop %v: fee expected 0 got %v (sat) %v (msat)", ht.Fatalf("route %v hop %v: fee expected 0 got %v "+
i, len(route.Hops)-1, hop.Fee, hop.FeeMsat) // nolint:staticcheck "(sat) %v (msat)", i, len(route.Hops)-1,
hop.Fee, hop.FeeMsat)
} }
if hop.AmtToForward != hop.AmtToForwardMsat/mSat { // nolint:staticcheck if hop.AmtToForward != hop.AmtToForwardMsat/mSat {
ht.Fatalf("route %v hop %v: amt to forward %v (msat) does not "+ ht.Fatalf("route %v hop %v: amt to forward %v (msat) "+
"round down to %v (sat)", "does not round down to %v (sat)", i,
i, len(route.Hops)-1, hop.AmtToForwardMsat, hop.AmtToForward) // nolint:staticcheck len(route.Hops)-1, hop.AmtToForwardMsat,
hop.AmtToForward)
} }
if hop.AmtToForwardMsat != paymentAmt*mSat { if hop.AmtToForwardMsat != paymentAmt*mSat {
ht.Fatalf("route %v hop %v: amt to forward in msat "+ ht.Fatalf("route %v hop %v: amt to forward in msat "+
"expected %v got %v", "expected %v got %v", i, len(route.Hops)-1,
i, len(route.Hops)-1, paymentAmt*mSat, hop.AmtToForwardMsat) paymentAmt*mSat, hop.AmtToForwardMsat)
} }
} }