mirror of https://github.com/status-im/op-geth.git
Tests for magic words
This commit is contained in:
parent
2ea2261156
commit
20bae2b8f6
|
@ -2184,6 +2184,21 @@ func TestBlockNumArgs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBlockNumArgsWord(t *testing.T) {
|
||||
input := `["pending"]`
|
||||
expected := new(BlockNumIndexArgs)
|
||||
expected.BlockNumber = -2
|
||||
|
||||
args := new(BlockNumArg)
|
||||
if err := json.Unmarshal([]byte(input), &args); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if expected.BlockNumber != args.BlockNumber {
|
||||
t.Errorf("BlockNumber shoud be %#v but is %#v", expected.BlockNumber, args.BlockNumber)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlockNumArgsInvalid(t *testing.T) {
|
||||
input := `{}`
|
||||
|
||||
|
@ -2233,6 +2248,26 @@ func TestBlockNumIndexArgs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBlockNumIndexArgsWord(t *testing.T) {
|
||||
input := `["latest", 67]`
|
||||
expected := new(BlockNumIndexArgs)
|
||||
expected.BlockNumber = -1
|
||||
expected.Index = 67
|
||||
|
||||
args := new(BlockNumIndexArgs)
|
||||
if err := json.Unmarshal([]byte(input), &args); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if expected.BlockNumber != args.BlockNumber {
|
||||
t.Errorf("BlockNumber shoud be %#v but is %#v", expected.BlockNumber, args.BlockNumber)
|
||||
}
|
||||
|
||||
if expected.Index != args.Index {
|
||||
t.Errorf("Index shoud be %#v but is %#v", expected.Index, args.Index)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlockNumIndexArgsEmpty(t *testing.T) {
|
||||
input := `[]`
|
||||
|
||||
|
|
Loading…
Reference in New Issue