public async Task ValidateDoublingEventPostConnection() { var txParams = new TransactionParams { From = Accounts[0] }; // admin //fund with strike price of initPrice Fund _FundContract; _FundContract = await Fund.New(_contract.ContractAddress, RpcClient); //connect fund await _contract.connectFund(_FundContract.ContractAddress).SendTransaction(txParams); //end var txHash = await _contract.reportPrice(12345678, "meadowUpdate").SendTransaction(txParams); //validate fund info var fundInfo = await _contract.funds(_FundContract.ContractAddress).Call(); Assert.AreEqual(_FundContract.ContractAddress, fundInfo.fund); Assert.AreEqual(true, fundInfo.endPriceConditionsReached); Assert.AreEqual(12345678, fundInfo.endPrice); Assert.AreEqual(initPrice, fundInfo.strikePrice); var hasFundEnded = await _contract.hasFundEnded(_FundContract.ContractAddress).Call(); Assert.AreEqual(true, hasFundEnded); }
public async Task ValidateConnectingFundNoMax() { //deploy a fund instance, but do no tests, that's something for the fund test suite Fund _FundContract; _FundContract = await Fund.New(_contract.ContractAddress, RpcClient); //connect fund var txParams = new TransactionParams { From = Accounts[0] }; // admin await _contract.connectFund(_FundContract.ContractAddress).SendTransaction(txParams); //validate number of connected funds var numberOfConnectedFunds = await _contract.numberOfConnectedFunds().Call(); Assert.AreEqual(1, numberOfConnectedFunds); //validate fund info var fundInfo = await _contract.funds(_FundContract.ContractAddress).Call(); Assert.AreEqual(_FundContract.ContractAddress, fundInfo.fund); Assert.AreEqual(false, fundInfo.endPriceConditionsReached); Assert.AreEqual(0, fundInfo.endPrice); //default of 0 since it hasn't ended Assert.AreEqual(initPrice, fundInfo.strikePrice); var fundAddress = await _contract.getConnectedFundAddress(0).Call(); Assert.AreEqual(_FundContract.ContractAddress, fundAddress); var hasFundEnded = await _contract.hasFundEnded(_FundContract.ContractAddress).Call(); Assert.AreEqual(false, hasFundEnded); }
public async Task ValidateConnectingFundSecurity() { //deploy a fund instance, but do no tests, that's something for the fund test suite Fund _FundContract; _FundContract = await Fund.New(_contract.ContractAddress, RpcClient); //connect fund var txParams = new TransactionParams { From = Accounts[1] }; // notadmin await _contract.connectFund(_FundContract.ContractAddress).SendTransaction(txParams); }
public async Task ValidateEndAndReturn() { Meadow.Core.EthTypes.UInt256 newPrice = 12345678; var txParams = new TransactionParams { From = Accounts[0] }; // admin //fund with strike price of initPrice Fund _FundContract; _FundContract = await Fund.New(_contract.ContractAddress, RpcClient); //connect fund await _contract.connectFund(_FundContract.ContractAddress).SendTransaction(txParams); //end var txHash = await _contract.reportPrice(newPrice, "meadowUpdate").SendTransaction(txParams); //validate fund info var fundInfo = await _contract.funds(_FundContract.ContractAddress).Call(); Assert.AreEqual(_FundContract.ContractAddress, fundInfo.fund); Assert.AreEqual(true, fundInfo.endPriceConditionsReached); Assert.AreEqual(newPrice, fundInfo.endPrice); Assert.AreEqual(initPrice, fundInfo.strikePrice); var hasFundEnded = await _contract.hasFundEnded(_FundContract.ContractAddress).Call(); Assert.AreEqual(true, hasFundEnded); //back down from end await _contract.reportPrice(initPrice, "meadowUpdate").SendTransaction(txParams); //validate fund info again fundInfo = await _contract.funds(_FundContract.ContractAddress).Call(); var EndPrice = await _contract.getEndPrice(_FundContract.ContractAddress).Call(); Assert.AreEqual(_FundContract.ContractAddress, fundInfo.fund); Assert.AreEqual(true, fundInfo.endPriceConditionsReached); Assert.AreEqual(newPrice, fundInfo.endPrice); //end price was the peak Assert.AreEqual(newPrice, EndPrice); //end price was the peak Assert.AreEqual(initPrice, fundInfo.strikePrice); hasFundEnded = await _contract.hasFundEnded(_FundContract.ContractAddress).Call(); Assert.AreEqual(true, hasFundEnded); }
public async Task ValidateConnectingFund_decimalMismatch() { //deploy a fund instance, but do no tests, that's something for the fund test suite Fund _FundContract; _FundContract = await Fund.New(_contract.ContractAddress, RpcClient); //make new price index but with other decimals // Deploy our test contract Meadow.Core.EthTypes.UInt256 fiatDecimals2 = 5; PriceIndex _contract2 = await PriceIndex.New(initPrice, "meadowInit", 4, (byte)fiatDecimals2, "BTC", "USD", RpcClient); //connect fund var txParams = new TransactionParams { From = Accounts[0] }; // admin await _contract2.connectFund(_FundContract.ContractAddress).SendTransaction(txParams); }
public async Task ValidateRequestForInvalidFund() { var fundAddress1 = await _contract.getConnectedFundAddress(0).Call(); Assert.AreEqual("0x0000000000000000000000000000000000000000", fundAddress1); Fund _FundContract; _FundContract = await Fund.New(_contract.ContractAddress, RpcClient); //connect fund var txParams = new TransactionParams { From = Accounts[0] }; // admin await _contract.connectFund(_FundContract.ContractAddress).SendTransaction(txParams); var fundAddress2 = await _contract.getConnectedFundAddress(4).Call(); Assert.AreEqual("0x0000000000000000000000000000000000000000", fundAddress2); }