diff options
author | Felix Lange <fjl@twurst.com> | 2015-04-22 16:59:27 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-04-22 18:31:19 +0800 |
commit | e1f616fadf4fe20030d518d0c3f2a3f05186ab68 (patch) | |
tree | 74634a9f8ea2307554d1a675a741215bd872d8f7 /cmd/geth/admin.go | |
parent | 635b66acdccc1e9b3793c67a846675dfbb08b6f8 (diff) | |
download | dexon-e1f616fadf4fe20030d518d0c3f2a3f05186ab68.tar dexon-e1f616fadf4fe20030d518d0c3f2a3f05186ab68.tar.gz dexon-e1f616fadf4fe20030d518d0c3f2a3f05186ab68.tar.bz2 dexon-e1f616fadf4fe20030d518d0c3f2a3f05186ab68.tar.lz dexon-e1f616fadf4fe20030d518d0c3f2a3f05186ab68.tar.xz dexon-e1f616fadf4fe20030d518d0c3f2a3f05186ab68.tar.zst dexon-e1f616fadf4fe20030d518d0c3f2a3f05186ab68.zip |
cmd/geth: improve the JS tests
These changes ensure that the JS tests run without networking
and fixes the block chain export and its associated test.
Diffstat (limited to 'cmd/geth/admin.go')
-rw-r--r-- | cmd/geth/admin.go | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go index bd09291bf..e75ff047a 100644 --- a/cmd/geth/admin.go +++ b/cmd/geth/admin.go @@ -3,7 +3,6 @@ package main import ( "errors" "fmt" - "os" "time" "github.com/ethereum/go-ethereum/cmd/utils" @@ -318,7 +317,7 @@ func (js *jsre) newAccount(call otto.FunctionCall) otto.Value { fmt.Printf("Could not create the account: %v", err) return otto.UndefinedValue() } - return js.re.ToVal(common.Bytes2Hex(acct.Address)) + return js.re.ToVal("0x" + common.Bytes2Hex(acct.Address)) } func (js *jsre) nodeInfo(call otto.FunctionCall) otto.Value { @@ -334,33 +333,15 @@ func (js *jsre) importChain(call otto.FunctionCall) otto.Value { fmt.Println("err: require file name") return otto.FalseValue() } - fn, err := call.Argument(0).ToString() if err != nil { fmt.Println(err) return otto.FalseValue() } - - var fh *os.File - fh, err = os.OpenFile(fn, os.O_RDONLY, os.ModePerm) - if err != nil { - fmt.Println(err) + if err := utils.ImportChain(js.ethereum.ChainManager(), fn); err != nil { + fmt.Println("Import error: ", err) return otto.FalseValue() } - defer fh.Close() - - var blocks types.Blocks - if err = rlp.Decode(fh, &blocks); err != nil { - fmt.Println(err) - return otto.FalseValue() - } - - js.ethereum.ChainManager().Reset() - if err = js.ethereum.ChainManager().InsertChain(blocks); err != nil { - fmt.Println(err) - return otto.FalseValue() - } - return otto.TrueValue() } |