Ejemplo n.º 1
0
 public DepositDetailsForRpc(DepositDetails deposit, uint timestamp)
 {
     Id           = deposit.Id;
     Deposit      = new DepositForRpc(deposit.Deposit);
     DataAsset    = new DataAssetForRpc(deposit.DataAsset);
     Consumer     = deposit.Consumer;
     Timestamp    = deposit.Timestamp;
     Transaction  = deposit.Transaction is null ? null : new TransactionInfoForRpc(deposit.Transaction);
     Transactions = deposit.Transactions?.Select(t => new TransactionInfoForRpc(t)).OrderBy(t => t.Timestamp) ??
                    Enumerable.Empty <TransactionInfoForRpc>();
     ConfirmationTimestamp = deposit.ConfirmationTimestamp;
     Confirmed             = deposit.Confirmed;
     Rejected                 = deposit.Rejected;
     Cancelled                = deposit.Cancelled;
     Expired                  = deposit.IsExpired(timestamp);
     RefundClaimed            = deposit.RefundClaimed;
     ClaimedRefundTransaction = deposit.ClaimedRefundTransaction is null
         ? null
         : new TransactionInfoForRpc(deposit.ClaimedRefundTransaction);
     ClaimedRefundTransactions = deposit.ClaimedRefundTransactions?.Select(t => new TransactionInfoForRpc(t))
                                 .OrderBy(t => t.Timestamp) ??
                                 Enumerable.Empty <TransactionInfoForRpc>();
     RefundCancelled       = deposit.RefundCancelled;
     ConsumedUnits         = deposit.ConsumedUnits;
     Kyc                   = deposit.Kyc;
     Confirmations         = deposit.Confirmations;
     RequiredConfirmations = deposit.RequiredConfirmations;
 }
Ejemplo n.º 2
0
        // If deposits are eligable to refund (deposit is expired / consumer hasn't consumed all units yet etc.)
        // background proccessor will try to refund them every single block proccesed.
        public void Will_try_to_refund_deposit_while_expired_and_not_consumed()
        {
            _processor.Init();
            var blockProccesed = Build.A.Block.TestObject;

            _accountService.GetAddress().Returns(TestItem.AddressB);

            var dataAsset = new DataAsset(Keccak.OfAnEmptyString, "test", "test", 1,
                                          DataAssetUnitType.Unit, 0, 10, new DataAssetRules(new DataAssetRule(1)),
                                          new DataAssetProvider(Address.Zero, "test"));

            _refundClaimant.TryClaimEarlyRefundAsync(Arg.Any <DepositDetails>(), TestItem.AddressB)
            .Returns(new RefundClaimStatus(Keccak.Zero, true));

            var consumedDeposit        = new Deposit(Keccak.Zero, 10, 1, 1);
            var consumedDepositDetails = new DepositDetails(consumedDeposit, dataAsset, null, null, 1, null);

            consumedDepositDetails.SetConsumedUnits(9);

            var refundsResult = PagedResult <DepositDetails> .Create(
                new List <DepositDetails> {
                consumedDepositDetails
            },
                1,
                1,
                1,
                1);

            _depositRepository.BrowseAsync(Arg.Any <GetDeposits>()).Returns(Task.FromResult(refundsResult));
            _blockProcessor.BlockProcessed += Raise.EventWith(new BlockProcessedEventArgs(blockProccesed, Array.Empty <TxReceipt>()));
            _consumerNotifier.Received().SendClaimedEarlyRefundAsync(Arg.Any <Keccak>(), Arg.Any <string>(), Arg.Any <Keccak>());
        }
Ejemplo n.º 3
0
        public async Task TryClaimEarlyRefundAsync(DepositDetails deposit, Address refundTo)
        {
            var now = (ulong)_blockchainBridge.Head.Timestamp;

            if (!deposit.CanClaimEarlyRefund(now))
            {
                return;
            }

            var depositId       = deposit.Deposit.Id;
            var transactionHash = deposit.ClaimedRefundTransactionHash;

            if (transactionHash is null)
            {
                var provider         = deposit.DataAsset.Provider.Address;
                var ticket           = deposit.EarlyRefundTicket;
                var earlyRefundClaim = new EarlyRefundClaim(ticket.DepositId, deposit.DataAsset.Id,
                                                            deposit.Deposit.Units, deposit.Deposit.Value, deposit.Deposit.ExpiryTime, deposit.Pepper, provider,
                                                            ticket.ClaimableAfter, ticket.Signature, refundTo);
                transactionHash = _refundService.ClaimEarlyRefund(refundTo, earlyRefundClaim);
                deposit.SetClaimedRefundTransactionHash(transactionHash);
                await _depositRepository.UpdateAsync(deposit);

                if (_logger.IsInfo)
                {
                    _logger.Info($"Claimed an early refund for deposit: '{depositId}', transaction hash: '{transactionHash}' (awaits a confirmation).");
                }
            }

            await TryConfirmClaimAsync(deposit, "early ");
        }
        private static DepositDetails BuildDummyDepositDetails()
        {
            Deposit           deposit   = new Deposit(TestItem.KeccakA, 100, 100, 100);
            DataAssetProvider provider  = new DataAssetProvider(TestItem.AddressA, "provider");
            DataAsset         dataAsset = new DataAsset(TestItem.KeccakA, "data_asset", "desc", 1, DataAssetUnitType.Time, 1000, 10000, new DataAssetRules(new DataAssetRule(1), null), provider, null, QueryType.Stream, DataAssetState.Published, null, false, null);
            DepositDetails    details   = new DepositDetails(
                deposit,
                dataAsset,
                TestItem.AddressA,
                Array.Empty <byte>(),
                10,
                Array.Empty <TransactionInfo>(),
                9,
                false,
                false,
                null,
                Array.Empty <TransactionInfo>(),
                false,
                false,
                null,
                0,
                6);

            return(details);
        }
Ejemplo n.º 5
0
        private Task AddOrUpdateAsync(DepositDetails deposit)
        {
            Serialization.Rlp.Rlp rlp = _rlpDecoder.Encode(deposit);
            _database.Set(deposit.Id, rlp.Bytes);

            return(Task.CompletedTask);
        }
Ejemplo n.º 6
0
        public Task <PagedResult <DepositDetails> > BrowseAsync(GetDeposits query)
        {
            if (query is null)
            {
                return(Task.FromResult(PagedResult <DepositDetails> .Empty));
            }

            var depositsBytes = _database.GetAll();

            if (depositsBytes.Length == 0)
            {
                return(Task.FromResult(PagedResult <DepositDetails> .Empty));
            }

            var deposits = new DepositDetails[depositsBytes.Length];

            for (var i = 0; i < depositsBytes.Length; i++)
            {
                deposits[i] = Decode(depositsBytes[i]);
            }

            var filteredDeposits = deposits.AsEnumerable();

            if (query.OnlyUnverified)
            {
                filteredDeposits = filteredDeposits.Where(d => d.VerificationTimestamp == 0);
            }

            return(Task.FromResult(filteredDeposits.OrderByDescending(d => d.Timestamp).Paginate(query)));
        }
Ejemplo n.º 7
0
 public async Task Can_add_async()
 {
     IMongoDatabase database       = MongoForTest.TempDb.GetDatabase();
     var            repo           = new DepositDetailsMongoRepository(database);
     DepositDetails depositDetails = BuildDummyDepositDetails();
     await repo.AddAsync(depositDetails);
 }
Ejemplo n.º 8
0
        public static DepositDetails DALtoDepositDetails(Deposit deposit)
        {
            DepositDetails depositDetails = new DepositDetails();

            try
            {
                DB db = new SuperGmachEntities();
                // User_in_fund u_I_F=db.UserInFunds.FirstOrDefault(uf=>uf.User_in_fundId==deposit.User_in_fundId);
                User user = db.Users.FirstOrDefault(f => f.UserId == deposit.UserId);
                //Status status = db.Status.FirstOrDefault(s => s.id == deposit.status);
                Fund fund = db.Funds.FirstOrDefault(f => f.FundId == deposit.FundId);
                depositDetails.user_name = user.lastname + " " + user.firstName;
                depositDetails.UserId    = user.UserId;
                depositDetails.FundName  = fund.fund_name;
                // depositDetails.status = deposit.status;
                depositDetails.amount = (int)deposit.Amount;
                depositDetails.date   = deposit.Date;
                depositDetails.type   = deposit.Type;
                depositDetails.Id     = deposit.DepositId;
            }
            catch (Exception e)
            {
                throw e;
            }
            return(depositDetails);
        }
Ejemplo n.º 9
0
        public async Task <RefundClaimStatus> TryClaimRefundAsync(DepositDetails deposit, Address refundTo)
        {
            ulong now = _timestamper.EpochSeconds;

            if (!deposit.CanClaimRefund(now))
            {
                return(RefundClaimStatus.Empty);
            }

            Block?latestBlock = await _blockchainBridge.GetLatestBlockAsync();

            if (latestBlock == null)
            {
                return(RefundClaimStatus.Empty);
            }

            now = (ulong)latestBlock.Timestamp;
            if (!deposit.CanClaimRefund(now))
            {
                return(RefundClaimStatus.Empty);
            }

            Keccak depositId       = deposit.Deposit.Id;
            Keccak?transactionHash = deposit.ClaimedRefundTransaction?.Hash;

            if (transactionHash is null)
            {
                Address     provider    = deposit.DataAsset.Provider.Address;
                RefundClaim refundClaim = new RefundClaim(depositId, deposit.DataAsset.Id, deposit.Deposit.Units,
                                                          deposit.Deposit.Value, deposit.Deposit.ExpiryTime, deposit.Pepper, provider, refundTo);
                UInt256 gasPrice = await _gasPriceService.GetCurrentAsync();

                transactionHash = await _refundService.ClaimRefundAsync(refundTo, refundClaim, gasPrice);

                if (transactionHash is null)
                {
                    if (_logger.IsError)
                    {
                        _logger.Error("There was an error when trying to claim refund (no transaction hash returned).");
                    }
                    return(RefundClaimStatus.Empty);
                }

                deposit.AddClaimedRefundTransaction(TransactionInfo.Default(transactionHash, 0, gasPrice,
                                                                            _refundService.GasLimit, _timestamper.EpochSeconds));
                await _depositRepository.UpdateAsync(deposit);

                if (_logger.IsInfo)
                {
                    _logger.Info($"Claimed a refund for deposit: '{depositId}', gas price: {gasPrice} wei, transaction hash: '{transactionHash}' (awaits a confirmation).");
                }
            }

            bool confirmed = await TryConfirmClaimAsync(deposit, string.Empty);

            return(confirmed
                ? RefundClaimStatus.Confirmed(transactionHash)
                : RefundClaimStatus.Unconfirmed(transactionHash));
        }
Ejemplo n.º 10
0
        private static IEnumerable <ResourceTransaction> MapPendingTransactions(DepositDetails deposit)
        {
            string depositId = deposit.Id.ToString();

            return(deposit.ClaimedRefundTransaction is null
                ? deposit.Transactions.Select(t => new ResourceTransaction(depositId, "deposit", t))
                : deposit.ClaimedRefundTransactions.Select(t => new ResourceTransaction(depositId, "refund", t)));
        }
        public async Task Update_get(DepositDetails details)
        {
            await repository.UpdateAsync(details);

            DepositDetails retrieved = await repository.GetAsync(details.Id);

            retrieved.Should().BeEquivalentTo(details);
        }
 public async Task Can_add_async()
 {
     IMongoDatabase          database = MongoForTest.TempDb.GetDatabase();
     IDepositUnitsCalculator depositUnitsCalculator = Substitute.For <IDepositUnitsCalculator>();
     var            repo           = new DepositDetailsMongoRepository(database, depositUnitsCalculator);
     DepositDetails depositDetails = BuildDummyDepositDetails();
     await repo.AddAsync(depositDetails);
 }
Ejemplo n.º 13
0
        public async Task Get_null()
        {
            IDb db = new MemDb();
            DepositDetailsRocksRepository repository = new DepositDetailsRocksRepository(db, new DepositDetailsDecoder());
            DepositDetails retrieved = await repository.GetAsync(Keccak.Zero);

            retrieved.Should().BeNull();
        }
Ejemplo n.º 14
0
 private DepositReportItem ToReportItem(DepositDetails deposit, bool expired, uint consumedUnits, IEnumerable <DataDeliveryReceiptReportItem> receiptItems)
 {
     return(new DepositReportItem(deposit.Id, deposit.DataAsset.Id, deposit.DataAsset.Name,
                                  deposit.DataAsset.Provider.Address, deposit.DataAsset.Provider.Name, deposit.Deposit.Value,
                                  deposit.Deposit.Units, deposit.Consumer, deposit.Timestamp, deposit.Deposit.ExpiryTime, expired,
                                  deposit.Transaction?.Hash, deposit.ConfirmationTimestamp, deposit.Confirmations,
                                  deposit.RequiredConfirmations, deposit.Confirmed, deposit.Rejected,
                                  deposit.ClaimedRefundTransaction?.Hash, deposit.RefundClaimed, consumedUnits, receiptItems));
 }
        public void Setup()
        {
            DataAssetProvider provider = new DataAssetProvider(_providerAddress, "provider");

            _asset = new DataAsset(Keccak.Compute("1"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.Published);

            _deposit = new Deposit(Keccak.Zero, 1, 2, 3);
            _details = new DepositDetails(_deposit, _asset, Address.Zero, new byte[0], 1, new TransactionInfo[0]);
        }
        public async Task TryConfirmAsync(DepositDetails deposit)
        {
            if (deposit.Confirmed || deposit.Rejected)
            {
                return;
            }

            var transactionHash = deposit.TransactionHash;
            var transaction     = await _blockchainBridge.GetTransactionAsync(deposit.TransactionHash);

            if (transaction is null)
            {
                if (_logger.IsInfo)
                {
                    _logger.Info($"Transaction was not found for hash: '{transactionHash}' for deposit: '{deposit.Id}' to be confirmed.");
                }
                return;
            }

            var headNumber = await _blockchainBridge.GetLatestBlockNumberAsync();

            var(confirmations, rejected) = await VerifyDepositConfirmationsAsync(deposit, transaction, headNumber);

            if (rejected)
            {
                deposit.Reject();
                await _depositRepository.UpdateAsync(deposit);

                await _consumerNotifier.SendDepositRejectedAsync(deposit.Id);

                return;
            }

            if (_logger.IsInfo)
            {
                _logger.Info($"Deposit: '{deposit.Id}' has {confirmations} confirmations (required at least {_requiredBlockConfirmations}) for transaction hash: '{transactionHash}' to be confirmed.");
            }
            var confirmed = confirmations >= _requiredBlockConfirmations;

            if (confirmed)
            {
                if (_logger.IsInfo)
                {
                    _logger.Info($"Deposit with id: '{deposit.Deposit.Id}' has been confirmed.");
                }
            }

            if (confirmations != deposit.Confirmations || confirmed)
            {
                deposit.SetConfirmations(confirmations);
                await _depositRepository.UpdateAsync(deposit);
            }

            await _consumerNotifier.SendDepositConfirmationsStatusAsync(deposit.Id, deposit.DataAsset.Name,
                                                                        confirmations, _requiredBlockConfirmations, deposit.ConfirmationTimestamp, confirmed);
        }
Ejemplo n.º 17
0
        public async Task <RefundClaimStatus> TryClaimEarlyRefundAsync(DepositDetails deposit, Address refundTo)
        {
            var now = _timestamper.EpochSeconds;

            if (!deposit.CanClaimEarlyRefund(now))
            {
                return(RefundClaimStatus.Empty);
            }

            var latestBlock = await _blockchainBridge.GetLatestBlockAsync();

            now = (ulong)latestBlock.Timestamp;
            if (!deposit.CanClaimEarlyRefund(now))
            {
                return(RefundClaimStatus.Empty);
            }

            var depositId       = deposit.Deposit.Id;
            var transactionHash = deposit.ClaimedRefundTransaction?.Hash;

            if (transactionHash is null)
            {
                var provider         = deposit.DataAsset.Provider.Address;
                var ticket           = deposit.EarlyRefundTicket;
                var earlyRefundClaim = new EarlyRefundClaim(ticket.DepositId, deposit.DataAsset.Id,
                                                            deposit.Deposit.Units, deposit.Deposit.Value, deposit.Deposit.ExpiryTime, deposit.Pepper, provider,
                                                            ticket.ClaimableAfter, ticket.Signature, refundTo);
                var gasPrice = await _gasPriceService.GetCurrentAsync();

                transactionHash = await _refundService.ClaimEarlyRefundAsync(refundTo, earlyRefundClaim, gasPrice);

                if (transactionHash is null)
                {
                    if (_logger.IsError)
                    {
                        _logger.Error("There was an error when trying to claim early refund (no transaction hash returned).");
                    }
                    return(RefundClaimStatus.Empty);
                }

                deposit.SetClaimedRefundTransaction(new TransactionInfo(transactionHash, 0, gasPrice,
                                                                        _refundService.GasLimit, _timestamper.EpochSeconds));
                await _depositRepository.UpdateAsync(deposit);

                if (_logger.IsInfo)
                {
                    _logger.Info($"Claimed an early refund for deposit: '{depositId}', gas price: {gasPrice} wei, transaction hash: '{transactionHash}' (awaits a confirmation).");
                }
            }

            var confirmed = await TryConfirmClaimAsync(deposit, "early ");

            return(confirmed
                ? RefundClaimStatus.Confirmed(transactionHash)
                : RefundClaimStatus.Unconfirmed(transactionHash));
        }
Ejemplo n.º 18
0
        public async Task Update_get(DepositDetails details)
        {
            IDb db = new MemDb();
            DepositDetailsRocksRepository repository = new DepositDetailsRocksRepository(db, new DepositDetailsDecoder());
            await repository.UpdateAsync(details);

            DepositDetails retrieved = await repository.GetAsync(details.Id);

            retrieved.Should().BeEquivalentTo(details);
        }
        public async Task <PagedResult <DepositDetails> > BrowseAsync(GetDeposits query)
        {
            if (query is null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var depositsBytes = _database.GetAllValues().ToArray();

            if (depositsBytes.Length == 0)
            {
                return(PagedResult <DepositDetails> .Empty);
            }

            DepositDetails[] deposits = new DepositDetails[depositsBytes.Length];
            for (var i = 0; i < depositsBytes.Length; i++)
            {
                deposits[i] = Decode(depositsBytes[i]);
            }

            IEnumerable <DepositDetails> filteredDeposits = deposits.AsEnumerable();

            if (query.OnlyPending)
            {
                filteredDeposits = filteredDeposits.Where(d => !d.Rejected && !d.RefundClaimed &&
                                                          (d.Transaction?.State == TransactionState.Pending ||
                                                           d.ClaimedRefundTransaction?.State ==
                                                           TransactionState.Pending));
            }

            if (query.OnlyUnconfirmed)
            {
                filteredDeposits = filteredDeposits.Where(d => d.ConfirmationTimestamp == 0 ||
                                                          d.Confirmations < d.RequiredConfirmations);
            }

            if (query.OnlyNotRejected)
            {
                filteredDeposits = filteredDeposits.Where(d => !d.Rejected);
            }

            if (query.EligibleToRefund)
            {
                foreach (var deposit in deposits)
                {
                    uint consumedUnits = await _depositUnitsCalculator.GetConsumedAsync(deposit);

                    deposit.SetConsumedUnits(consumedUnits);
                }

                filteredDeposits = GetEligibleToRefund(filteredDeposits, query.CurrentBlockTimestamp);
            }

            return(filteredDeposits.OrderByDescending(d => d.Timestamp).ToArray().Paginate(query));
        }
Ejemplo n.º 20
0
        public async Task Get_assets(DepositDetails depositDetails)
        {
            IDb db = new MemDb();
            DepositDetailsRocksRepository detailsRocksRepository = new DepositDetailsRocksRepository(db, new DepositDetailsDecoder());
            await detailsRocksRepository.AddAsync(depositDetails);
            
            ProviderRocksRepository repository = new ProviderRocksRepository(db, new DepositDetailsDecoder());

            var retrieved = await repository.GetDataAssetsAsync();
            retrieved.Count.Should().Be(1);
        }
Ejemplo n.º 21
0
        public async Task Can_get_by_id()
        {
            IMongoDatabase database       = MongoForTest.TempDb.GetDatabase();
            var            repo           = new DepositDetailsMongoRepository(database);
            DepositDetails depositDetails = BuildDummyDepositDetails();
            await repo.AddAsync(depositDetails);

            DepositDetails result = await repo.GetAsync(depositDetails.Id);

            result.Should().BeEquivalentTo(depositDetails);
        }
Ejemplo n.º 22
0
 public ActionResult Update([FromBody] DepositDetails deposit)
 {
     try
     {
         DepositBL.Update(deposit);
     }
     catch (Exception e)
     {
         return(BadRequest(e.ToString()));
     }
     return(Ok());
 }
Ejemplo n.º 23
0
        public async Task Get_providers(DepositDetails depositDetails)
        {
            IDb db = new MemDb();
            IDepositUnitsCalculator       depositUnitsCalculator = Substitute.For <IDepositUnitsCalculator>();
            DepositDetailsRocksRepository detailsRocksRepository = new DepositDetailsRocksRepository(db, new DepositDetailsDecoder(), depositUnitsCalculator);
            await detailsRocksRepository.AddAsync(depositDetails);

            ProviderRocksRepository repository = new ProviderRocksRepository(db, new DepositDetailsDecoder());

            var retrieved = await repository.GetProvidersAsync();

            retrieved.Count.Should().Be(1);
        }
Ejemplo n.º 24
0
        public Task <PagedResult <DepositDetails> > BrowseAsync(GetDeposits query)
        {
            if (query is null)
            {
                return(Task.FromResult(PagedResult <DepositDetails> .Empty));
            }

            var depositsBytes = _database.GetAll();

            if (depositsBytes.Length == 0)
            {
                return(Task.FromResult(PagedResult <DepositDetails> .Empty));
            }

            var deposits = new DepositDetails[depositsBytes.Length];

            for (var i = 0; i < depositsBytes.Length; i++)
            {
                deposits[i] = Decode(depositsBytes[i]);
            }

            var filteredDeposits = deposits.AsEnumerable();

            if (query.OnlyPending)
            {
                filteredDeposits = filteredDeposits.Where(d => !d.Rejected && !d.RefundClaimed &&
                                                          d.Transaction?.State == TransactionState.Pending ||
                                                          d.ClaimedRefundTransaction?.State ==
                                                          TransactionState.Pending);
            }

            if (query.OnlyUnconfirmed)
            {
                filteredDeposits = filteredDeposits.Where(d => d.ConfirmationTimestamp == 0 ||
                                                          d.Confirmations < d.RequiredConfirmations);
            }

            if (query.OnlyNotRejected)
            {
                filteredDeposits = filteredDeposits.Where(d => !d.Rejected);
            }

            if (query.EligibleToRefund)
            {
                filteredDeposits = filteredDeposits.Where(d => !d.RefundClaimed &&
                                                          (!(d.EarlyRefundTicket is null) ||
                                                           query.CurrentBlockTimestamp >= d.Deposit.ExpiryTime));
            }

            return(Task.FromResult(filteredDeposits.OrderByDescending(d => d.Timestamp).Paginate(query)));
        }
Ejemplo n.º 25
0
        private IEnumerable <DepositDetails> GetAll()
        {
            byte[][] depositsBytes = _database.GetAllValues().ToArray();
            if (depositsBytes.Length == 0)
            {
                yield break;
            }

            DepositDetails[] dataAssets = new DepositDetails[depositsBytes.Length];
            for (int i = 0; i < depositsBytes.Length; i++)
            {
                yield return(dataAssets[i] = Decode(depositsBytes[i]));
            }
        }
Ejemplo n.º 26
0
        public void equals_returns_correctly_false()
        {
            var deposit        = new Deposit(Keccak.OfAnEmptyString, 10, 10, 10);
            var depositDetails = new DepositDetails(deposit,
                                                    _dataAsset,
                                                    _consumerAddress,
                                                    pepper: new byte[] { 5, 8, 6 },
                                                    timestamp: 50,
                                                    transactions: null);

            bool equals = depositDetails.Equals(_depositDetails);

            Assert.IsFalse(equals);
        }
Ejemplo n.º 27
0
        public void Roundtrip(DepositDetails item)
        {
            DepositDecoder.Init();
            TransactionInfoDecoder.Init();
            DataAssetDecoder.Init();
            DataAssetRuleDecoder.Init();
            DataAssetRulesDecoder.Init();
            DataAssetProviderDecoder.Init();
            EarlyRefundTicketDecoder.Init();

            DepositDetailsDecoder decoder = new DepositDetailsDecoder();

            decoder.Decode(decoder.Encode(item).Bytes.AsRlpStream()).Should().BeEquivalentTo(item);
        }
Ejemplo n.º 28
0
        public ActionResult GetById([FromRoute] int id)
        {
            DepositDetails deposit = new DepositDetails();

            try
            {
                deposit = DepositBL.GetById(id);
            }
            catch (Exception e)
            {
                return(BadRequest(e.ToString()));
            }
            return(Ok(deposit));
        }
 public DepositDetailsForRpc(DepositDetails deposit)
 {
     Id                           = deposit.Id;
     Deposit                      = new DepositForRpc(deposit.Deposit);
     DataHeader                   = new DataHeaderForRpc(deposit.DataHeader);
     Timestamp                    = deposit.Timestamp;
     TransactionHash              = deposit.TransactionHash;
     VerificationTimestamp        = deposit.VerificationTimestamp;
     Verified                     = deposit.Verified;
     RefundClaimed                = deposit.RefundClaimed;
     ClaimedRefundTransactionHash = deposit.ClaimedRefundTransactionHash;
     ConsumedUnits                = deposit.ConsumedUnits;
     Kyc                          = deposit.Kyc;
 }
Ejemplo n.º 30
0
        public async Task set_early_refund_ticket_should_succeed_if_deposit_exists()
        {
            const RefundReason reason = RefundReason.DataDiscontinued;
            var deposit        = new Deposit(TestItem.KeccakA, 1, 1, 1);
            var depositDetails = new DepositDetails(deposit, null, null, null, 0, null, 0);
            var ticket         = new EarlyRefundTicket(deposit.Id, 0, null);
            var refundService  = new RefundService(_ndmBridge, _abiEncoder, _depositRepository, _contractAddress, LimboLogs.Instance);

            _depositRepository.GetAsync(ticket.DepositId).Returns(depositDetails);
            await refundService.SetEarlyRefundTicketAsync(ticket, reason);

            depositDetails.EarlyRefundTicket.Should().Be(ticket);
            await _depositRepository.Received().GetAsync(ticket.DepositId);

            await _depositRepository.Received().UpdateAsync(depositDetails);
        }