forked from TrueCloudLab/neoneo-go
rpc/client: implement GetNativeContracts
This commit is contained in:
parent
02ca3d3dfd
commit
4f1bea0bcb
2 changed files with 26 additions and 0 deletions
|
@ -240,6 +240,18 @@ func (c *Client) getContractState(param interface{}) (*state.Contract, error) {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetNativeContracts queries information about native contracts.
|
||||||
|
func (c *Client) GetNativeContracts() ([]state.NativeContract, error) {
|
||||||
|
var (
|
||||||
|
params = request.NewRawParams()
|
||||||
|
resp []state.NativeContract
|
||||||
|
)
|
||||||
|
if err := c.performRequest("getnativecontracts", params, &resp); err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetNEP17Balances is a wrapper for getnep17balances RPC.
|
// GetNEP17Balances is a wrapper for getnep17balances RPC.
|
||||||
func (c *Client) GetNEP17Balances(address util.Uint160) (*result.NEP17Balances, error) {
|
func (c *Client) GetNEP17Balances(address util.Uint160) (*result.NEP17Balances, error) {
|
||||||
params := request.NewRawParams(address.StringLE())
|
params := request.NewRawParams(address.StringLE())
|
||||||
|
|
|
@ -322,3 +322,17 @@ func TestInvokeVerify(t *testing.T) {
|
||||||
require.False(t, res.Stack[0].Value().(bool))
|
require.False(t, res.Stack[0].Value().(bool))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_GetNativeContracts(t *testing.T) {
|
||||||
|
chain, rpcSrv, httpSrv := initServerWithInMemoryChain(t)
|
||||||
|
defer chain.Close()
|
||||||
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
|
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
cs, err := c.GetNativeContracts()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, chain.GetNatives(), cs)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue