|
|
@ -69,7 +69,7 @@ func TestStartRPC(t *testing.T) { |
|
|
|
name: "rpc enabled through API", |
|
|
|
name: "rpc enabled through API", |
|
|
|
cfg: Config{}, |
|
|
|
cfg: Config{}, |
|
|
|
fn: func(t *testing.T, n *Node, api *privateAdminAPI) { |
|
|
|
fn: func(t *testing.T, n *Node, api *privateAdminAPI) { |
|
|
|
_, err := api.StartRPC(sp("127.0.0.1"), ip(0), nil, nil, nil) |
|
|
|
_, err := api.StartHTTP(sp("127.0.0.1"), ip(0), nil, nil, nil) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
}, |
|
|
|
}, |
|
|
|
wantReachable: true, |
|
|
|
wantReachable: true, |
|
|
@ -90,14 +90,14 @@ func TestStartRPC(t *testing.T) { |
|
|
|
port := listener.Addr().(*net.TCPAddr).Port |
|
|
|
port := listener.Addr().(*net.TCPAddr).Port |
|
|
|
|
|
|
|
|
|
|
|
// Now try to start RPC on that port. This should fail.
|
|
|
|
// Now try to start RPC on that port. This should fail.
|
|
|
|
_, err = api.StartRPC(sp("127.0.0.1"), ip(port), nil, nil, nil) |
|
|
|
_, err = api.StartHTTP(sp("127.0.0.1"), ip(port), nil, nil, nil) |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
t.Fatal("StartRPC should have failed on port", port) |
|
|
|
t.Fatal("StartHTTP should have failed on port", port) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Try again after unblocking the port. It should work this time.
|
|
|
|
// Try again after unblocking the port. It should work this time.
|
|
|
|
listener.Close() |
|
|
|
listener.Close() |
|
|
|
_, err = api.StartRPC(sp("127.0.0.1"), ip(port), nil, nil, nil) |
|
|
|
_, err = api.StartHTTP(sp("127.0.0.1"), ip(port), nil, nil, nil) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
}, |
|
|
|
}, |
|
|
|
wantReachable: true, |
|
|
|
wantReachable: true, |
|
|
@ -109,7 +109,7 @@ func TestStartRPC(t *testing.T) { |
|
|
|
name: "rpc stopped through API", |
|
|
|
name: "rpc stopped through API", |
|
|
|
cfg: Config{HTTPHost: "127.0.0.1"}, |
|
|
|
cfg: Config{HTTPHost: "127.0.0.1"}, |
|
|
|
fn: func(t *testing.T, n *Node, api *privateAdminAPI) { |
|
|
|
fn: func(t *testing.T, n *Node, api *privateAdminAPI) { |
|
|
|
_, err := api.StopRPC() |
|
|
|
_, err := api.StopHTTP() |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
}, |
|
|
|
}, |
|
|
|
wantReachable: false, |
|
|
|
wantReachable: false, |
|
|
@ -121,10 +121,10 @@ func TestStartRPC(t *testing.T) { |
|
|
|
name: "rpc stopped twice", |
|
|
|
name: "rpc stopped twice", |
|
|
|
cfg: Config{HTTPHost: "127.0.0.1"}, |
|
|
|
cfg: Config{HTTPHost: "127.0.0.1"}, |
|
|
|
fn: func(t *testing.T, n *Node, api *privateAdminAPI) { |
|
|
|
fn: func(t *testing.T, n *Node, api *privateAdminAPI) { |
|
|
|
_, err := api.StopRPC() |
|
|
|
_, err := api.StopHTTP() |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
|
|
|
|
|
|
|
|
_, err = api.StopRPC() |
|
|
|
_, err = api.StopHTTP() |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
}, |
|
|
|
}, |
|
|
|
wantReachable: false, |
|
|
|
wantReachable: false, |
|
|
@ -211,14 +211,14 @@ func TestStartRPC(t *testing.T) { |
|
|
|
{ |
|
|
|
{ |
|
|
|
name: "rpc stopped with ws enabled", |
|
|
|
name: "rpc stopped with ws enabled", |
|
|
|
fn: func(t *testing.T, n *Node, api *privateAdminAPI) { |
|
|
|
fn: func(t *testing.T, n *Node, api *privateAdminAPI) { |
|
|
|
_, err := api.StartRPC(sp("127.0.0.1"), ip(0), nil, nil, nil) |
|
|
|
_, err := api.StartHTTP(sp("127.0.0.1"), ip(0), nil, nil, nil) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
|
|
|
|
|
|
|
|
wsport := n.http.port |
|
|
|
wsport := n.http.port |
|
|
|
_, err = api.StartWS(sp("127.0.0.1"), ip(wsport), nil, nil) |
|
|
|
_, err = api.StartWS(sp("127.0.0.1"), ip(wsport), nil, nil) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
|
|
|
|
|
|
|
|
_, err = api.StopRPC() |
|
|
|
_, err = api.StopHTTP() |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
}, |
|
|
|
}, |
|
|
|
wantReachable: false, |
|
|
|
wantReachable: false, |
|
|
@ -233,7 +233,7 @@ func TestStartRPC(t *testing.T) { |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
|
|
|
|
|
|
|
|
wsport := n.http.port |
|
|
|
wsport := n.http.port |
|
|
|
_, err = api.StartRPC(sp("127.0.0.1"), ip(wsport), nil, nil, nil) |
|
|
|
_, err = api.StartHTTP(sp("127.0.0.1"), ip(wsport), nil, nil, nil) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
}, |
|
|
|
}, |
|
|
|
wantReachable: true, |
|
|
|
wantReachable: true, |
|
|
|