mirror of
https://github.com/status-im/status-go.git
synced 2025-02-03 10:25:35 +00:00
9a5c1774c3
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
34 lines
752 B
Go
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))
|
|
}
|
|
}
|