mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 23:33:37 +00:00
b8a88f9378
... for getcontractstate RPC client method.
32 lines
830 B
Go
32 lines
830 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neo-go/cli/options"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
func TestGetRPCClient(t *testing.T) {
|
|
e := newExecutor(t, true)
|
|
defer e.Close(t)
|
|
|
|
t.Run("no endpoint", func(t *testing.T) {
|
|
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
|
ctx := cli.NewContext(cli.NewApp(), set, nil)
|
|
gctx, _ := options.GetTimeoutContext(ctx)
|
|
_, ec := options.GetRPCClient(gctx, ctx)
|
|
require.Equal(t, 1, ec.ExitCode())
|
|
})
|
|
|
|
t.Run("success", func(t *testing.T) {
|
|
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
|
set.String(options.RPCEndpointFlag, "http://"+e.RPC.Addr, "")
|
|
ctx := cli.NewContext(cli.NewApp(), set, nil)
|
|
gctx, _ := options.GetTimeoutContext(ctx)
|
|
_, ec := options.GetRPCClient(gctx, ctx)
|
|
require.Nil(t, ec)
|
|
})
|
|
}
|