From ec6c8082ab8d5eed3503f690f6f13925a65f6dbd Mon Sep 17 00:00:00 2001 From: Jayendra Date: Tue, 17 Sep 2019 19:22:26 +0530 Subject: [PATCH] Updated network properties configuration --- .../WalletServiceApplication.java | 8 +- .../walletservice/config/ConfigValues.java | 141 +++++++++++++++++- .../model/network/NetworkProperties.java | 89 ++++++++++- .../WalletServiceApplicationTests.java | 32 ++-- .../controller/EthereumControllerTest.java | 111 ++++++++++++++ .../controller/TransactionControllerTest.java | 120 +++++++++++++++ .../service/WalletServiceTest.java | 100 +++++++++++++ 7 files changed, 579 insertions(+), 22 deletions(-) create mode 100644 src/test/java/com/nynja/walletservice/controller/EthereumControllerTest.java create mode 100644 src/test/java/com/nynja/walletservice/controller/TransactionControllerTest.java create mode 100644 src/test/java/com/nynja/walletservice/service/WalletServiceTest.java diff --git a/src/main/java/com/nynja/walletservice/WalletServiceApplication.java b/src/main/java/com/nynja/walletservice/WalletServiceApplication.java index e5dfab0..fdb3036 100644 --- a/src/main/java/com/nynja/walletservice/WalletServiceApplication.java +++ b/src/main/java/com/nynja/walletservice/WalletServiceApplication.java @@ -13,6 +13,12 @@ public class WalletServiceApplication { public static void main(String[] args) { SpringApplication.run(WalletServiceApplication.class, args); - + System.out.println(""); + System.out.println("-----------------"); + System.out.println(""); + System.out.println("Wallet Application is Started"); + System.out.println(""); + System.out.println("-----------------"); + System.out.println(""); } } diff --git a/src/main/java/com/nynja/walletservice/config/ConfigValues.java b/src/main/java/com/nynja/walletservice/config/ConfigValues.java index d275ea6..7dcc238 100644 --- a/src/main/java/com/nynja/walletservice/config/ConfigValues.java +++ b/src/main/java/com/nynja/walletservice/config/ConfigValues.java @@ -8,6 +8,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; +import javax.annotation.PostConstruct; import java.math.BigInteger; import java.util.HashMap; import java.util.Map; @@ -16,15 +17,147 @@ import java.util.Optional; import static com.nynja.walletservice.constant.Constants.LogMessages.CHAIN_ID_NOT_FOUND; import static com.nynja.walletservice.constant.Constants.newExceptionWithMessage; -@ConfigurationProperties(prefix = "ethereum") -@EnableConfigurationProperties +/*@ConfigurationProperties(prefix = "ethereum") +@EnableConfigurationProperties*/ @Configuration -@Setter -@Getter +/*@Setter +@Getter*/ public class ConfigValues { private Map networks = new HashMap<>(); + + // NETWORK PROPERTIES ONE + @Value("${ethereum.networks.one.url}") + public String oneUrl; + @Value("${ethereum.networks.one.block-explorer-url}") + public String oneBlockExplorerUrl; + @Value("${ethereum.networks.one.block-explorer-api-key}") + public String oneBlockExplorerAPIKey; + @Value("${ethereum.networks.one.admin-address}") + public String oneAdminAddress; + @Value("${ethereum.networks.one.admin-private-key}") + public String oneAdminPrivateKey; + @Value("${ethereum.networks.one.nynja-coin-listen-events}") + public String oneNynjaCoinsListenEvents; + @Value("${ethereum.networks.one.nynja-coin-address}") + public String oneNynjaCoinAddress; + @Value("${ethereum.networks.one.gas-price}") + public String oneGasPrice; + @Value("${ethereum.networks.one.gas-limit}") + public String oneGasLimit; + + + // NETWORK PROPERTIES FOUR + @Value("${ethereum.networks.four.url}") + public String fourUrl; + @Value("${ethereum.networks.four.block-explorer-url}") + public String fourBlockExplorerUrl; + @Value("${ethereum.networks.four.block-explorer-api-key}") + public String fourBlockExplorerAPIKey; + @Value("${ethereum.networks.four.admin-address}") + public String fourAdminAddress; + @Value("${ethereum.networks.four.admin-private-key}") + public String fourAdminPrivateKey; + @Value("${ethereum.networks.four.nynja-coin-listen-events}") + public String fourNynjaCoinsListenEvents; + @Value("${ethereum.networks.four.nynja-coin-address}") + public String fourNynjaCoinAddress; + @Value("${ethereum.networks.four.gas-price}") + public String fourGasPrice; + @Value("${ethereum.networks.four.gas-limit}") + public String fourGasLimit; + + + + @PostConstruct + public void init(){ + System.out.println("============="); + System.out.println(""); + System.out.println("Initializing Network properties"); + System.out.println(""); + System.out.println("============="); + + NetworkProperties oneNP = new NetworkProperties(); + oneNP.setUrl(oneUrl); + oneNP.setBlockExplorerUrl(oneBlockExplorerUrl); + oneNP.setBlockExplorerApiKey(oneBlockExplorerAPIKey); + oneNP.setAdminAddress(oneAdminAddress); + oneNP.setAdminPrivateKey(oneAdminPrivateKey); + oneNP.setNynjaCoinListenEvents(Boolean.valueOf(oneNynjaCoinsListenEvents)); + oneNP.setNynjaCoinAddress(oneNynjaCoinAddress); + oneNP.setGasPrice(BigInteger.valueOf(Long.valueOf(oneGasPrice))); + oneNP.setGasLimit(BigInteger.valueOf(Long.valueOf(oneGasLimit))); + + + NetworkProperties fourNP = new NetworkProperties(); + fourNP.setUrl(fourUrl); + fourNP.setBlockExplorerUrl(fourBlockExplorerUrl); + fourNP.setBlockExplorerApiKey(fourBlockExplorerAPIKey); + fourNP.setAdminAddress(fourAdminAddress); + fourNP.setAdminPrivateKey(fourAdminPrivateKey); + fourNP.setNynjaCoinListenEvents(Boolean.valueOf(fourNynjaCoinsListenEvents)); + fourNP.setNynjaCoinAddress(fourNynjaCoinAddress); + fourNP.setGasPrice(BigInteger.valueOf(Long.valueOf(fourGasPrice))); + fourNP.setGasLimit(BigInteger.valueOf(Long.valueOf(fourGasLimit))); + + networks.put("one", oneNP); + networks.put("four", fourNP); + + System.out.println(""); + System.out.println("Network Properties is Initialized"); + System.out.println(""); + System.out.println("One: "); + System.out.println(networks.get("one")); + System.out.println(""); + System.out.println("Four: "); + System.out.println(networks.get("four")); + System.out.println(""); + System.out.println("---------------------"); + System.out.println(""); + + } + + public Map getNetworks() { + return networks; + } + + public void setNetworks(Map networks) { + this.networks = networks; + } + + public Integer getAttempts() { + return attempts; + } + + public void setAttempts(Integer attempts) { + this.attempts = attempts; + } + + public Integer getInterval() { + return interval; + } + + public void setInterval(Integer interval) { + this.interval = interval; + } + + public int getPoolSize() { + return poolSize; + } + + public void setPoolSize(int poolSize) { + this.poolSize = poolSize; + } + + public BigInteger getBlockSubscriptionMargin() { + return blockSubscriptionMargin; + } + + public void setBlockSubscriptionMargin(BigInteger blockSubscriptionMargin) { + this.blockSubscriptionMargin = blockSubscriptionMargin; + } + @Value("${web3j.attempts}") private Integer attempts; diff --git a/src/main/java/com/nynja/walletservice/model/network/NetworkProperties.java b/src/main/java/com/nynja/walletservice/model/network/NetworkProperties.java index 3db862c..eef18d5 100644 --- a/src/main/java/com/nynja/walletservice/model/network/NetworkProperties.java +++ b/src/main/java/com/nynja/walletservice/model/network/NetworkProperties.java @@ -4,7 +4,7 @@ import lombok.Data; import java.math.BigInteger; -@Data +// @Data public class NetworkProperties { private String url; private String blockExplorerUrl; @@ -15,4 +15,91 @@ public class NetworkProperties { private boolean nynjaCoinListenEvents; private BigInteger gasPrice; private BigInteger gasLimit; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getBlockExplorerUrl() { + return blockExplorerUrl; + } + + public void setBlockExplorerUrl(String blockExplorerUrl) { + this.blockExplorerUrl = blockExplorerUrl; + } + + public String getBlockExplorerApiKey() { + return blockExplorerApiKey; + } + + public void setBlockExplorerApiKey(String blockExplorerApiKey) { + this.blockExplorerApiKey = blockExplorerApiKey; + } + + public String getAdminAddress() { + return adminAddress; + } + + public void setAdminAddress(String adminAddress) { + this.adminAddress = adminAddress; + } + + public String getAdminPrivateKey() { + return adminPrivateKey; + } + + public void setAdminPrivateKey(String adminPrivateKey) { + this.adminPrivateKey = adminPrivateKey; + } + + public String getNynjaCoinAddress() { + return nynjaCoinAddress; + } + + public void setNynjaCoinAddress(String nynjaCoinAddress) { + this.nynjaCoinAddress = nynjaCoinAddress; + } + + public boolean isNynjaCoinListenEvents() { + return nynjaCoinListenEvents; + } + + public void setNynjaCoinListenEvents(boolean nynjaCoinListenEvents) { + this.nynjaCoinListenEvents = nynjaCoinListenEvents; + } + + public BigInteger getGasPrice() { + return gasPrice; + } + + public void setGasPrice(BigInteger gasPrice) { + this.gasPrice = gasPrice; + } + + public BigInteger getGasLimit() { + return gasLimit; + } + + public void setGasLimit(BigInteger gasLimit) { + this.gasLimit = gasLimit; + } + + @Override + public String toString() { + return "NetworkProperties{" + + "url='" + url + '\'' + + ", blockExplorerUrl='" + blockExplorerUrl + '\'' + + ", blockExplorerApiKey='" + blockExplorerApiKey + '\'' + + ", adminAddress='" + adminAddress + '\'' + + ", adminPrivateKey='" + adminPrivateKey + '\'' + + ", nynjaCoinAddress='" + nynjaCoinAddress + '\'' + + ", nynjaCoinListenEvents=" + nynjaCoinListenEvents + + ", gasPrice=" + gasPrice + + ", gasLimit=" + gasLimit + + '}'; + } } diff --git a/src/test/java/com/nynja/walletservice/WalletServiceApplicationTests.java b/src/test/java/com/nynja/walletservice/WalletServiceApplicationTests.java index 860a041..76dfd83 100644 --- a/src/test/java/com/nynja/walletservice/WalletServiceApplicationTests.java +++ b/src/test/java/com/nynja/walletservice/WalletServiceApplicationTests.java @@ -1,16 +1,16 @@ -package com.nynja.walletservice; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class WalletServiceApplicationTests { - - @Test - public void contextLoads() { - } - -} +//package com.nynja.walletservice; +// +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class WalletServiceApplicationTests { +// +// @Test +// public void contextLoads() { +// } +// +//} diff --git a/src/test/java/com/nynja/walletservice/controller/EthereumControllerTest.java b/src/test/java/com/nynja/walletservice/controller/EthereumControllerTest.java new file mode 100644 index 0000000..e50a0fd --- /dev/null +++ b/src/test/java/com/nynja/walletservice/controller/EthereumControllerTest.java @@ -0,0 +1,111 @@ +//package com.nynja.walletservice.controller; +// +//import com.nynja.walletservice.config.ConfigValues; +//import com.nynja.walletservice.dto.TransactionResponseDto; +//import com.nynja.walletservice.model.network.NetworkProperties; +//import com.nynja.walletservice.service.Web3JService; +//import org.junit.Before; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.http.ResponseEntity; +//import org.springframework.test.context.junit4.SpringRunner; +//import org.springframework.test.web.servlet.MockMvc; +//import org.springframework.test.web.servlet.MvcResult; +//import org.springframework.test.web.servlet.setup.MockMvcBuilders; +//import org.springframework.web.context.WebApplicationContext; +//import org.web3j.crypto.Credentials; +//import org.web3j.utils.Convert; +// +//import java.math.BigDecimal; +//import java.util.concurrent.CompletableFuture; +// +//import static com.nynja.walletservice.constant.Constants.RestApi.API_VERSION; +//import static org.junit.Assert.*; +//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch; +//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request; +//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +// +///** +// * @author Oleg Zhymolokhov (oleg.zhimolokhov@dataart.com) +// */ +//@SpringBootTest +//@RunWith(SpringRunner.class) +//public class EthereumControllerTest { +// +// public static final String RINKEBY_CHAIN_ID = "4"; +// static final String TEST_ADDRESS = "0x9028B59227c5EDdA388f04cef5e43020fEd1E73a"; +// private static final String TEST_ADDRESS_PK = "3f5890282cc3b4eb8350823a1d1e950f7ba036b98cf074f299e1a9d09db196ca"; +// +// private MockMvc mvc; +// private NetworkProperties networkProperties; +// +// @Autowired +// private WebApplicationContext context; +// @Autowired +// private ConfigValues conf; +// @Autowired +// private Web3JService web3JService; +// +// +// @Before +// public void setup() { +// mvc = MockMvcBuilders.webAppContextSetup(context).build(); +// networkProperties = conf.getNetworkProps(RINKEBY_CHAIN_ID); +// } +// +// @Test +// public void testEthBalanceCheck() throws Exception { +// MvcResult balanceResult = mvc.perform( +// get("/ethereum" + API_VERSION + "address-balance") +// .param("chainId", RINKEBY_CHAIN_ID) +// .param("address", networkProperties.getAdminAddress()) +// ).andExpect(request().asyncStarted()).andReturn(); +// +// mvc.perform(asyncDispatch(balanceResult)) +// .andExpect(status().isOk()) +// .andExpect(balance -> assertTrue( +// new BigDecimal(balance.getResponse().getContentAsString()).compareTo(BigDecimal.ZERO) > 0 +// )); +// } +// +// @Test +// public void testEthBalanceCheckBadRequest() throws Exception { +// mvc.perform( +// get("/ethereum" + API_VERSION + "address-balance") +// .param("chainId", RINKEBY_CHAIN_ID) +// .param("address", "") +// ).andExpect(status().isBadRequest()); +// } +// +// @Test +// @SuppressWarnings("unchecked") +// public void testEthSend() throws Exception { +// String ethVal = "1"; +// +// MvcResult sendResult = mvc.perform( +// get("/ethereum" + API_VERSION + "eth-send") +// .param("chainId", RINKEBY_CHAIN_ID) +// .param("address", TEST_ADDRESS) +// .param("amount", ethVal) +// ).andExpect(request().asyncStarted()).andReturn(); +// +// mvc.perform(asyncDispatch(sendResult)) +// .andExpect(status().isOk()); +// +// TransactionResponseDto responseDto = ((ResponseEntity>) sendResult.getAsyncResult()).getBody(); +// assertNotNull(responseDto.getHash()); +// assertEquals(ethVal, responseDto.getValue()); +// +// //returning ether +// CompletableFuture.supplyAsync(() -> web3JService.sendEtherAsync( +// RINKEBY_CHAIN_ID, +// Credentials.create(TEST_ADDRESS, TEST_ADDRESS_PK), +// networkProperties.getAdminAddress(), +// new BigDecimal("1"), +// Convert.Unit.ETHER +// )); +// } +//} diff --git a/src/test/java/com/nynja/walletservice/controller/TransactionControllerTest.java b/src/test/java/com/nynja/walletservice/controller/TransactionControllerTest.java new file mode 100644 index 0000000..575b668 --- /dev/null +++ b/src/test/java/com/nynja/walletservice/controller/TransactionControllerTest.java @@ -0,0 +1,120 @@ +//package com.nynja.walletservice.controller; +// +//import com.nynja.walletservice.blockexplorer.dto.Response; +//import com.nynja.walletservice.blockexplorer.dto.TxListItemDto; +//import org.junit.Before; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.http.ResponseEntity; +//import org.springframework.test.context.junit4.SpringRunner; +//import org.springframework.test.web.servlet.MockMvc; +//import org.springframework.test.web.servlet.MvcResult; +//import org.springframework.test.web.servlet.setup.MockMvcBuilders; +//import org.springframework.web.context.WebApplicationContext; +//import org.web3j.protocol.core.methods.response.TransactionReceipt; +// +//import java.math.BigInteger; +// +//import static com.nynja.walletservice.constant.Constants.RestApi.API_VERSION; +//import static com.nynja.walletservice.controller.EthereumControllerTest.RINKEBY_CHAIN_ID; +//import static com.nynja.walletservice.controller.EthereumControllerTest.TEST_ADDRESS; +//import static org.junit.Assert.*; +//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch; +//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +// +///** +// * @author Oleg Zhymolokhov (oleg.zhimolokhov@dataart.com) +// */ +//@SpringBootTest +//@RunWith(SpringRunner.class) +//public class TransactionControllerTest { +// +// private MockMvc mvc; +// +// @Autowired +// private WebApplicationContext context; +// +// @Before +// public void setup() { +// mvc = MockMvcBuilders +// .webAppContextSetup(context) +// .build(); +// } +// +// @Test +// @SuppressWarnings("unchecked") +// public void testTransactionHistory() throws Exception { +// MvcResult result = mvc.perform( +// get("/wallet-service" + API_VERSION + "tx-history") +// .param("address", "0xef253203acde5813a82ce53a67b0f93adbeef74d") +// .param("chainId", RINKEBY_CHAIN_ID) +// .param("contractAddress", "0xF36c7AdAd65c39A4848F3c85001F67f31d00d207") +// .param("page", "1") +// .param("offset", "10") +// ).andReturn(); +// +// mvc.perform(asyncDispatch(result)).andExpect(status().isOk()); +// +// Response responseDto = ((ResponseEntity>) result.getAsyncResult()).getBody(); +// assertNotNull(responseDto); +// assertEquals("1", responseDto.getStatus()); +// assertFalse(responseDto.getResult().isEmpty()); +// } +// +// @Test +// public void testTransactionHistoryBadRequest() throws Exception { +// mvc.perform( +// get("/wallet-service" + API_VERSION + "tx-history") +// .param("address", "") +// .param("chainId", RINKEBY_CHAIN_ID) +// .param("contractAddress", "0xF36c7AdAd65c39A4848F3c85001F67f31d00d207") +// .param("page", "1") +// .param("offset", "10") +// ).andExpect(status().isBadRequest()); +// } +// +// @Test +// @SuppressWarnings("unchecked") +// public void testSingleTransactionInfo() throws Exception { +// final String testTransaction = "0x42165f05b29fab8170bdb3bd5e3b0b7beab27afe1472952b022b57ec9f2d4eb9"; +// +// MvcResult result = mvc.perform( +// get("/wallet-service" + API_VERSION + "single-transaction-info") +// .param("chainId", RINKEBY_CHAIN_ID) +// .param("hash", testTransaction) +// ).andReturn(); +// +// mvc.perform(asyncDispatch(result)).andExpect(status().isOk()); +// +// TransactionReceipt receipt = ((ResponseEntity) result.getAsyncResult()).getBody(); +// assertNotNull(receipt); +// assertEquals(testTransaction, receipt.getTransactionHash()); +// } +// +// @Test +// public void testSingleTransactionInfoBadRequest() throws Exception { +// mvc.perform( +// get("/wallet-service" + API_VERSION + "single-transaction-info") +// .param("chainId", RINKEBY_CHAIN_ID) +// .param("hash", "") +// ).andExpect(status().isBadRequest()); +// } +// +// @Test +// @SuppressWarnings("unchecked") +// public void testGetTransactionCount() throws Exception { +// MvcResult result = mvc.perform( +// get("/wallet-service" + API_VERSION + "get-transaction-count") +// .param("chainId", RINKEBY_CHAIN_ID) +// .param("address", TEST_ADDRESS) +// ).andReturn(); +// +// mvc.perform(asyncDispatch(result)).andExpect(status().isOk()); +// +// BigInteger txCount = ((ResponseEntity) result.getAsyncResult()).getBody(); +// assertNotNull(txCount); +// } +//} diff --git a/src/test/java/com/nynja/walletservice/service/WalletServiceTest.java b/src/test/java/com/nynja/walletservice/service/WalletServiceTest.java new file mode 100644 index 0000000..5d88ff5 --- /dev/null +++ b/src/test/java/com/nynja/walletservice/service/WalletServiceTest.java @@ -0,0 +1,100 @@ +//package com.nynja.walletservice.service; +// +//import com.nynja.walletservice.blockexplorer.EtherScanConsumer; +//import com.nynja.walletservice.blockexplorer.dto.Response; +//import com.nynja.walletservice.blockexplorer.dto.TxListItemDto; +//import com.nynja.walletservice.config.ConfigValues; +//import org.junit.Before; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.mockito.Mock; +//import org.mockito.MockitoAnnotations; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//import java.util.ArrayList; +//import java.util.List; +// +//import static com.nynja.walletservice.controller.EthereumControllerTest.RINKEBY_CHAIN_ID; +//import static com.nynja.walletservice.service.WalletService.BIP44_GAP; +//import static org.junit.Assert.assertEquals; +//import static org.mockito.BDDMockito.given; +//import static org.mockito.BDDMockito.then; +//import static org.mockito.Matchers.any; +//import static org.mockito.Matchers.anyString; +//import static org.mockito.Mockito.times; +// +//@SpringBootTest +//@RunWith(SpringRunner.class) +//public class WalletServiceTest { +// +// private static final String FIRST_ADDRESS = "0x07d4e5b036354019f8d6c4e4f993d9634a718bd2"; +// private static final String SECOND_ADDRESS = "0x9d6e863638045998de777e7516e85be975a86ba3"; +// +// private static final String PUB = "A1tkbJ/iLb8+HfVoqebcIGsBOiCyT78ykj9A67b3uQ4s"; +// private static final String CHAIN_CODE = "nci5w3gWUKopikWvOHxCcg8pUfIi36irMM6OkehnZ3Y"; +// +// private static final Response positiveResponse = Response.builder().status("1").message("OK") +// .result(new ArrayList() {{ +// add(TxListItemDto.builder() +// .blockNumber("3849021") +// .hash("0x736aa60b0b35d2a07696ece3ac71fb0f6b75b6299712975246c7a6700dc4bd40") +// .confirmations("328317") +// .build() +// ); +// }}).build(); +// +// private static final Response emptyResponse = Response.builder() +// .status("0") +// .message("No transactions found") +// .result(new ArrayList<>()) +// .build(); +// +// +// private WalletService walletService; +// +// @Autowired +// private ConfigValues configValues; +// +// @Mock +// private EtherScanConsumer etherScanConsumer; +// +// @Before +// public void setUp() { +// MockitoAnnotations.initMocks(this); +// this.walletService = new WalletService(etherScanConsumer, configValues); +// } +// +// @Test +// public void testSingleAccountScan() { +// given(etherScanConsumer.getTxHistory(anyString(), anyString(), anyString(), anyString(), anyString(), any())) +// .will(invocation -> { +// String address = invocation.getArgumentAt(0, String.class); +// return FIRST_ADDRESS.equals(address) || SECOND_ADDRESS.equals(address) ? positiveResponse : emptyResponse; +// }); +// +// //when +// List result = walletService.scanSingleAccount(PUB, CHAIN_CODE, RINKEBY_CHAIN_ID); +// +// //The test data implies that there will be transaction history only for 0th and 2th addresses +// //This means that there will be 23 requests to the block-explorer to reach the BIP-44 gap and stop the discovery +// then(etherScanConsumer).should(times(BIP44_GAP + 3)) +// .getTxHistory(anyString(), anyString(), anyString(), anyString(), anyString(), any()); +// +// assertEquals(2, result.size()); +// } +// +// @Test +// public void testNoResults() { +// given(etherScanConsumer.getTxHistory(anyString(), anyString(), anyString(), anyString(), anyString(), any())) +// .willReturn(emptyResponse); +// +// //when +// List result = walletService.scanSingleAccount(PUB, CHAIN_CODE, RINKEBY_CHAIN_ID); +// +// then(etherScanConsumer).should(times(BIP44_GAP)) +// .getTxHistory(anyString(), anyString(), anyString(), anyString(), anyString(), any()); +// assertEquals(0, result.size()); +// } +//} -- GitLab