aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args_test.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-04-23 02:24:29 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-04-23 02:24:29 +0800
commit20bae2b8f6fb46440f0b7e6d83916c422fd84567 (patch)
tree12fabb39dffeff4577e16bf3167e48b8aeb570d9 /rpc/args_test.go
parent2ea2261156eae9e7d783ff5f8663ad95113c8386 (diff)
downloaddexon-20bae2b8f6fb46440f0b7e6d83916c422fd84567.tar
dexon-20bae2b8f6fb46440f0b7e6d83916c422fd84567.tar.gz
dexon-20bae2b8f6fb46440f0b7e6d83916c422fd84567.tar.bz2
dexon-20bae2b8f6fb46440f0b7e6d83916c422fd84567.tar.lz
dexon-20bae2b8f6fb46440f0b7e6d83916c422fd84567.tar.xz
dexon-20bae2b8f6fb46440f0b7e6d83916c422fd84567.tar.zst
dexon-20bae2b8f6fb46440f0b7e6d83916c422fd84567.zip
Tests for magic words
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r--rpc/args_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 9e0cf179f..2f011bfd9 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -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 := `[]`