diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-26 18:59:35 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-26 18:59:35 +0800 |
commit | 300d36b8640cf195db0f7997cc946ab5f164828f (patch) | |
tree | 4663f915ca35bc77ceb97cce4825bbe6046bcb2c /rpc/args_test.go | |
parent | ad2089b0a3a495d8584209b6e31dde153cac7088 (diff) | |
download | dexon-300d36b8640cf195db0f7997cc946ab5f164828f.tar dexon-300d36b8640cf195db0f7997cc946ab5f164828f.tar.gz dexon-300d36b8640cf195db0f7997cc946ab5f164828f.tar.bz2 dexon-300d36b8640cf195db0f7997cc946ab5f164828f.tar.lz dexon-300d36b8640cf195db0f7997cc946ab5f164828f.tar.xz dexon-300d36b8640cf195db0f7997cc946ab5f164828f.tar.zst dexon-300d36b8640cf195db0f7997cc946ab5f164828f.zip |
improved NewTxArgs tests
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r-- | rpc/args_test.go | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go index b9a68d8bc..e5a27e38a 100644 --- a/rpc/args_test.go +++ b/rpc/args_test.go @@ -300,13 +300,66 @@ func TestNewTxArgsBlockInt(t *testing.T) { } } +func TestNewTxArgsBlockInvalid(t *testing.T) { + input := `[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, false]` + expected := new(NewTxArgs) + expected.From = common.HexToAddress("0xb60e8dd61c5d32be8058bb8eb970870f07233155") + expected.BlockNumber = big.NewInt(5).Int64() + + args := new(NewTxArgs) + err := json.Unmarshal([]byte(input), &args) + switch err.(type) { + case nil: + t.Error("Expected error but didn't get one") + case *DecodeParamError: + break + default: + t.Errorf("Expeted *rpc.DecodeParamError but got %T with message `%s`", err, err.Error()) + } + +} + func TestNewTxArgsEmpty(t *testing.T) { input := `[]` args := new(NewTxArgs) err := json.Unmarshal([]byte(input), &args) - if err == nil { + switch err.(type) { + case nil: + t.Error("Expected error but didn't get one") + case *InsufficientParamsError: + break + default: + t.Errorf("Expeted *rpc.InsufficientParamsError but got %T with message `%s`", err, err.Error()) + } +} + +func TestNewTxArgsInvalid(t *testing.T) { + input := `{}` + + args := new(NewTxArgs) + err := json.Unmarshal([]byte(input), &args) + switch err.(type) { + case nil: t.Error("Expected error but didn't get one") + case *DecodeParamError: + break + default: + t.Errorf("Expeted *rpc.DecodeParamError but got %T with message `%s`", err, err.Error()) + } +} +func TestNewTxArgsNotStrings(t *testing.T) { + input := `[{"from":6}]` + + args := new(NewTxArgs) + err := json.Unmarshal([]byte(input), &args) + switch err.(type) { + case nil: + t.Error("Expected error but didn't get one") + case *DecodeParamError: + break + default: + t.Errorf("Expeted *rpc.DecodeParamError but got %T with message `%s`", err, err.Error()) } } |