No longer require gas & gas price in transactions
Defaults to 0, which is then set to default values in XEth
This commit is contained in:
parent
015453f5b3
commit
b4eef59b6f
@ -207,7 +207,7 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
|
|||||||
args.Value = big.NewInt(num)
|
args.Value = big.NewInt(num)
|
||||||
|
|
||||||
if ext.Gas == nil {
|
if ext.Gas == nil {
|
||||||
return NewValidationError("gas", "is required")
|
num = 0
|
||||||
} else {
|
} else {
|
||||||
if err := numString(ext.Gas, &num); err != nil {
|
if err := numString(ext.Gas, &num); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -216,7 +216,7 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
|
|||||||
args.Gas = big.NewInt(num)
|
args.Gas = big.NewInt(num)
|
||||||
|
|
||||||
if ext.GasPrice == nil {
|
if ext.GasPrice == nil {
|
||||||
return NewValidationError("gasprice", "is required")
|
num = 0
|
||||||
} else {
|
} else {
|
||||||
if err := numString(ext.GasPrice, &num); err != nil {
|
if err := numString(ext.GasPrice, &num); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -468,11 +468,16 @@ func TestNewTxArgsGasMissing(t *testing.T) {
|
|||||||
"value": "0x9184e72a000",
|
"value": "0x9184e72a000",
|
||||||
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
|
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
|
||||||
}]`
|
}]`
|
||||||
|
expected := new(NewTxArgs)
|
||||||
|
expected.Gas = big.NewInt(0)
|
||||||
|
|
||||||
args := new(NewTxArgs)
|
args := new(NewTxArgs)
|
||||||
str := ExpectValidationError(json.Unmarshal([]byte(input), &args))
|
if err := json.Unmarshal([]byte(input), &args); err != nil {
|
||||||
if len(str) > 0 {
|
t.Error(err)
|
||||||
t.Error(str)
|
}
|
||||||
|
|
||||||
|
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",
|
"value": "0x9184e72a000",
|
||||||
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
|
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
|
||||||
}]`
|
}]`
|
||||||
|
expected := new(NewTxArgs)
|
||||||
|
expected.GasPrice = big.NewInt(0)
|
||||||
|
|
||||||
args := new(NewTxArgs)
|
args := new(NewTxArgs)
|
||||||
str := ExpectValidationError(json.Unmarshal([]byte(input), &args))
|
if err := json.Unmarshal([]byte(input), &args); err != nil {
|
||||||
if len(str) > 0 {
|
t.Error(err)
|
||||||
t.Error(str)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
func TestNewTxArgsValueMissing(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user