aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-04-02 19:55:53 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-04-02 19:55:53 +0800
commit015453f5b3f5b78ac8f432aed2247c839a6e5049 (patch)
tree154d7d13efb2a39253a80b7d4979251ba0172ede
parent118ad22ee59658ec8ff476999e48d9bffb0c7db6 (diff)
downloaddexon-015453f5b3f5b78ac8f432aed2247c839a6e5049.tar
dexon-015453f5b3f5b78ac8f432aed2247c839a6e5049.tar.gz
dexon-015453f5b3f5b78ac8f432aed2247c839a6e5049.tar.bz2
dexon-015453f5b3f5b78ac8f432aed2247c839a6e5049.tar.lz
dexon-015453f5b3f5b78ac8f432aed2247c839a6e5049.tar.xz
dexon-015453f5b3f5b78ac8f432aed2247c839a6e5049.tar.zst
dexon-015453f5b3f5b78ac8f432aed2247c839a6e5049.zip
Default Value to 0 for NewTxArgs
-rw-r--r--rpc/args.go2
-rw-r--r--rpc/args_test.go12
2 files changed, 10 insertions, 4 deletions
diff --git a/rpc/args.go b/rpc/args.go
index b43c465c0..df57e69c4 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -198,7 +198,7 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
var num int64
if ext.Value == nil {
- return NewValidationError("value", "is required")
+ num = 0
} else {
if err := numString(ext.Value, &num); err != nil {
return err
diff --git a/rpc/args_test.go b/rpc/args_test.go
index f00899b79..8c1e8c478 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -500,12 +500,18 @@ func TestNewTxArgsValueMissing(t *testing.T) {
"gasPrice": "0x9184e72a000",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]`
+ expected := new(NewTxArgs)
+ expected.Value = big.NewInt(0)
args := new(NewTxArgs)
- str := ExpectValidationError(json.Unmarshal([]byte(input), &args))
- if len(str) > 0 {
- t.Error(str)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
}
+
+ if bytes.Compare(expected.Value.Bytes(), args.Value.Bytes()) != 0 {
+ t.Errorf("Value shoud be %v but is %v", expected.Value, args.Value)
+ }
+
}
func TestNewTxArgsEmpty(t *testing.T) {