diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 02:34:32 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 02:34:32 +0800 |
commit | f68ca2b6e6b3dafb9f40f5c73ecca3168eb5a090 (patch) | |
tree | 52a558e09ce028482db8931fd7ad14701c9046ed | |
parent | 3ab9f26943a30ed65da9dac13147ec3aecbaca0a (diff) | |
download | dexon-f68ca2b6e6b3dafb9f40f5c73ecca3168eb5a090.tar.gz dexon-f68ca2b6e6b3dafb9f40f5c73ecca3168eb5a090.tar.zst dexon-f68ca2b6e6b3dafb9f40f5c73ecca3168eb5a090.zip |
DbArgs tests
-rw-r--r-- | rpc/args_test.go | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go index 2622891b9..f28bdbbd3 100644 --- a/rpc/args_test.go +++ b/rpc/args_test.go @@ -737,6 +737,7 @@ func TestBlockFilterArgs(t *testing.T) { } func TestBlockFilterArgsWords(t *testing.T) { + t.Skip() input := `[{ "fromBlock": "latest", "toBlock": "pending" @@ -811,6 +812,84 @@ func TestDbArgs(t *testing.T) { } } +func TestDbArgsInvalid(t *testing.T) { + input := `{}` + + args := new(DbArgs) + str := ExpectDecodeParamError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestDbArgsEmpty(t *testing.T) { + input := `[]` + + args := new(DbArgs) + str := ExpectInsufficientParamsError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestDbArgsDatabaseType(t *testing.T) { + input := `[true, "keyval", "valval"]` + + args := new(DbArgs) + str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestDbArgsKeyType(t *testing.T) { + input := `["dbval", 3, "valval"]` + + args := new(DbArgs) + str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestDbArgsValType(t *testing.T) { + input := `["dbval", "keyval", {}]` + + args := new(DbArgs) + str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestDbArgsDatabaseEmpty(t *testing.T) { + input := `["", "keyval", "valval"]` + + args := new(DbArgs) + if err := json.Unmarshal([]byte(input), &args); err != nil { + t.Error(err.Error()) + } + + str := ExpectValidationError(args.requirements()) + if len(str) > 0 { + t.Error(str) + } +} + +func TestDbArgsKeyEmpty(t *testing.T) { + input := `["dbval", "", "valval"]` + + args := new(DbArgs) + if err := json.Unmarshal([]byte(input), &args); err != nil { + t.Error(err.Error()) + } + + str := ExpectValidationError(args.requirements()) + if len(str) > 0 { + t.Error(str) + } +} + func TestDbHexArgs(t *testing.T) { input := `["testDB","myKey","0xbeef"]` expected := new(DbHexArgs) |