Exemple #1
0
        public void Null_query_throws()
        {
            IDb db = new MemDb();
            DepositDetailsRocksRepository repository = new DepositDetailsRocksRepository(db, new DepositDetailsDecoder());

            Assert.Throws <ArgumentNullException>(() => repository.BrowseAsync(null));
        }
Exemple #2
0
        public async Task Browse_empty_database()
        {
            IDb db = new MemDb();
            DepositDetailsRocksRepository repository = new DepositDetailsRocksRepository(db, new DepositDetailsDecoder());
            PagedResult <DepositDetails>  result     = await repository.BrowseAsync(new GetDeposits());

            result.Items.Should().HaveCount(0);
        }
Exemple #3
0
        private static async Task <PagedResult <DepositDetails> > LoadDeposits(ILogManager logManager, string dbPath)
        {
            ConsumerRocksDbProvider       consumerRocksDbProvider = new ConsumerRocksDbProvider(dbPath, DbConfig.Default, logManager);
            DepositDetailsRocksRepository depositsRepo            = new DepositDetailsRocksRepository(consumerRocksDbProvider.DepositsDb, new DepositDetailsDecoder());
            // var deposits = await depositsRepo.BrowseAsync(new GetDeposits());
            var deposits = await depositsRepo.BrowseAsync(new GetDeposits { CurrentBlockTimestamp = Timestamper.Default.EpochSecondsLong, EligibleToRefund = true });

            return(deposits);
        }
Exemple #4
0
        public async Task Browse_empty()
        {
            IDb db = new MemDb();
            DepositDetailsRocksRepository repository = new DepositDetailsRocksRepository(db, new DepositDetailsDecoder());

            foreach (DepositDetails details in _cases)
            {
                await repository.AddAsync(details);
            }

            PagedResult <DepositDetails> result = await repository.BrowseAsync(new GetDeposits { EligibleToRefund = true });

            result.Items.Should().HaveCount(0);
        }
Exemple #5
0
        public async Task Browse_unconfirmed_only()
        {
            IDb db = new MemDb();
            DepositDetailsRocksRepository repository = new DepositDetailsRocksRepository(db, new DepositDetailsDecoder());

            foreach (DepositDetails details in _cases)
            {
                await repository.AddAsync(details);
            }

            PagedResult <DepositDetails> result = await repository.BrowseAsync(new GetDeposits { OnlyUnconfirmed = true });

            result.Items.Should().HaveCount(01);
        }
Exemple #6
0
        private static async Task <PagedResult <DepositDetails> > LoadDeposits(ILogManager logManager, string dbPath)
        {
            using (var dbProvider = new DbProvider(DbModeHint.Persisted))
            {
                var rocksDbFactory = new RocksDbFactory(DbConfig.Default, logManager, dbPath);
                var dbInitializer  = new ConsumerNdmDbInitializer(dbProvider, new NdmConfig(), rocksDbFactory, new MemDbFactory());
                await dbInitializer.InitAsync();

                DepositDetailsRocksRepository depositsRepo = new DepositDetailsRocksRepository(dbProvider.GetDb <IDb>(ConsumerNdmDbNames.Deposits), new DepositDetailsDecoder());
                // var deposits = await depositsRepo.BrowseAsync(new GetDeposits());
                var deposits = await depositsRepo.BrowseAsync(new GetDeposits { CurrentBlockTimestamp = Timestamper.Default.EpochSecondsLong, EligibleToRefund = true });

                return(deposits);
            }
        }
        public async Task Browse_by_eligible_to_refund()
        {
            depositUnitsCalculator.GetConsumedAsync(Arg.Is <DepositDetails>(d => d.Timestamp == 1000)).Returns(Task.FromResult((uint)200));
            foreach (DepositDetails details in _cases)
            {
                await repository.AddAsync(details);
            }

            PagedResult <DepositDetails> result = await repository.BrowseAsync(new GetDeposits { EligibleToRefund = true, CurrentBlockTimestamp = 200 });

            result.Items.Should().HaveCount(1);
        }