-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix peers filtering, increase the version (#126)
- Loading branch information
Showing
3 changed files
with
42 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package gossip | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/p2p/discover/discfilter" | ||
"github.com/ethereum/go-ethereum/p2p/enode" | ||
"testing" | ||
) | ||
|
||
func TestIsUseless(t *testing.T) { | ||
validEnode := enode.MustParse("enode://3f4306c065eaa5d8079e17feb56c03a97577e67af3c9c17496bb8916f102f1ff603e87d2a4ebfa0a2f70b780b85db212618857ea4e9627b24a9b0dd2faeb826e@127.0.0.1:5050") | ||
sonicName := "Sonic/v1.0.0-a-61af51c2-1715085138/linux-amd64/go1.21.7" | ||
operaName := "go-opera/v1.1.2-rc.6-8e84c9dc-1688013329/linux-amd64/go1.19.11" | ||
invalidName := "bot" | ||
|
||
discfilter.Enable() | ||
if isUseless(validEnode, sonicName) { | ||
t.Errorf("sonic peer reported as useless") | ||
} | ||
if isUseless(validEnode, operaName) { | ||
t.Errorf("opera peer reported as useless") | ||
} | ||
if !isUseless(validEnode, invalidName) { | ||
t.Errorf("invalid peer not reported as useless") | ||
} | ||
if !isUseless(validEnode, operaName) { | ||
t.Errorf("peer not banned after marking as useless") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters