From 42674e46aca2ff46da4ab54bf2db6d37238053ad Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 16 Mar 2021 22:50:14 +0300 Subject: [PATCH] client: add GetStoragePrice for native policy contract --- pkg/rpc/client/policy.go | 8 ++++++++ pkg/rpc/client/rpc_test.go | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pkg/rpc/client/policy.go b/pkg/rpc/client/policy.go index 81cdb34a8..674d7314e 100644 --- a/pkg/rpc/client/policy.go +++ b/pkg/rpc/client/policy.go @@ -25,6 +25,14 @@ func (c *Client) GetExecFeeFactor() (int64, error) { return c.invokeNativePolicyMethod("getExecFeeFactor") } +// GetStoragePrice invokes `getStoragePrice` method on a native Policy contract. +func (c *Client) GetStoragePrice() (int64, error) { + if !c.initDone { + return 0, errNetworkNotInitialized + } + return c.invokeNativePolicyMethod("getStoragePrice") +} + // GetMaxNotValidBeforeDelta invokes `getMaxNotValidBeforeDelta` method on a native Notary contract. func (c *Client) GetMaxNotValidBeforeDelta() (int64, error) { notaryHash, err := c.GetNativeContractHash(nativenames.Notary) diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index e34302c70..3cb8d382c 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -428,6 +428,18 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ }, }, }, + "getStoragePrice": { + { + name: "positive", + invoke: func(c *Client) (interface{}, error) { + return c.GetStoragePrice() + }, + serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"state":"HALT","gasconsumed":"2007390","script":"EMAMDWdldEZlZVBlckJ5dGUMFJphpG7sl7iTBtfOgfFbRiCR0AkyQWJ9W1I=","stack":[{"type":"Integer","value":"100000"}],"tx":null}}`, + result: func(c *Client) interface{} { + return int64(100000) + }, + }, + }, "getMaxNotValidBeforeDelta": { { name: "positive",