Example #1
0
        public void LoadContractAbi()
        {
            var ci = new CommandInfo("load_contract_abi");

            ci.Parameter = ContractAbi;
            CH.RpcLoadContractAbi(ci);

            Assert.IsTrue(ci.Result, $"Load contract abi failed. Reason: {ci.GetErrorMessage()}");
        }
Example #2
0
        public void ExecuteContractMethod(string rawTx, out string txId)
        {
            txId = string.Empty;
            var ci = new CommandInfo("broadcast_tx");

            ci.Parameter = rawTx;
            CH.RpcBroadcastTx(ci);
            if (ci.Result)
            {
                ci.GetJsonInfo();
                txId = ci.JsonInfo["txId"].ToString();
            }
            Assert.IsTrue(ci.Result, $"Execute contract failed. Reason: {ci.GetErrorMessage()}");
        }
Example #3
0
        public bool GetTransactionResult(string txId, out CommandInfo ci)
        {
            ci           = new CommandInfo("get_tx_result");
            ci.Parameter = txId;
            CH.ExecuteCommand(ci);

            if (ci.Result)
            {
                ci.GetJsonInfo();
                ci.JsonInfo = ci.JsonInfo;
                string txResult = ci.JsonInfo["result"]["result"]["tx_status"].ToString();
                Logger.WriteInfo($"Transaction: {txId}, Status: {txResult}");

                return(txResult == "Mined");
            }

            Logger.WriteError(ci.GetErrorMessage());
            return(false);
        }
Example #4
0
        public void DeployContract(out string txId)
        {
            txId = string.Empty;
            var ci = new CommandInfo("deploy_contract");

            ci.Parameter = $"{FileName} 0 {Account}";
            CH.RpcDeployContract(ci);
            if (ci.Result)
            {
                ci.GetJsonInfo();
                txId = ci.JsonInfo["txId"].ToString();
                Logger.WriteInfo($"Transaction: DeployContract, TxId: {txId}");

                bool result = GetContractAbi(txId, out var contractAbi);
                Assert.IsTrue(result, $"Get contract abi failed.");
            }

            Assert.IsTrue(ci.Result, $"Deploy contract failed. Reason: {ci.GetErrorMessage()}");
        }