24
24
using System ;
25
25
using System . IO ;
26
26
using System . Linq ;
27
+ using System . Text ;
27
28
28
29
namespace Neo . Plugins . RpcServer . Tests ;
29
30
@@ -32,6 +33,7 @@ public partial class UT_RpcServer
32
33
static readonly string NeoScriptHash = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5" ;
33
34
static readonly string GasScriptHash = "0xd2a4cff31913016155e38e474a2c06d08be276cf" ;
34
35
static readonly string NeoTotalSupplyScript = "wh8MC3RvdGFsU3VwcGx5DBT1Y\u002B pAvCg9TQ4FxI6jBbPyoHNA70FifVtS" ;
36
+ static readonly string NeoTransferScript = "CxEMFPlu76Cuc\u002B bgteStE4ozsOWTNUdrDBQtYNweHko3YcnMFOes3ceblcI/lRTAHwwIdHJhbnNmZXIMFPVj6kC8KD1NDgXEjqMFs/Kgc0DvQWJ9W1I=" ;
35
37
static readonly UInt160 ValidatorScriptHash = Contract
36
38
. CreateSignatureRedeemScript ( TestProtocolSettings . SoleNode . StandbyCommittee [ 0 ] )
37
39
. ToScriptHash ( ) ;
@@ -71,6 +73,16 @@ public void TestInvokeFunction()
71
73
Assert . AreEqual ( resp [ "stack" ] [ 0 ] [ "value" ] , "100000000" ) ;
72
74
Assert . IsTrue ( resp . ContainsProperty ( "tx" ) ) ;
73
75
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
+
74
86
// This call triggers not only NEO but also unclaimed GAS
75
87
resp = ( JObject ) _rpcServer . InvokeFunction ( new JArray ( NeoScriptHash , "transfer" , new JArray ( [
76
88
new JObject ( ) { [ "type" ] = "Hash160" , [ "value" ] = MultisigScriptHash . ToString ( ) } ,
@@ -79,6 +91,7 @@ public void TestInvokeFunction()
79
91
new JObject ( ) { [ "type" ] = "Any" } ,
80
92
] ) , multisigSigner , true ) ) ;
81
93
Assert . AreEqual ( resp . Count , 7 ) ;
94
+ Assert . AreEqual ( resp [ "script" ] , NeoTransferScript ) ;
82
95
Assert . IsTrue ( resp . ContainsProperty ( "gasconsumed" ) ) ;
83
96
Assert . IsTrue ( resp . ContainsProperty ( "diagnostics" ) ) ;
84
97
Assert . AreEqual ( resp [ "diagnostics" ] [ "invokedcontracts" ] [ "call" ] [ 0 ] [ "hash" ] , NeoScriptHash ) ;
@@ -110,6 +123,11 @@ public void TestInvokeScript()
110
123
Assert . AreEqual ( ( ( JArray ) resp [ "notifications" ] ) . Count , 0 ) ;
111
124
Assert . AreEqual ( resp [ "stack" ] [ 0 ] [ "type" ] , "Integer" ) ;
112
125
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 ) ;
113
131
}
114
132
115
133
[ TestMethod ]
0 commit comments