示例#1
0
        public void TestDeployContract()
        {
            byte[] script;
            var    manifest = new ContractManifest()
            {
                Permissions = new[] { ContractPermission.DefaultPermission },
                Abi         = new ContractAbi()
                {
                    Hash    = new byte[1].ToScriptHash(),
                    Events  = new ContractEventDescriptor[0],
                    Methods = new ContractMethodDescriptor[0]
                },
                Groups      = new ContractGroup[0],
                SafeMethods = WildcardContainer <string> .Create(),
                Trusts      = WildcardContainer <UInt160> .Create(),
                Extra       = null,
            };

            manifest.Features = ContractFeatures.HasStorage | ContractFeatures.Payable;
            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitSysCall(ApplicationEngine.System_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.CreateDeployContractTx(new byte[1], manifest, keyPair1);

            Assert.IsNotNull(result);
        }
        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.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.CreateDeployContractTx(new byte[1], manifest, keyPair1);

            Assert.IsNotNull(result);
        }