示例#1
0
        public async Task TransferAuthorizationForVoteInterest_Test()
        {
            var newInterest = new VoteWeightInterestList();

            newInterest.VoteWeightInterestInfos.Add(new VoteWeightInterest
            {
                Capital  = 1000,
                Interest = 16,
                Day      = 400
            });
            var updateInterestRet = (await TreasuryContractStub.SetVoteWeightInterest.SendAsync(newInterest)).TransactionResult;

            updateInterestRet.Status.ShouldBe(TransactionResultStatus.Failed);
            var newParliament = new Parliament.CreateOrganizationInput
            {
                ProposerAuthorityRequired = false,
                ProposalReleaseThreshold  = new Acs3.ProposalReleaseThreshold
                {
                    MaximalAbstentionThreshold = 1,
                    MaximalRejectionThreshold  = 1,
                    MinimalApprovalThreshold   = 1,
                    MinimalVoteThreshold       = 1
                },
                ParliamentMemberProposingAllowed = false
            };
            var bpParliamentStub    = GetParliamentContractTester(InitialCoreDataCenterKeyPairs[0]);
            var createNewParliament =
                (await bpParliamentStub.CreateOrganization.SendAsync(newParliament)).TransactionResult;

            createNewParliament.Status.ShouldBe(TransactionResultStatus.Mined);
            var calculatedNewParliamentAddress = await ParliamentContractStub.CalculateOrganizationAddress.CallAsync(newParliament);

            var newAuthority = new AuthorityInfo
            {
                OwnerAddress    = calculatedNewParliamentAddress,
                ContractAddress = ParliamentContractAddress
            };

            await ExecuteProposalTransaction(Tester, TreasuryContractAddress, nameof(TreasuryContractStub.ChangeVoteWeightInterestController), newAuthority);

            var proposalToUpdateInterest = new Acs3.CreateProposalInput
            {
                OrganizationAddress = calculatedNewParliamentAddress,
                ContractMethodName  = nameof(TreasuryContractContainer.TreasuryContractStub.SetVoteWeightInterest),
                ExpiredTime         = TimestampHelper.GetUtcNow().AddHours(1),
                Params    = newInterest.ToByteString(),
                ToAddress = TreasuryContractAddress
            };
            var createResult = await bpParliamentStub.CreateProposal.SendAsync(proposalToUpdateInterest);

            createResult.TransactionResult.Status.ShouldBe(TransactionResultStatus.Mined);

            var proposalHash = Hash.Parser.ParseFrom(createResult.TransactionResult.ReturnValue);
            await bpParliamentStub.Approve.SendAsync(proposalHash);

            await ParliamentContractStub.Release.SendAsync(proposalHash);

            var interestList = await TreasuryContractStub.GetVoteWeightSetting.CallAsync(new Empty());

            interestList.VoteWeightInterestInfos.Count.ShouldBe(1);
            interestList.VoteWeightInterestInfos[0].Capital.ShouldBe(1000);
            interestList.VoteWeightInterestInfos[0].Interest.ShouldBe(16);
            interestList.VoteWeightInterestInfos[0].Day.ShouldBe(400);
        }