aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-04-02 20:05:14 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-04-02 20:05:14 +0800
commitb4eef59b6f9631d22fdf62a2b1a40fe05209fccd (patch)
tree46b2505b306b7eddaac76ca08abb018454c9d0a8 /rpc
parent015453f5b3f5b78ac8f432aed2247c839a6e5049 (diff)
downloadgo-tangerine-b4eef59b6f9631d22fdf62a2b1a40fe05209fccd.tar
go-tangerine-b4eef59b6f9631d22fdf62a2b1a40fe05209fccd.tar.gz
go-tangerine-b4eef59b6f9631d22fdf62a2b1a40fe05209fccd.tar.bz2
go-tangerine-b4eef59b6f9631d22fdf62a2b1a40fe05209fccd.tar.lz
go-tangerine-b4eef59b6f9631d22fdf62a2b1a40fe05209fccd.tar.xz
go-tangerine-b4eef59b6f9631d22fdf62a2b1a40fe05209fccd.tar.zst
go-tangerine-b4eef59b6f9631d22fdf62a2b1a40fe05209fccd.zip
No longer require gas & gas price in transactions
Defaults to 0, which is then set to default values in XEth
Diffstat (limited to 'rpc')
-rw-r--r--rpc/args.go4
-rw-r--r--rpc/args_test.go23
2 files changed, 19 insertions, 8 deletions
diff --git a/rpc/args.go b/rpc/args.go
index df57e69c4..70618a01a 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -207,7 +207,7 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
args.Value = big.NewInt(num)
if ext.Gas == nil {
- return NewValidationError("gas", "is required")
+ num = 0
} else {
if err := numString(ext.Gas, &num); err != nil {
return err
@@ -216,7 +216,7 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
args.Gas = big.NewInt(num)
if ext.GasPrice == nil {
- return NewValidationError("gasprice", "is required")
+ num = 0
} else {
if err := numString(ext.GasPrice, &num); err != nil {
return err
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 8c1e8c478..902f8013e 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -468,11 +468,16 @@ func TestNewTxArgsGasMissing(t *testing.T) {
"value": "0x9184e72a000",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]`
+ expected := new(NewTxArgs)
+ expected.Gas = 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.Gas.Bytes(), args.Gas.Bytes()) != 0 {
+ t.Errorf("Gas shoud be %v but is %v", expected.Gas, args.Gas)
}
}
@@ -484,12 +489,18 @@ func TestNewTxArgsBlockGaspriceMissing(t *testing.T) {
"value": "0x9184e72a000",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]`
+ expected := new(NewTxArgs)
+ expected.GasPrice = 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.GasPrice.Bytes(), args.GasPrice.Bytes()) != 0 {
+ t.Errorf("GasPrice shoud be %v but is %v", expected.GasPrice, args.GasPrice)
+ }
+
}
func TestNewTxArgsValueMissing(t *testing.T) {