refactor: use slices.Contains to simplify code#1159
Conversation
|
PR author is not in the allowed authors list. |
aljo242
left a comment
There was a problem hiding this comment.
behavioral regression in filters/utils.go: the original loop sets match := len(sub) == 0 -- an empty sub-slice is a wildcard (matches any topic at that position). slices.Contains(sub, ...) on an empty slice returns false, so a filter like [][]common.Hash{{}} now rejects all logs at position 0 instead of accepting all. this breaks the ethereum filter spec.
test gap: the test case named "empty topic sub-array (wildcard)" uses topics: [][]common.Hash{} (empty outer array), which skips the loop entirely and doesn't exercise the broken path. add a case with [][]common.Hash{{}} (one empty inner slice = position-0 wildcard) and verify it still returns all logs.
the authz.go change is correct and clean.
Modified and also rebased the latest code. Please review it again. @aljo242 Thanks~ |
Signed-off-by: chuanshanjida <chuanshanjida@outlook.com>
|
@aljo242 Thanks for your review! If there's anything need I to do, please feel free to let me know. |
|
@aljo242 friendly ping~ |


Description
There is a new function added in the go1.21 standard library, which can make the code more concise and easy to read.
The new pr with unit test for #1101
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
mainbranch