コード例 #1
0
 public void TestSetup()
 {
     keyPair1      = new KeyPair(Wallet.GetPrivateKeyFromWIF("KyXwTh1hB76RRMquSvnxZrJzQx7h9nQP2PCRL38v6VDb5ip3nf1p"));
     sender        = Contract.CreateSignatureRedeemScript(keyPair1.PublicKey).ToScriptHash();
     rpcClientMock = UT_TransactionManager.MockRpcClient(sender, new byte[0]);
     nep5API       = new Nep5API(rpcClientMock.Object);
 }
コード例 #2
0
ファイル: UT_ContractClient.cs プロジェクト: yongjiema/neo
        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());
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: UT_PolicyAPI.cs プロジェクト: yongjiema/neo
        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);
        }
コード例 #7
0
ファイル: UT_PolicyAPI.cs プロジェクト: yongjiema/neo
        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]);
        }
コード例 #8
0
ファイル: UT_ContractClient.cs プロジェクト: yongjiema/neo
        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);
        }
コード例 #9
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)
     });
コード例 #10
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)
     });