rpc: fix Client's GetOraclePrice

This commit is contained in:
AnnaShaleva 2022-03-01 13:17:37 +03:00
parent 92282c70cb
commit 49e228ddf8
2 changed files with 16 additions and 1 deletions

View file

@ -16,7 +16,7 @@ import (
// GetOraclePrice invokes `getPrice` method on a native Oracle contract.
func (c *Client) GetOraclePrice() (int64, error) {
oracleHash, err := c.GetNativeContractHash(nativenames.Notary)
oracleHash, err := c.GetNativeContractHash(nativenames.Oracle)
if err != nil {
return 0, fmt.Errorf("failed to get native Oracle hash: %w", err)
}

View file

@ -998,3 +998,18 @@ func TestClient_GetNotaryServiceFeePerKey(t *testing.T) {
require.NoError(t, err)
require.Equal(t, defaultNotaryServiceFeePerKey, actual)
}
func TestClient_GetOraclePrice(t *testing.T) {
chain, rpcSrv, httpSrv := initServerWithInMemoryChain(t)
defer chain.Close()
defer func() { _ = rpcSrv.Shutdown() }()
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
require.NoError(t, err)
require.NoError(t, c.Init())
var defaultOracleRequestPrice int64 = 5000_0000
actual, err := c.GetOraclePrice()
require.NoError(t, err)
require.Equal(t, defaultOracleRequestPrice, actual)
}