public async Task BadRequestForInvalidAddressFormat() { var jsonRpcMock = new Mock <IJsonRpcClient>(); var controller = new EthereumController(jsonRpcMock.Object); var result = await controller.Search(0, "rahrah"); Assert.IsType <BadRequestObjectResult>(result); }
public async Task FiltersTransactionsForAddress() { var jsonRpcMock = new Mock <IJsonRpcClient>(); var jsonRpcResponse = new JsonRpcBlockResponseResult { Hash = BlockHash, Number = BlockNumber, Transactions = new List <JsonRpcTransactionResponse> { new JsonRpcTransactionResponse { BlockNumber = BlockNumber, BlockHash = BlockHash, Hash = TxHash1, From = Addr1, To = Addr3, Value = Value, Gas = Gas }, new JsonRpcTransactionResponse { BlockNumber = BlockNumber, BlockHash = BlockHash, Hash = TxHash2, From = Addr1, To = Addr2, Value = Value, Gas = Gas }, new JsonRpcTransactionResponse { BlockNumber = BlockNumber, BlockHash = BlockHash, Hash = TxHash3, From = Addr3, To = Addr2, Value = Value, Gas = Gas } } }; jsonRpcMock.Setup(x => x.GetBlockByHeightAsync(BlockNumber, true)) .Returns(Task.FromResult(jsonRpcResponse)); var controller = new EthereumController(jsonRpcMock.Object); var result = (OkObjectResult)await controller.Search(7, Addr3); var returnedJson = (SearchResultViewModel)result.Value; Assert.Equal(2, returnedJson.Transactions.Count()); }
// ------------------------------------------- /* * GetAllTransactionsReal */ public void GetAllTransactionsReal() { AddLog("++INPUT TRANSACTIONS[" + EthereumController.Instance.InTransactionsHistory.Count + "]++"); for (int i = 0; i < EthereumController.Instance.InTransactionsHistory.Count; i++) { ItemMultiObjectEntry transaction = EthereumController.Instance.InTransactionsHistory[i]; AddLog(EthereumController.ToStringTransaction(transaction)); } AddLog("--OUTPUT TRANSACTIONS[" + EthereumController.Instance.OutTransactionsHistory.Count + "]--"); for (int i = 0; i < EthereumController.Instance.OutTransactionsHistory.Count; i++) { ItemMultiObjectEntry transaction = EthereumController.Instance.OutTransactionsHistory[i]; AddLog(EthereumController.ToStringTransaction(transaction)); } }
// ------------------------------------------- /* * UpdateCurrency */ public void UpdateCurrency() { #if ENABLE_ETHEREUM string balanceCurrencyWallet = (EthereumController.FromWei(new BigInteger(m_amount)) * EthereumController.Instance.CurrenciesExchange[EthereumController.Instance.CurrentCurrency]).ToString(); m_container.Find("Price").GetComponent <Text>().text = Utilities.Trim(balanceCurrencyWallet); m_container.Find("Currency").GetComponent <Text>().text = EthereumController.Instance.CurrentCurrency; foreach (KeyValuePair <string, Transform> item in m_iconsCurrencies) { if (item.Key == EthereumController.Instance.CurrentCurrency) { item.Value.gameObject.SetActive(true); } else { item.Value.gameObject.SetActive(false); } } #endif }
// ------------------------------------------- /* * Constructor */ public void Initialize(params object[] _list) { ItemMultiObjectEntry item = (ItemMultiObjectEntry)_list[0]; m_container = this.gameObject.transform; m_id = (string)item.Objects[0]; m_date = (DateTime)item.Objects[1]; m_amount = (decimal)item.Objects[2]; m_gas = (string)item.Objects[3]; m_title = (string)item.Objects[4]; List <ItemMultiTextEntry> transactionScriptPubKey = (List <ItemMultiTextEntry>)item.Objects[5]; string addresses = ""; for (int i = 0; i < transactionScriptPubKey.Count; i++) { ItemMultiTextEntry sitem = transactionScriptPubKey[i]; if (addresses.Length > 0) { addresses += ":"; } addresses += sitem.Items[1]; } m_container.Find("Target").GetComponent <Text>().text = EthereumController.Instance.AddressToLabelUpperCase(addresses.Split(':')); m_container.Find("Title").GetComponent <Text>().text = m_title; string dateTrimmed = m_date.ToString(); m_container.Find("Date").GetComponent <Text>().text = dateTrimmed; #if ENABLE_ETHEREUM m_container.Find("Bitcoins").GetComponent <Text>().text = Utilities.Trim(EthereumController.FromWei(new BigInteger(m_amount)).ToString()); #endif if (m_amount < 0) { m_container.GetComponent <Image>().color = new Color(188f / 255f, 83f / 255f, 141f / 255f); m_container.Find("IconsCalendar/Input").gameObject.SetActive(false); m_container.Find("IconsCalendar/Output").gameObject.SetActive(true); m_container.Find("IconsType/Sent").gameObject.SetActive(true); m_container.Find("IconsType/Received").gameObject.SetActive(false); } else { m_container.GetComponent <Image>().color = new Color(53f / 255f, 174f / 255f, 64f / 255f); m_container.Find("IconsCalendar/Input").gameObject.SetActive(true); m_container.Find("IconsCalendar/Output").gameObject.SetActive(false); m_container.Find("IconsType/Sent").gameObject.SetActive(false); m_container.Find("IconsType/Received").gameObject.SetActive(true); } m_iconsCurrencies.Clear(); for (int i = 0; i < EthereumController.CURRENCY_CODE.Length; i++) { m_iconsCurrencies.Add(EthereumController.CURRENCY_CODE[i], m_container.Find("IconsCurrency/" + EthereumController.CURRENCY_CODE[i])); } UpdateCurrency(); EthereumEventController.Instance.EthereumEvent += new EthereumEventHandler(OnEthereumEvent); }