Skip to content

Commit eefa8c9

Browse files
committed
invoke without signer
1 parent 54ae25f commit eefa8c9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.SmartContract.cs

+18
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System;
2525
using System.IO;
2626
using System.Linq;
27+
using System.Text;
2728

2829
namespace Neo.Plugins.RpcServer.Tests;
2930

@@ -32,6 +33,7 @@ public partial class UT_RpcServer
3233
static readonly string NeoScriptHash = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5";
3334
static readonly string GasScriptHash = "0xd2a4cff31913016155e38e474a2c06d08be276cf";
3435
static readonly string NeoTotalSupplyScript = "wh8MC3RvdGFsU3VwcGx5DBT1Y\u002BpAvCg9TQ4FxI6jBbPyoHNA70FifVtS";
36+
static readonly string NeoTransferScript = "CxEMFPlu76Cuc\u002BbgteStE4ozsOWTNUdrDBQtYNweHko3YcnMFOes3ceblcI/lRTAHwwIdHJhbnNmZXIMFPVj6kC8KD1NDgXEjqMFs/Kgc0DvQWJ9W1I=";
3537
static readonly UInt160 ValidatorScriptHash = Contract
3638
.CreateSignatureRedeemScript(TestProtocolSettings.SoleNode.StandbyCommittee[0])
3739
.ToScriptHash();
@@ -71,6 +73,16 @@ public void TestInvokeFunction()
7173
Assert.AreEqual(resp["stack"][0]["value"], "100000000");
7274
Assert.IsTrue(resp.ContainsProperty("tx"));
7375

76+
resp = (JObject)_rpcServer.InvokeFunction(new JArray(NeoScriptHash, "symbol"));
77+
Assert.AreEqual(resp.Count, 6);
78+
Assert.IsTrue(resp.ContainsProperty("script"));
79+
Assert.IsTrue(resp.ContainsProperty("gasconsumed"));
80+
Assert.AreEqual(resp["state"], "HALT");
81+
Assert.AreEqual(resp["exception"], null);
82+
Assert.AreEqual(((JArray)resp["notifications"]).Count, 0);
83+
Assert.AreEqual(resp["stack"][0]["type"], "ByteString");
84+
Assert.AreEqual(resp["stack"][0]["value"], Convert.ToBase64String(Encoding.UTF8.GetBytes("NEO")));
85+
7486
// This call triggers not only NEO but also unclaimed GAS
7587
resp = (JObject)_rpcServer.InvokeFunction(new JArray(NeoScriptHash, "transfer", new JArray([
7688
new JObject() { ["type"] = "Hash160", ["value"] = MultisigScriptHash.ToString() },
@@ -79,6 +91,7 @@ public void TestInvokeFunction()
7991
new JObject() { ["type"] = "Any" },
8092
]), multisigSigner, true));
8193
Assert.AreEqual(resp.Count, 7);
94+
Assert.AreEqual(resp["script"], NeoTransferScript);
8295
Assert.IsTrue(resp.ContainsProperty("gasconsumed"));
8396
Assert.IsTrue(resp.ContainsProperty("diagnostics"));
8497
Assert.AreEqual(resp["diagnostics"]["invokedcontracts"]["call"][0]["hash"], NeoScriptHash);
@@ -110,6 +123,11 @@ public void TestInvokeScript()
110123
Assert.AreEqual(((JArray)resp["notifications"]).Count, 0);
111124
Assert.AreEqual(resp["stack"][0]["type"], "Integer");
112125
Assert.AreEqual(resp["stack"][0]["value"], "100000000");
126+
127+
resp = (JObject)_rpcServer.InvokeScript(new JArray(NeoTransferScript));
128+
Assert.AreEqual(resp.Count, 6);
129+
Assert.AreEqual(resp["stack"][0]["type"], "Boolean");
130+
Assert.AreEqual(resp["stack"][0]["value"], false);
113131
}
114132

115133
[TestMethod]

0 commit comments

Comments
 (0)