mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
0d4b98cd0a
* Add REST implementation for Validator's WaitForChainStart * Add missing error mapping * Add missing bazel dependency * Add missing tests * Address PR comments * Replace EventErrorJson with DefaultErrorJson * Add tests for WaitForChainStart * Refactor tests * Address PR comments * Add gazelle:build_tag use_beacon_api comment in BUILD.bazel * Address PR comments * Address PR comments Co-authored-by: Radosław Kapka <rkapka@wp.pl>
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
//go:build use_beacon_api
|
|
// +build use_beacon_api
|
|
|
|
package beacon_api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
|
)
|
|
|
|
func TestBeaconApiHelpers(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
valid bool
|
|
}{
|
|
{
|
|
name: "correct format",
|
|
input: "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
|
|
valid: true,
|
|
},
|
|
{
|
|
name: "root too small",
|
|
input: "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f",
|
|
valid: false,
|
|
},
|
|
{
|
|
name: "root too big",
|
|
input: "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f22",
|
|
valid: false,
|
|
},
|
|
{
|
|
name: "empty root",
|
|
input: "",
|
|
valid: false,
|
|
},
|
|
{
|
|
name: "no 0x prefix",
|
|
input: "cf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
|
|
valid: false,
|
|
},
|
|
{
|
|
name: "invalid characters",
|
|
input: "0xzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",
|
|
valid: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert.Equal(t, tt.valid, validRoot(tt.input))
|
|
})
|
|
}
|
|
}
|