Beispiel #1
0
        public void SellGoldEstimationReversedCryptoRandom()
        {
            for (var i = 0; i < 100000; ++i)
            {
                _ratesProvider.SetSpread(0.2d);
                _ratesDispatcher.OnProviderCurrencyRate(_ratesProvider.RequestGoldPrice(TimeSpan.Zero).Result);
                _ratesDispatcher.OnProviderCurrencyRate(_ratesProvider.RequestEthPrice(TimeSpan.Zero).Result);
                _ratesDispatcher.ForceUpdate().Wait();

                var requiredCryptoAmount = (SecureRandom.GetPositiveInt() % 100000000) * BigInteger.Pow(10, TokensPrecision.Ethereum - 8);

                var rev = CoreLogic.Finance.Estimation.SellGoldCryptoRev(_services, TradableCurrency.Eth, FiatCurrency.Usd, requiredCryptoAmount + CoreLogic.Finance.Estimation.SellingFeeForCrypto(TradableCurrency.Eth, requiredCryptoAmount)).Result;
                var def = CoreLogic.Finance.Estimation.SellGoldCrypto(_services, TradableCurrency.Eth, FiatCurrency.Usd, rev.ResultGoldAmount).Result;

                Assert.True(def.Allowed && rev.Allowed);
                Assert.True(def.ResultAssetAmount >= requiredCryptoAmount + CoreLogic.Finance.Estimation.SellingFeeForCrypto(TradableCurrency.Eth, requiredCryptoAmount));
            }
        }
Beispiel #2
0
        public void BuyGoldEstimationReversedFiatRandom()
        {
            for (var i = 0; i < 100000; ++i)
            {
                _ratesProvider.SetSpread(0.2d);
                _ratesDispatcher.OnProviderCurrencyRate(_ratesProvider.RequestGoldPrice(TimeSpan.Zero).Result);
                _ratesDispatcher.OnProviderCurrencyRate(_ratesProvider.RequestEthPrice(TimeSpan.Zero).Result);
                _ratesDispatcher.ForceUpdate().Wait();

                var requiredGoldAmount = (SecureRandom.GetPositiveInt() % 200000000) * BigInteger.Pow(10, TokensPrecision.Sumus - 8);

                var rev = CoreLogic.Finance.Estimation.BuyGoldFiatRev(_services, FiatCurrency.Usd, requiredGoldAmount).Result;
                var def = CoreLogic.Finance.Estimation.BuyGoldFiat(_services, FiatCurrency.Usd, rev.ResultCentsAmount).Result;

                Assert.True(def.Allowed && rev.Allowed);
                Assert.True(def.ResultCentsAmount == rev.ResultCentsAmount);
                Assert.True(def.ResultGoldAmount >= requiredGoldAmount);
            }
        }