channeldb: use new for range directive in testcases
What changed, and why it matters
This commit only updates test code to use a newer Go language feature ('for range' over integers). It does not change any production code or affect how the software behaves when running live. There is no security relevance.
No action needed. This is a routine code-style/test modernization commit with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies channeldb/forwarding_log_test.go, replacing five C-style integer loops (for i := 0; i < numEvents; i++) with Go 1.22+’s for i := range numEvents syntax. This is a syntactic modernization inside unit tests only. No production logic, interfaces, cryptography, database schemas, or network handling are changed.
Changed components
channeldb/forwarding_log_test.goInspect captured patch +5 / −5
diff --git a/channeldb/forwarding_log_test.go b/channeldb/forwarding_log_test.go
index 0f589f8..ad80717 100644
--- a/channeldb/forwarding_log_test.go
+++ b/channeldb/forwarding_log_test.go
@@ -37,7 +37,7 @@ func TestForwardingLogBasicStorageAndQuery(t *testing.T) {
// minutes after the prior event.
numEvents := 100
events := make([]ForwardingEvent, numEvents)
- for i := 0; i < numEvents; i++ {
+ for i := range numEvents {
events[i] = ForwardingEvent{
Timestamp: timestamp,
IncomingChanID: lnwire.NewShortChanIDFromInt(uint64(rand.Int63())),
@@ -107,7 +107,7 @@ func TestForwardingLogQueryOptions(t *testing.T) {
// minutes after the prior event.
numEvents := 20
events := make([]ForwardingEvent, numEvents)
- for i := 0; i < numEvents; i++ {
+ for i := range numEvents {
events[i] = ForwardingEvent{
Timestamp: endTime,
IncomingChanID: lnwire.NewShortChanIDFromInt(uint64(rand.Int63())),
@@ -208,7 +208,7 @@ func TestForwardingLogQueryLimit(t *testing.T) {
// minutes after the prior event.
numEvents := 200
events := make([]ForwardingEvent, numEvents)
- for i := 0; i < numEvents; i++ {
+ for i := range numEvents {
events[i] = ForwardingEvent{
Timestamp: endTime,
IncomingChanID: lnwire.NewShortChanIDFromInt(uint64(rand.Int63())),
@@ -319,7 +319,7 @@ func TestForwardingLogStoreEvent(t *testing.T) {
numEvents := 20
events := make([]ForwardingEvent, numEvents)
ts := time.Now().UnixNano()
- for i := 0; i < numEvents; i++ {
+ for i := range numEvents {
events[i] = ForwardingEvent{
Timestamp: time.Unix(0, ts+int64(i)),
IncomingChanID: lnwire.NewShortChanIDFromInt(uint64(rand.Int63())),
@@ -503,7 +503,7 @@ func TestForwardingLogQueryChanIDs(t *testing.T) {
}
events := make([]ForwardingEvent, numEvents)
- for i := 0; i < numEvents; i++ {
+ for i := range numEvents {
events[i] = ForwardingEvent{
Timestamp: endTime,
IncomingChanID: incomingChanIDs[i%len(incomingChanIDs)],
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.