Esempio n. 1
0
        public async Task ValidateDeployment()
        {
            //validate total price
            var totalBtcPriceUSDCents = await _contract.getPrice().Call();

            Assert.AreEqual(initPrice, totalBtcPriceUSDCents);

            //validate num of price agents
            var numberOfRegisteredPriceAgents = await _contract.numberOfRegisteredPriceAgents().Call();

            Assert.AreEqual(1, numberOfRegisteredPriceAgents);

            //validate max num of price agents
            var maxNumberPriceAgents = await _contract.maxNumberPriceAgents().Call();

            Assert.AreEqual(4, maxNumberPriceAgents);

            //validate that no funds are connected initially
            var numberOfConnectedFunds = await _contract.numberOfConnectedFunds().Call();

            Assert.AreEqual(0, numberOfConnectedFunds);

            //validate that deployer is the initial price agent
            var initPriceAgentAddress = await _contract.getRegisteredPriceAgent(0).Call();

            Assert.AreEqual(initPriceAgentAddress, Accounts[0]);

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

            Assert.AreEqual(initPrice, BtcPriceReport.price);
            int now = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;

            //validate decimals
            var decimals = await _contract.decimals().Call();

            Assert.AreEqual(fiatDecimals, decimals);

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

            Assert.AreEqual("meadowInit", BtcPriceReport.source);

            //validate tickers
            var baseTicker = await _contract.baseTicker().Call();

            Assert.AreEqual("BTC", baseTicker);

            var quoteTicker = await _contract.quoteTicker().Call();

            Assert.AreEqual("USD", quoteTicker);
        }