From 36c45f1ba046cf7788002aaeac6441e720c8da6b Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Sun, 24 Dec 2023 16:10:32 +0800 Subject: [PATCH] fix test --- .../org/starcoin/indexer/handler/TvlTest.java | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/starcoin-indexer/src/test/java/org/starcoin/indexer/handler/TvlTest.java b/starcoin-indexer/src/test/java/org/starcoin/indexer/handler/TvlTest.java index c88d23c..ef80e5f 100644 --- a/starcoin-indexer/src/test/java/org/starcoin/indexer/handler/TvlTest.java +++ b/starcoin-indexer/src/test/java/org/starcoin/indexer/handler/TvlTest.java @@ -15,34 +15,29 @@ public class TvlTest { @Test - public void testTvl() { - try { - ContractRPCClient client = new ContractRPCClient(new URL("http://barnard1.seed.starcoin.org:9850")); + public void testTvl() throws MalformedURLException, org.starcoin.jsonrpc.client.JSONRPC2SessionException { + ContractRPCClient client = new ContractRPCClient(new URL("http://barnard1.seed.starcoin.org:9850")); - ContractCall call = new ContractCall(); + ContractCall call = new ContractCall(); - call.setFunctionId("0xbd7e8be8fae9f60f2f5136433e36a091::TokenSwap::get_reserves"); + call.setFunctionId("0xbd7e8be8fae9f60f2f5136433e36a091::TokenSwap::get_reserves"); - List typeTags = new ArrayList<>(); - typeTags.add("0x00000000000000000000000000000001::STC::STC"); - typeTags.add("0xbd7e8be8fae9f60f2f5136433e36a091::Usdx::Usdx"); + List typeTags = new ArrayList<>(); + typeTags.add("0x00000000000000000000000000000001::STC::STC"); + typeTags.add("0xbd7e8be8fae9f60f2f5136433e36a091::Usdx::Usdx"); - call.setTypeArgs(typeTags); - call.setArgs(new ArrayList<>()); + call.setTypeArgs(typeTags); + call.setArgs(new ArrayList<>()); - List result = client.call(call); - System.out.println(result); - - } catch (JSONRPC2SessionException | MalformedURLException e) { - e.printStackTrace(); - } + List result = client.call(call); + System.out.println(result); } @Test public void TestGetTokenReserve() throws MalformedURLException, JSONRPC2SessionException { StateRPCClient client = new StateRPCClient(new URL("http://main.seed.starcoin.org:9850")); - Map poolReserves = ServiceUtils.getTokenReserveFromState(client, "0x8c109349c6bd91411d6bc962e080c4a3", "0x23cd65c679f1e64aba2b9684b995349f362fb9775f40bc503c0c065490260208"); - for (String[] key: poolReserves.keySet()) { + Map poolReserves = ServiceUtils.getTokenReserveFromState(client, "0x8c109349c6bd91411d6bc962e080c4a3", "0x23cd65c679f1e64aba2b9684b995349f362fb9775f40bc503c0c065490260208"); + for (String[] key : poolReserves.keySet()) { System.out.println(key[0] + "," + key[1]); Long[] value = poolReserves.get(key); System.out.println(value[0] + "," + value[1]);