Exemplo n.º 1
0
        public void TestInvoke()
        {
            byte[] testScript = NativeContract.GAS.Hash.MakeScript("balanceOf", UInt160.Zero);
            UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter { Type = ContractParameterType.ByteArray, Value = "00e057eb481b".HexToBytes() });

            ContractClient contractClient = new ContractClient(rpcClientMock.Object);
            var result = contractClient.TestInvoke(NativeContract.GAS.Hash, "balanceOf", UInt160.Zero);

            Assert.AreEqual(30000000000000L, (long)result.Stack[0].ToStackItem().GetBigInteger());
        }
Exemplo n.º 2
0
        public void TestGetDecimals()
        {
            byte[] testScript = NativeContract.GAS.Hash.MakeScript("decimals");
            UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter {
                Type = ContractParameterType.Integer, Value = new BigInteger(NativeContract.GAS.Decimals)
            });

            var result = nep5API.Decimals(NativeContract.GAS.Hash);

            Assert.AreEqual(NativeContract.GAS.Decimals, (byte)result);
        }
Exemplo n.º 3
0
        public void TestGetSymbol()
        {
            byte[] testScript = NativeContract.GAS.Hash.MakeScript("symbol");
            UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter {
                Type = ContractParameterType.String, Value = NativeContract.GAS.Symbol
            });

            var result = nep5API.Symbol(NativeContract.GAS.Hash);

            Assert.AreEqual(NativeContract.GAS.Symbol, result);
        }
Exemplo n.º 4
0
        public void TestBalanceOf()
        {
            byte[] testScript = NativeContract.GAS.Hash.MakeScript("balanceOf", UInt160.Zero);
            UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter {
                Type = ContractParameterType.Integer, Value = new BigInteger(10000)
            });

            var balance = nep5API.BalanceOf(NativeContract.GAS.Hash, UInt160.Zero);

            Assert.AreEqual(10000, (int)balance);
        }
Exemplo n.º 5
0
        public void TestGetFeePerByte()
        {
            byte[] testScript = NativeContract.Policy.Hash.MakeScript("getFeePerByte");
            UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter {
                Type = ContractParameterType.Integer, Value = new BigInteger(1000)
            });

            var result = policyAPI.GetFeePerByte();

            Assert.AreEqual(1000L, result);
        }
Exemplo n.º 6
0
        public void TestGetBlockedAccounts()
        {
            byte[] testScript = NativeContract.Policy.Hash.MakeScript("getBlockedAccounts");
            UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter {
                Type = ContractParameterType.Array, Value = new[] { new ContractParameter {
                                                                        Type = ContractParameterType.Hash160, Value = UInt160.Zero
                                                                    } }
            });

            var result = policyAPI.GetBlockedAccounts();

            Assert.AreEqual(UInt160.Zero, result[0]);
        }
Exemplo n.º 7
0
        public void TestDeployContract()
        {
            byte[] script;
            var manifest = ContractManifest.CreateDefault(new byte[1].ToScriptHash());
            manifest.Features = ContractFeatures.HasStorage | ContractFeatures.Payable;
            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitSysCall(InteropService.Neo_Contract_Create, new byte[1], manifest.ToString());
                script = sb.ToArray();
            }

            UT_TransactionManager.MockInvokeScript(rpcClientMock, script, new ContractParameter());

            ContractClient contractClient = new ContractClient(rpcClientMock.Object);
            var result = contractClient.DeployContract(new byte[1], manifest, keyPair1);

            Assert.IsNotNull(result);
        }
Exemplo n.º 8
0
 public void TestGetUnclaimedGas()
 {
     byte[] testScript = NativeContract.NEO.Hash.MakeScript("unclaimedGas", sender, 99);
     UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter {
         Type = ContractParameterType.Integer, Value = new BigInteger(1_10000000)
     });
Exemplo n.º 9
0
 public void TestGetTotalSupply()
 {
     byte[] testScript = NativeContract.GAS.Hash.MakeScript("totalSupply");
     UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter {
         Type = ContractParameterType.Integer, Value = new BigInteger(1_00000000)
     });