Ejemplo n.º 1
0
 public TransactionStateService(
     IEthereum ethereum,
     EthereumClassicApiSettings settings)
 {
     _ethereum = ethereum;
     _settings = settings;
 }
 public BalanceObserverDispatcherRole(
     IEthereum ethereum,
     IObservableBalanceRepository observableBalanceRepository,
     EthereumClassicApiSettings settings)
 {
     _ethereum = ethereum;
     _observableBalanceRepository = observableBalanceRepository;
     _settings = settings;
 }
Ejemplo n.º 3
0
 public GasPriceOracleService(
     EthereumClassicApiSettings serviceSettings,
     IEthereum ethereum,
     IGasPriceRepository gasPriceRepository)
 {
     _defaultMaxGasPrice = BigInteger.Parse(serviceSettings.DefaultMaxGasPrice);
     _defaultMinGasPrice = BigInteger.Parse(serviceSettings.DefaultMinGasPrice);
     _ethereum           = ethereum;
     _gasPriceRepository = gasPriceRepository;
 }
Ejemplo n.º 4
0
        public void CalculateGasPriceAsync__ExpectedResultReturned(
            string defaultMinGasPrice,
            string defaultMaxGasPrice,
            string estimatedResultStr,
            string expectedResultStr,
            bool isSettingsStored)
        {
            string         to              = "0x83F0726180Cf3964b69f62AC063C5Cb9A66B3bE5";
            BigInteger     amount          = 1000000000;
            BigInteger     estimatedResult = BigInteger.Parse(estimatedResultStr);
            BigInteger     expectedResult  = BigInteger.Parse(expectedResultStr);
            GasPriceEntity newGasPriceDto  = new GasPriceEntity()
            {
                Max = BigInteger.Parse(defaultMaxGasPrice),
                Min = BigInteger.Parse(defaultMinGasPrice),
            };
            GasPriceEntity gasPriceDto = isSettingsStored ? newGasPriceDto : null;

            #region Mock

            EthereumClassicApiSettings settings           = new EthereumClassicApiSettings();
            Mock <IEthereum>           ethereum           = new Mock <IEthereum>();
            Mock <IGasPriceRepository> gasPriceRepository = new Mock <IGasPriceRepository>();

            settings.DefaultMinGasPrice = defaultMinGasPrice;
            settings.DefaultMaxGasPrice = defaultMaxGasPrice;

            ethereum.Setup(x => x.EstimateGasPriceAsync(to, amount)).Returns(Task.FromResult(estimatedResult));

            gasPriceRepository.Setup(x => x.TryGetAsync()).Returns(Task.FromResult(gasPriceDto));
            gasPriceRepository.Setup(x => x.AddOrReplaceAsync(It.IsAny <GasPriceEntity>()))
            .Returns(Task.FromResult(0)).Verifiable();

            #endregion

            GasPriceOracleService service = new GasPriceOracleService(settings, ethereum.Object, gasPriceRepository.Object);

            //ACT
            var actualCalculated = service.CalculateGasPriceAsync(to, amount).Result;

            //ASSERT
            Assert.AreEqual(expectedResult, actualCalculated);

            if (gasPriceDto == null)
            {
                gasPriceRepository.Verify(x => x.AddOrReplaceAsync(It.IsAny <GasPriceEntity>()), Times.Once());
            }
        }
Ejemplo n.º 5
0
        public TransactionMonitorDispatcherActor(
            IOperationMonitorsFactory operationMonitorsFactory,
            EthereumClassicApiSettings settings,
            ITransactionMonitorDispatcherRole transactionMonitorDispatcherRole)
        {
            _transactionMonitorDispatcherRole = transactionMonitorDispatcherRole;
            _transactionMonitors = operationMonitorsFactory.Build(Context, "transation-monitors");
            _settings            = settings;

            Become(Idle);

            Self.Tell
            (
                new CheckTransactionStates(),
                Nobody.Instance
            );
        }
        public BalanceObserverDispatcherActor(
            IBalanceObserverDispatcherRole balanceObserverDispatcherRole,
            IBalanceObserversFactory balanceObserversFactory,
            EthereumClassicApiSettings settings)
        {
            _balanceObserverDispatcherRole = balanceObserverDispatcherRole;
            _balanceObservers = balanceObserversFactory.Build(Context, "balance-observers");
            _settings         = settings;

            Become(Idle);

            Self.Tell
            (
                new CheckBalances(),
                Nobody.Instance
            );
        }
Ejemplo n.º 7
0
 public EthereumFactory(
     EthereumClassicApiSettings serviceSettings)
 {
     _serviceSettings = serviceSettings;
 }
 public OperationMonitorsFactory(
     EthereumClassicApiSettings serviceSettings)
 {
     _serviceSettings = serviceSettings;
 }
Ejemplo n.º 9
0
 public BalanceObserversFactory(
     EthereumClassicApiSettings serviceSettings)
 {
     _serviceSettings = serviceSettings;
 }