示例#1
0
        public async Task GetNotApprovedProposalIdListTest()
        {
            var proposalId1 = Hash.FromString("proposalId1");
            var proposalId2 = Hash.FromString("proposalId2");
            var proposalId3 = Hash.FromString("proposalId3");
            var proposalId4 = Hash.FromString("proposalId4");

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

            _proposalTestHelper.AddNotVotedProposalIdList(notApprovedProposalIdList);

            var blockHash   = Hash.FromString("BlockHash");
            var blockHeight = 10;

            var proposalCacheProvider = GetRequiredService <IProposalProvider>();

            proposalCacheProvider.AddProposal(proposalId1, 5);

            {
                var queryResultNotApprovedProposalIdList =
                    await _proposalService.GetNotApprovedProposalIdListAsync(NormalAddress, blockHash, blockHeight);

                queryResultNotApprovedProposalIdList.Count.ShouldBe(1);
                queryResultNotApprovedProposalIdList.ShouldContain(proposalId1);
            }

            proposalCacheProvider.AddProposal(proposalId2, 6);
            {
                var queryResultNotApprovedProposalIdList =
                    await _proposalService.GetNotApprovedProposalIdListAsync(NormalAddress, blockHash, blockHeight);

                queryResultNotApprovedProposalIdList.Count.ShouldBe(2);
                queryResultNotApprovedProposalIdList.ShouldContain(proposalId1);
                queryResultNotApprovedProposalIdList.ShouldContain(proposalId2);
            }
        }
示例#2
0
        public async Task GenerateTransactionsAsync_Without_PackedTransaction_Test()
        {
            var address    = NormalAddress;
            var blockIndex = new BlockIndex
            {
                BlockHash   = HashHelper.ComputeFrom("BlockHash"),
                BlockHeight = 10
            };
            var proposalId = HashHelper.ComputeFrom("proposal");

            _proposalTestHelper.AddNotVotedProposalIdList(new List <Hash> {
                proposalId
            });

            var proposalCacheProvider = GetRequiredService <IProposalProvider>();

            proposalCacheProvider.AddProposal(proposalId, 5);
            await _transactionPackingOptionProvider.SetTransactionPackingOptionAsync(blockIndex, false);

            var transactionList = await _proposalApprovalTransactionGenerator.GenerateTransactionsAsync(address, blockIndex.BlockHeight, blockIndex.BlockHash);

            transactionList.Count.ShouldBe(1);
        }