Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update policy api #561

Merged
merged 3 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/RpcClient/PolicyAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ public class PolicyAPI : ContractClient
public PolicyAPI(RpcClient rpcClient) : base(rpcClient) { }

/// <summary>
/// Get Max Transactions Count Per Block
/// Get Fee Factor
/// </summary>
/// <returns></returns>
public async Task<uint> GetMaxTransactionsPerBlockAsync()
public async Task<uint> GetExecFeeFactorAsync()
{
var result = await TestInvokeAsync(scriptHash, "getMaxTransactionsPerBlock").ConfigureAwait(false);
var result = await TestInvokeAsync(scriptHash, "getExecFeeFactor").ConfigureAwait(false);
return (uint)result.Stack.Single().GetInteger();
}

/// <summary>
/// Get Max Block Size
/// Get Storage Price
/// </summary>
/// <returns></returns>
public async Task<uint> GetMaxBlockSizeAsync()
public async Task<uint> GetStoragePriceAsync()
{
var result = await TestInvokeAsync(scriptHash, "getMaxBlockSize").ConfigureAwait(false);
var result = await TestInvokeAsync(scriptHash, "getStoragePrice").ConfigureAwait(false);
return (uint)result.Stack.Single().GetInteger();
}

Expand Down
20 changes: 10 additions & 10 deletions tests/Neo.Network.RPC.Tests/UT_PolicyAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ public void TestSetup()
}

[TestMethod]
public async Task TestGetMaxTransactionsPerBlock()
public async Task TestGetExecFeeFactor()
{
byte[] testScript = NativeContract.Policy.Hash.MakeScript("getMaxTransactionsPerBlock");
UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(512) });
byte[] testScript = NativeContract.Policy.Hash.MakeScript("getExecFeeFactor");
UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(30) });

var result = await policyAPI.GetMaxTransactionsPerBlockAsync();
Assert.AreEqual(512u, result);
var result = await policyAPI.GetExecFeeFactorAsync();
Assert.AreEqual(30u, result);
}

[TestMethod]
public async Task TestGetMaxBlockSize()
public async Task TestGetStoragePrice()
{
byte[] testScript = NativeContract.Policy.Hash.MakeScript("getMaxBlockSize");
UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(1024u * 256u) });
byte[] testScript = NativeContract.Policy.Hash.MakeScript("getStoragePrice");
UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(100000) });

var result = await policyAPI.GetMaxBlockSizeAsync();
Assert.AreEqual(1024u * 256u, result);
var result = await policyAPI.GetStoragePriceAsync();
Assert.AreEqual(100000u, result);
}

[TestMethod]
Expand Down