Skip to content

Commit

Permalink
use wallet in invokefunction
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Aug 19, 2024
1 parent e975765 commit 851b4b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public partial class UT_RpcServer
[TestMethod]
public void TestInvokeFunction()
{
_rpcServer.wallet = _wallet;
JObject resp = (JObject)_rpcServer.InvokeFunction(new JArray(NeoScriptHash, "totalSupply", new JArray([]), validatorSigner, true));
Assert.AreEqual(resp.Count, 7);
Assert.AreEqual(resp.Count, 8);
Assert.AreEqual(resp["script"], NeoTotalSupplyScript);
Assert.IsTrue(resp.ContainsProperty("gasconsumed"));
Assert.IsTrue(resp.ContainsProperty("diagnostics"));
Expand All @@ -67,6 +68,8 @@ public void TestInvokeFunction()
Assert.AreEqual(((JArray)resp["notifications"]).Count, 0);
Assert.AreEqual(resp["stack"][0]["type"], "Integer");
Assert.AreEqual(resp["stack"][0]["value"], "100000000");
Assert.IsTrue(resp.ContainsProperty("tx"));
_rpcServer.wallet = null;

// This call triggers not only NEO but also unclaimed GAS
resp = (JObject)_rpcServer.InvokeFunction(new JArray(NeoScriptHash, "transfer", new JArray([
Expand All @@ -86,10 +89,10 @@ public void TestInvokeFunction()
Assert.AreEqual(notifications.Count, 2);
Assert.AreEqual(notifications[0]["eventname"].AsString(), "Transfer");
Assert.AreEqual(notifications[0]["contract"].AsString(), NeoScriptHash);
Assert.AreEqual(((JArray)resp["notifications"])[0]["state"]["value"][2]["value"], "1");
Assert.AreEqual(notifications[0]["state"]["value"][2]["value"], "1");
Assert.AreEqual(notifications[1]["eventname"].AsString(), "Transfer");
Assert.AreEqual(notifications[1]["contract"].AsString(), GasScriptHash);
Assert.AreEqual(((JArray)resp["notifications"])[1]["state"]["value"][2]["value"], "50000000");
Assert.AreEqual(notifications[1]["state"]["value"][2]["value"], "50000000");
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void TestSetup()
_memoryStore = new MemoryStore();
_memoryStoreProvider = new TestMemoryStoreProvider(_memoryStore);
_neoSystem = new NeoSystem(TestProtocolSettings.SoleNode, _memoryStoreProvider);
_rpcServer = new RpcServer(_neoSystem, RpcServerSettings.Default with { SessionEnabled = true });
_rpcServer = new RpcServer(_neoSystem, RpcServerSettings.Default with { SessionEnabled = true, Network = TestProtocolSettings.SoleNode.Network });
_walletAccount = _wallet.Import("KxuRSsHgJMb3AMSN6B9P3JHNGMFtxmuimqgR9MmXPcv3CLLfusTd");
var key = new KeyBuilder(NativeContract.GAS.Id, 20).Add(_walletAccount.ScriptHash);
var snapshot = _neoSystem.GetSnapshotCache();
Expand Down

0 comments on commit 851b4b4

Please sign in to comment.