Skip to content

Commit

Permalink
fix: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Jun 5, 2024
1 parent 4ce5e48 commit c297567
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion p2psrv/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func isIncompatible(peerName string) bool {
// Extract the semantic version from the name
peerVersion := versionRegex.FindString(peerName)
if peerVersion == "" {
return false
return true
}

major := strings.Split(peerVersion, ".")[0]
Expand Down
8 changes: 8 additions & 0 deletions p2psrv/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ func TestIsIncompatible(t *testing.T) {
peerName: "thor/v3.1.1-88c7c86-release/linux/go1.21.9",
expected: false,
},
{
peerName: "",
expected: true,
},
{
peerName: "thor/v1.bad.v-88c7c86-release/linux/go1.21.9",
expected: true,
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit c297567

Please sign in to comment.