Skip to content

refactor: use a more modern writing style to simplify code #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions challenger/lnd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ func (m *mockInvoiceClient) ListInvoices(_ context.Context,
return &lnrpc.ListInvoiceResponse{}, nil
}

endIndex := r.IndexOffset + r.NumMaxInvoices
if endIndex > uint64(len(m.invoices)) {
endIndex = uint64(len(m.invoices))
}
endIndex := min(r.IndexOffset+r.NumMaxInvoices, uint64(len(m.invoices)))

return &lnrpc.ListInvoiceResponse{
Invoices: m.invoices[r.IndexOffset:endIndex],
Expand Down
7 changes: 3 additions & 4 deletions l402/satisfier.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package l402

import (
"fmt"
"slices"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -109,10 +110,8 @@ func NewCapabilitiesSatisfier(service string,
},
SatisfyFinal: func(c Caveat) error {
capabilities := strings.Split(c.Value, ",")
for _, capability := range capabilities {
if capability == targetCapability {
return nil
}
if slices.Contains(capabilities, targetCapability) {
return nil
}
return fmt.Errorf("target capability %v not authorized",
targetCapability)
Expand Down
9 changes: 2 additions & 7 deletions proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"os"
"path"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -576,13 +577,7 @@ func configFromCert(crt *tls.Certificate, certPool *x509.CertPool) *tls.Config {
tlsConf.RootCAs = certPool
tlsConf.InsecureSkipVerify = true

haveNPN := false
for _, p := range tlsConf.NextProtos {
if p == "h2" {
haveNPN = true
break
}
}
haveNPN := slices.Contains(tlsConf.NextProtos, "h2")
if !haveNPN {
tlsConf.NextProtos = append(tlsConf.NextProtos, "h2")
}
Expand Down