Fix SubmitPoolSyncCommitteeSignatures API endpoint (#9646)

* Fix `SubmitPoolSyncCommitteeSignatures` API endpoint

* fix test

* fix another test

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Radosław Kapka
2021-09-23 20:01:07 +02:00
committed by GitHub
parent 36b1f322c0
commit 1fbe05292f
7 changed files with 31 additions and 53 deletions

View File

@@ -366,14 +366,3 @@ func IsHex(b []byte) bool {
}
return hexRegex.Match(b)
}
// IsHexOfLen checks whether the byte array is a hex number prefixed with '0x' and containing the required number of digits.
func IsHexOfLen(b []byte, length uint64) bool {
if b == nil {
return false
}
matches := hexRegex.Match(b)
// Add 2 to account for '0x'
expectedLen := int(length) + 2
return matches && len(b) == expectedLen
}

View File

@@ -398,28 +398,6 @@ func TestIsHex(t *testing.T) {
}
}
func TestIsHexOfLen(t *testing.T) {
tests := []struct {
b []byte
l uint64
result bool
}{
{nil, 0, false},
{[]byte(""), 0, false},
{[]byte("0x"), 2, false},
{[]byte("0x0"), 2, false},
{[]byte("foo"), 3, false},
{[]byte("1234567890abcDEF"), 16, false},
{[]byte("XYZ4567890abcDEF1234567890abcDEF1234567890abcDEF1234567890abcDEF"), 64, false},
{[]byte("0x1234567890abcDEF1234567890abcDEF1234567890abcDEF1234567890abcDEF"), 64, true},
{[]byte("1234567890abcDEF1234567890abcDEF1234567890abcDEF1234567890abcDEF"), 64, false},
}
for _, tt := range tests {
isHex := bytesutil.IsHexOfLen(tt.b, tt.l)
assert.Equal(t, tt.result, isHex)
}
}
func TestSafeCopyRootAtIndex(t *testing.T) {
tests := []struct {
name string