fixed eth sign unittest

This commit is contained in:
Bas van Kervel 2015-06-22 13:19:59 +02:00
parent 2e0b56a72b
commit 6d596b1ad1
5 changed files with 27 additions and 9 deletions

View File

@ -46,7 +46,7 @@ var (
"eth_getData": (*ethApi).GetData, "eth_getData": (*ethApi).GetData,
"eth_getCode": (*ethApi).GetData, "eth_getCode": (*ethApi).GetData,
"eth_sign": (*ethApi).Sign, "eth_sign": (*ethApi).Sign,
"eth_sendRawTransaction": (*ethApi).PushTx, "eth_sendRawTransaction": (*ethApi).SendRawTransaction,
"eth_sendTransaction": (*ethApi).SendTransaction, "eth_sendTransaction": (*ethApi).SendTransaction,
"eth_transact": (*ethApi).SendTransaction, "eth_transact": (*ethApi).SendTransaction,
"eth_estimateGas": (*ethApi).EstimateGas, "eth_estimateGas": (*ethApi).EstimateGas,
@ -250,7 +250,7 @@ func (self *ethApi) Sign(req *shared.Request) (interface{}, error) {
return v, nil return v, nil
} }
func (self *ethApi) PushTx(req *shared.Request) (interface{}, error) { func (self *ethApi) SendRawTransaction(req *shared.Request) (interface{}, error) {
args := new(NewDataArgs) args := new(NewDataArgs)
if err := self.codec.Decode(req.Params, &args); err != nil { if err := self.codec.Decode(req.Params, &args); err != nil {
return nil, shared.NewDecodeParamError(err.Error()) return nil, shared.NewDecodeParamError(err.Error())

View File

@ -466,21 +466,21 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
} }
args.Value = num args.Value = num
if ext.Gas == nil { if ext.Gas != nil {
num = big.NewInt(0)
} else {
if num, err = numString(ext.Gas); err != nil { if num, err = numString(ext.Gas); err != nil {
return err return err
} }
} else {
num = nil
} }
args.Gas = num args.Gas = num
if ext.GasPrice == nil { if ext.GasPrice != nil {
num = big.NewInt(0)
} else {
if num, err = numString(ext.GasPrice); err != nil { if num, err = numString(ext.GasPrice); err != nil {
return err return err
} }
} else {
num = nil
} }
args.GasPrice = num args.GasPrice = num

View File

@ -1,3 +1,20 @@
package api package api
// JS api provided by web3.js // JS api provided by web3.js
// eth_sign not standard
const Eth_JS = `
web3._extend({
property: 'eth',
methods:
[
new web3._extend.Method({
name: 'sign',
call: 'eth_sign',
params: 2,
inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString],
outputFormatter: web3._extend.formatters.formatOutputString
})
]
});
`

View File

@ -178,6 +178,8 @@ func Javascript(name string) string {
return Debug_JS return Debug_JS
case shared.DbApiName: case shared.DbApiName:
return Db_JS return Db_JS
case shared.EthApiName:
return Eth_JS
case shared.MinerApiName: case shared.MinerApiName:
return Miner_JS return Miner_JS
case shared.NetApiName: case shared.NetApiName:

View File

@ -25,4 +25,3 @@ var (
ShhApiName, TxPoolApiName, PersonalApiName, Web3ApiName, ShhApiName, TxPoolApiName, PersonalApiName, Web3ApiName,
}, ",") }, ",")
) )