Fix Goodbye Codes In Prysm (#11168)

* fix goodbye codes

* gaz

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Nishant Das
2022-08-04 22:11:45 +08:00
committed by GitHub
parent cef95dd5b2
commit e169ce9107
3 changed files with 14 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ go_test(
embed = [":go_default_library"],
deps = [
"//config/params:go_default_library",
"//consensus-types/primitives:go_default_library",
"//encoding/bytesutil:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",

View File

@@ -9,7 +9,7 @@ type RPCGoodbyeCode = types.SSZUint64
const (
// Spec defined codes.
GoodbyeCodeClientShutdown RPCGoodbyeCode = iota
GoodbyeCodeClientShutdown RPCGoodbyeCode = iota + 1
GoodbyeCodeWrongNetwork
GoodbyeCodeGenericError

View File

@@ -5,6 +5,7 @@ import (
"testing"
"github.com/prysmaticlabs/prysm/config/params"
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/testing/assert"
"github.com/prysmaticlabs/prysm/testing/require"
)
@@ -107,6 +108,17 @@ func TestSSZBytes_HashTreeRoot(t *testing.T) {
}
}
func TestGoodbyeCodes(t *testing.T) {
assert.Equal(t, types.SSZUint64(1), GoodbyeCodeClientShutdown)
assert.Equal(t, types.SSZUint64(2), GoodbyeCodeWrongNetwork)
assert.Equal(t, types.SSZUint64(3), GoodbyeCodeGenericError)
assert.Equal(t, types.SSZUint64(128), GoodbyeCodeUnableToVerifyNetwork)
assert.Equal(t, types.SSZUint64(129), GoodbyeCodeTooManyPeers)
assert.Equal(t, types.SSZUint64(250), GoodbyeCodeBadScore)
assert.Equal(t, types.SSZUint64(251), GoodbyeCodeBanned)
}
func hexDecodeOrDie(t *testing.T, str string) []byte {
decoded, err := hex.DecodeString(str)
require.NoError(t, err)