Skip to content

Commit 2737baa

Browse files
bas-vkBas van Kervel
authored andcommitted
fixed unittests
1 parent f87501b commit 2737baa

File tree

2 files changed

+10
-36
lines changed

2 files changed

+10
-36
lines changed

cmd/geth/js_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"github.com/ethereum/go-ethereum/core/state"
2121
"github.com/ethereum/go-ethereum/crypto"
2222
"github.com/ethereum/go-ethereum/eth"
23+
"github.com/ethereum/go-ethereum/rpc/comms"
24+
"github.com/ethereum/go-ethereum/rpc/codec"
2325
)
2426

2527
const (
@@ -105,7 +107,8 @@ func testJEthRE(t *testing.T) (string, *testjethre, *eth.Ethereum) {
105107
t.Errorf("Error creating DocServer: %v", err)
106108
}
107109
tf := &testjethre{ds: ds, stateDb: ethereum.ChainManager().State().Copy()}
108-
repl := newJSRE(ethereum, assetPath, "", "", false, tf)
110+
client := comms.NewInProcClient(codec.JSON)
111+
repl := newJSRE(ethereum, assetPath, "", client, false, tf)
109112
tf.jsre = repl
110113
return tmp, tf, ethereum
111114
}
@@ -125,7 +128,7 @@ func TestNodeInfo(t *testing.T) {
125128
defer ethereum.Stop()
126129
defer os.RemoveAll(tmp)
127130
want := `{"DiscPort":0,"IP":"0.0.0.0","ListenAddr":"","Name":"test","NodeID":"4cb2fc32924e94277bf94b5e4c983beedb2eabd5a0bc941db32202735c6625d020ca14a5963d1738af43b6ac0a711d61b1a06de931a499fe2aa0b1a132a902b5","NodeUrl":"enode://4cb2fc32924e94277bf94b5e4c983beedb2eabd5a0bc941db32202735c6625d020ca14a5963d1738af43b6ac0a711d61b1a06de931a499fe2aa0b1a132a902b5@0.0.0.0:0","TCPPort":0,"Td":"131072"}`
128-
checkEvalJSON(t, repl, `admin.nodeInfo()`, want)
131+
checkEvalJSON(t, repl, `admin.nodeInfo`, want)
129132
}
130133

131134
func TestAccounts(t *testing.T) {
@@ -139,7 +142,7 @@ func TestAccounts(t *testing.T) {
139142
checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`"]`)
140143
checkEvalJSON(t, repl, `eth.coinbase`, `"`+testAddress+`"`)
141144

142-
val, err := repl.re.Run(`admin.newAccount("password")`)
145+
val, err := repl.re.Run(`personal.newAccount("password")`)
143146
if err != nil {
144147
t.Errorf("expected no error, got %v", err)
145148
}
@@ -161,7 +164,7 @@ func TestBlockChain(t *testing.T) {
161164
defer ethereum.Stop()
162165
defer os.RemoveAll(tmp)
163166
// get current block dump before export/import.
164-
val, err := repl.re.Run("JSON.stringify(admin.debug.dumpBlock())")
167+
val, err := repl.re.Run("JSON.stringify(debug.dumpBlock(eth.blockNumber))")
165168
if err != nil {
166169
t.Errorf("expected no error, got %v", err)
167170
}
@@ -178,14 +181,14 @@ func TestBlockChain(t *testing.T) {
178181

179182
ethereum.ChainManager().Reset()
180183

181-
checkEvalJSON(t, repl, `admin.export(`+tmpfileq+`)`, `true`)
184+
checkEvalJSON(t, repl, `admin.exportChain(`+tmpfileq+`)`, `true`)
182185
if _, err := os.Stat(tmpfile); err != nil {
183186
t.Fatal(err)
184187
}
185188

186189
// check import, verify that dumpBlock gives the same result.
187-
checkEvalJSON(t, repl, `admin.import(`+tmpfileq+`)`, `true`)
188-
checkEvalJSON(t, repl, `admin.debug.dumpBlock()`, beforeExport)
190+
checkEvalJSON(t, repl, `admin.importChain(`+tmpfileq+`)`, `true`)
191+
checkEvalJSON(t, repl, `debug.dumpBlock(eth.blockNumber)`, beforeExport)
189192
}
190193

191194
func TestMining(t *testing.T) {

rpc/api/admin.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const (
2323
var (
2424
// mapping between methods and handlers
2525
AdminMapping = map[string]adminhandler{
26-
// "admin_startRPC": (*adminApi).StartRPC,
27-
// "admin_stopRPC": (*adminApi).StopRPC,
2826
"admin_addPeer": (*adminApi).AddPeer,
2927
"admin_peers": (*adminApi).Peers,
3028
"admin_nodeInfo": (*adminApi).NodeInfo,
@@ -103,33 +101,6 @@ func (self *adminApi) Peers(req *shared.Request) (interface{}, error) {
103101
return self.ethereum.PeersInfo(), nil
104102
}
105103

106-
func (self *adminApi) StartRPC(req *shared.Request) (interface{}, error) {
107-
return false, nil
108-
// Enable when http rpc interface is refactored to prevent import cycles
109-
// args := new(StartRpcArgs)
110-
// if err := self.codec.Decode(req.Params, &args); err != nil {
111-
// return nil, shared.NewDecodeParamError(err.Error())
112-
// }
113-
//
114-
// cfg := rpc.RpcConfig{
115-
// ListenAddress: args.Address,
116-
// ListenPort: args.Port,
117-
// }
118-
//
119-
// err := rpc.Start(self.xeth, cfg)
120-
// if err == nil {
121-
// return true, nil
122-
// }
123-
// return false, err
124-
}
125-
126-
func (self *adminApi) StopRPC(req *shared.Request) (interface{}, error) {
127-
return false, nil
128-
// Enable when http rpc interface is refactored to prevent import cycles
129-
// rpc.Stop()
130-
// return true, nil
131-
}
132-
133104
func (self *adminApi) NodeInfo(req *shared.Request) (interface{}, error) {
134105
return self.ethereum.NodeInfo(), nil
135106
}

0 commit comments

Comments
 (0)