Esempio n. 1
0
        public async Task ClearProposalTest()
        {
            var proposalId1 = Hash.FromString("proposalId1");
            var proposalId2 = Hash.FromString("proposalId2");
            var proposalId3 = Hash.FromString("proposalId3");
            var proposalId4 = Hash.FromString("proposalId4");

            var proposalCacheProvider = GetRequiredService <IProposalProvider>();
            var blockHeight           = 5;

            proposalCacheProvider.AddProposal(proposalId1, blockHeight);
            proposalCacheProvider.AddProposal(proposalId2, blockHeight);
            proposalCacheProvider.AddProposal(proposalId3, blockHeight);
            proposalCacheProvider.AddProposal(proposalId4, blockHeight);

            var notApprovedProposalIdList = new List <Hash>
            {
                proposalId3, proposalId4
            };

            _proposalTestHelper.AddNotVotedProposalIdList(notApprovedProposalIdList);
            var notApprovedPendingProposalIdList = new List <Hash>
            {
                proposalId3
            };

            _proposalTestHelper.AddNotVotedPendingProposalIdList(notApprovedPendingProposalIdList);

            var libHash   = Hash.FromString("BlockHash");
            var libHeight = blockHeight;
            await _proposalService.ClearProposalByLibAsync(libHash, libHeight);

            var cachedProposalIdList = proposalCacheProvider.GetAllProposals();

            cachedProposalIdList.Count.ShouldBe(1);
            cachedProposalIdList.ShouldContain(proposalId3);

            var blockHash = Hash.FromString("BlockHash");
            var queryResultNotApprovedProposalIdList =
                await _proposalService.GetNotApprovedProposalIdListAsync(NormalAddress, blockHash, blockHeight);

            queryResultNotApprovedProposalIdList.Count.ShouldBe(1);
            queryResultNotApprovedProposalIdList.ShouldContain(proposalId3);
        }
 public async Task HandleEventAsync(NewIrreversibleBlockFoundEvent eventData)
 {
     await _proposalService.ClearProposalByLibAsync(eventData.BlockHash, eventData.BlockHeight);
 }