コード例 #1
0
        public async Task ValidateAddingNewPriceReportingAgent()
        {
            var txParams = new TransactionParams {
                From = Accounts[0]
            };                                                           // admin
            var txHash = await _contract.registerPriceAgent(Accounts[1]).SendTransaction(txParams);

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

            Assert.AreEqual(2, numberOfRegisteredPriceAgents);

            //validate total price (should not have changed from init)
            var totalBtcPriceUSDCents = await _contract.getPrice().Call();

            Assert.AreEqual(initPrice, totalBtcPriceUSDCents);


            //validate addition of new agent
            var newPriceAgentAddress = await _contract.getRegisteredPriceAgent(1).Call();

            Assert.AreEqual(newPriceAgentAddress, Accounts[1]);

            //validate new price agent report (that hasn't reported anything)
            var BtcPriceReport = await _contract.PriceAgentReports(Accounts[1]).Call();

            Assert.AreEqual(0, BtcPriceReport.price);
            Assert.AreEqual(0, BtcPriceReport.timestamp);
            Assert.AreEqual("", BtcPriceReport.source);
        }