laconicd-deprecated/tests/rpc/net_test.go
Calvin Lau 8bfb6b0a67
rpc: implement net_listening and net_peerCount JSON-RPC endpoints (#252)
* Add net_listening net_peerCount endpoint

* Add test cases

* Use RPC client from context

* Fix lint issue

* Revert unnecessary changes

* Update JSON RPC documentation
2021-07-12 08:26:33 -04:00

36 lines
687 B
Go

package rpc
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
)
func TestNet_Version(t *testing.T) {
rpcRes := Call(t, "net_version", []string{})
var res string
err := json.Unmarshal(rpcRes.Result, &res)
require.NoError(t, err)
require.Equal(t, "2", res)
}
func TestNet_Listening(t *testing.T) {
rpcRes := Call(t, "net_listening", []string{})
var res bool
err := json.Unmarshal(rpcRes.Result, &res)
require.NoError(t, err)
require.True(t, res)
}
func TestNet_PeerCount(t *testing.T) {
rpcRes := Call(t, "net_peerCount", []string{})
var res int
err := json.Unmarshal(rpcRes.Result, &res)
require.NoError(t, err)
require.Equal(t, 0, res)
}