Beispiel #1
0
        public async Task ChangeSymbolsToPayTXSizeFeeController_Success_Test()
        {
            var primaryToken = await TokenContractStub.GetPrimaryTokenSymbol.CallAsync(new Empty());

            var newSymbolList = new SymbolListToPayTxSizeFee();

            newSymbolList.SymbolsToPayTxSizeFee.Add(new SymbolToPayTxSizeFee
            {
                TokenSymbol      = primaryToken.Value,
                AddedTokenWeight = 1,
                BaseTokenWeight  = 1
            });

            // create a new organization to be replace the controller of SetSymbolsToPayTxSizeFee
            var newAuthority = await CreateNewParliamentAddressAsync();

            // get the default parliament that is the controller of SetSymbolsToPayTxSizeFee
            var defaultParliamentAddress = await GetDefaultParliamentAddressAsync();

            // create a proposal to replace the controller
            var createProposalInput = new CreateProposalInput
            {
                ToAddress           = TokenContractAddress,
                Params              = newAuthority.ToByteString(),
                OrganizationAddress = defaultParliamentAddress,
                ContractMethodName  = nameof(TokenContractImplContainer.TokenContractImplStub
                                             .ChangeSymbolsToPayTXSizeFeeController),
                ExpiredTime = TimestampHelper.GetUtcNow().AddHours(1)
            };

            await MainChainTesterCreatApproveAndReleaseProposalForParliamentAsync(createProposalInput);

            // the new controller try to send SetSymbolsToPayTxSizeFee
            var updateInput = new CreateProposalInput
            {
                ToAddress           = TokenContractAddress,
                Params              = newSymbolList.ToByteString(),
                OrganizationAddress = newAuthority.OwnerAddress,
                ContractMethodName  = nameof(TokenContractImplContainer.TokenContractImplStub.SetSymbolsToPayTxSizeFee),
                ExpiredTime         = TimestampHelper.GetUtcNow().AddHours(1)
            };

            await MainChainTesterCreatApproveAndReleaseProposalForParliamentAsync(updateInput);

            var symbolSet = await TokenContractStub.GetSymbolsToPayTxSizeFee.CallAsync(new Empty());

            symbolSet.SymbolsToPayTxSizeFee.Count.ShouldBe(1);
        }