Esempio n. 1
0
        public async Task ValidatePriceRegistrationUpdateFromInitNoFund()
        {
            var txParams = new TransactionParams {
                From = Accounts[0]
            };                                                           // admin
            var txHash = await _contract.reportPrice(100000000, "meadowUpdate").SendTransaction(txParams);

            //validate total price
            var totalBtcPriceUSDCents = await _contract.getPrice().Call();

            Assert.AreEqual(100000000, totalBtcPriceUSDCents);

            //validate initial price agent report
            var BtcPriceReport = await _contract.PriceAgentReports(Accounts[0]).Call();

            int now = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;

            Assert.AreEqual(100000000, BtcPriceReport.price);
            //price report should have been made within the last 60sec
            Assert.AreEqual(true, BtcPriceReport.timestamp >= now - 60 && BtcPriceReport.timestamp <= now);
            Assert.AreEqual("meadowUpdate", BtcPriceReport.source);
        }