rpc: allow to use address, id or name instead of scripthash [Client]
... for getcontractstate RPC client method.
This commit is contained in:
parent
d3daaafbe4
commit
b8a88f9378
12 changed files with 220 additions and 99 deletions
32
cli/options_test.go
Normal file
32
cli/options_test.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
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)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue