added RPC start/stop support

This commit is contained in:
Bas van Kervel
2015-06-22 12:47:32 +02:00
parent 2737baa657
commit 2e0b56a72b
31 changed files with 224 additions and 130 deletions

View File

@ -41,6 +41,7 @@ import (
"github.com/ethereum/go-ethereum/xeth"
"github.com/peterh/liner"
"github.com/robertkrimen/otto"
"github.com/ethereum/go-ethereum/rpc/shared"
)
type prompter interface {
@ -183,7 +184,9 @@ func newJSRE(ethereum *eth.Ethereum, libPath, corsDomain string, client comms.Et
js.wait = js.xeth.UpdateState()
js.client = client
if clt, ok := js.client.(*comms.InProcClient); ok {
clt.Initialize(js.xeth, ethereum)
if offeredApis, err := api.ParseApiString(shared.AllApis, codec.JSON, js.xeth, ethereum); err == nil {
clt.Initialize(api.Merge(offeredApis...))
}
}
// update state in separare forever blocks
@ -311,7 +314,7 @@ func (js *jsre) apiBindings(f xeth.Frontend) error {
// load only supported API's in javascript runtime
shortcuts := "var eth = web3.eth; "
for _, apiName := range apiNames {
if apiName == api.Web3ApiName || apiName == api.EthApiName {
if apiName == shared.Web3ApiName || apiName == shared.EthApiName {
continue // manually mapped
}

View File

@ -210,7 +210,7 @@ func TestRPC(t *testing.T) {
defer ethereum.Stop()
defer os.RemoveAll(tmp)
checkEvalJSON(t, repl, `admin.startRPC("127.0.0.1", 5004)`, `true`)
checkEvalJSON(t, repl, `admin.startRPC("127.0.0.1", 5004, "*", "web3,eth,net")`, `true`)
}
func TestCheckTestAccountBalance(t *testing.T) {