status-go/geth/rpc/route_test.go
Ivan Daniluk 9a5c1774c3 Refactor RPC client #304 (#311)
This PR refactors RPC subsystem for status-go:

cleans up two different RPC client implementations (RPCManager and rpc.Client)
creates new package under geth/rpc
moves routing logic into this package (rpc.(*router))
add tests for routing
cleans up NodeManager
2017-09-14 23:14:31 +03:00

34 lines
752 B
Go

package rpc
import (
"github.com/stretchr/testify/require"
"testing"
)
// some of the upstream examples
var upstreamMethods = []string{"some_weirdo_method", "eth_syncing", "eth_getBalance", "eth_call", "eth_getTransactionReceipt"}
func TestRouteWithUpstream(t *testing.T) {
router := newRouter(true)
for _, method := range localMethods {
require.True(t, router.routeLocally(method))
}
for _, method := range upstreamMethods {
require.False(t, router.routeLocally(method))
}
}
func TestRouteWithoutUpstream(t *testing.T) {
router := newRouter(false)
for _, method := range localMethods {
require.True(t, router.routeLocally(method))
}
for _, method := range upstreamMethods {
require.True(t, router.routeLocally(method))
}
}