Example #1
0
        public async Task Update_Contract_Success()
        {
            var registrationA = new SmartContractRegistration
            {
                Category = KernelConstants.DefaultRunnerCategory,
                Code     = Hash.FromString("TestContractA").ToByteString(),
                CodeHash = Hash.FromString("TestContractA")
            };

            var registrationANew = new SmartContractRegistration
            {
                Category = KernelConstants.DefaultRunnerCategory,
                Code     = Hash.FromString("TestContractA_New").ToByteString(),
                CodeHash = Hash.FromString("TestContractA")
            };

            var registrationB = new SmartContractRegistration
            {
                Category = KernelConstants.DefaultRunnerCategory,
                Code     = Hash.FromString("TestContractB").ToByteString(),
                CodeHash = Hash.FromString("TestContractB")
            };

            await _smartContractService.DeployContractAsync(Address.Genesis, registrationA, false, null);

            await _smartContractService.UpdateContractAsync(Address.Genesis, registrationANew, false, null);


            await _smartContractService.UpdateContractAsync(Address.Genesis, registrationB, false, null);
        }
        public async Task Update_Contract_Success()
        {
            var registrationA = new SmartContractRegistration
            {
                Category = KernelConstants.DefaultRunnerCategory,
                Code     = HashHelper.ComputeFrom("TestContractA").ToByteString(),
                CodeHash = HashHelper.ComputeFrom("TestContractA")
            };

            var registrationANew = new SmartContractRegistration
            {
                Category = KernelConstants.DefaultRunnerCategory,
                Code     = HashHelper.ComputeFrom("TestContractA_New").ToByteString(),
                CodeHash = HashHelper.ComputeFrom("TestContractA")
            };

            var registrationB = new SmartContractRegistration
            {
                Category = KernelConstants.DefaultRunnerCategory,
                Code     = HashHelper.ComputeFrom("TestContractB").ToByteString(),
                CodeHash = HashHelper.ComputeFrom("TestContractB")
            };

            await _smartContractService.DeployContractAsync(new ContractDto
            {
                BlockHeight               = 1,
                ContractAddress           = SampleAddress.AddressList[0],
                ContractName              = null,
                IsPrivileged              = false,
                SmartContractRegistration = registrationA
            });

            await _smartContractService.UpdateContractAsync(new ContractDto
            {
                ContractAddress           = SampleAddress.AddressList[1],
                SmartContractRegistration = registrationANew,
                BlockHeight  = 2,
                IsPrivileged = false,
                ContractName = null
            });

            await _smartContractService.UpdateContractAsync(new ContractDto
            {
                ContractAddress           = SampleAddress.AddressList[2],
                SmartContractRegistration = registrationB,
                BlockHeight  = 2,
                IsPrivileged = false,
                ContractName = null
            });
        }