Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Dec 24, 2023
1 parent 910a990 commit b681173
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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<String> typeTags = new ArrayList<>();
typeTags.add("0x00000000000000000000000000000001::STC::STC");
typeTags.add("0xbd7e8be8fae9f60f2f5136433e36a091::Usdx::Usdx");
List<String> 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<Object> result = client.call(call);
System.out.println(result);

} catch (JSONRPC2SessionException | MalformedURLException e) {
e.printStackTrace();
}
List<Object> 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<String[], Long[]> poolReserves = ServiceUtils.getTokenReserveFromState(client, "0x8c109349c6bd91411d6bc962e080c4a3", "0x23cd65c679f1e64aba2b9684b995349f362fb9775f40bc503c0c065490260208");
for (String[] key: poolReserves.keySet()) {
Map<String[], Long[]> 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]);
Expand Down

0 comments on commit b681173

Please sign in to comment.