client: add gasperblock getter

It's an important chain parameter.
This commit is contained in:
Roman Khimov 2021-03-16 23:03:51 +03:00
parent 87d4939093
commit 7990fa1b61
2 changed files with 21 additions and 0 deletions

View file

@ -25,3 +25,12 @@ func (c *Client) GetNNSPrice() (int64, error) {
} }
return c.invokeNativeGetMethod(nnsHash, "getPrice") return c.invokeNativeGetMethod(nnsHash, "getPrice")
} }
// GetGasPerBlock invokes `getGasPerBlock` method on a native NEO contract.
func (c *Client) GetGasPerBlock() (int64, error) {
neoHash, err := c.GetNativeContractHash(nativenames.Neo)
if err != nil {
return 0, fmt.Errorf("failed to get native NEO hash: %w", err)
}
return c.invokeNativeGetMethod(neoHash, "getGasPerBlock")
}

View file

@ -464,6 +464,18 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
}, },
}, },
}, },
"getGasPerBlock": {
{
name: "positive",
invoke: func(c *Client) (interface{}, error) {
return c.GetGasPerBlock()
},
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"state":"HALT","gasconsumed":"2007390","script":"EMAMDWdldEZlZVBlckJ5dGUMFJphpG7sl7iTBtfOgfFbRiCR0AkyQWJ9W1I=","stack":[{"type":"Integer","value":"500000000"}],"tx":null}}`,
result: func(c *Client) interface{} {
return int64(500000000)
},
},
},
"getMaxNotValidBeforeDelta": { "getMaxNotValidBeforeDelta": {
{ {
name: "positive", name: "positive",