From 5c3780e6910e60a2ff2b2f22a8aa4e10478f8bad Mon Sep 17 00:00:00 2001 From: skynetcap <100323448+skynetcap@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:04:11 -0700 Subject: [PATCH] Refactor sorting and logging in JupiterDca tests Updated the sorting criterion in `getMostRecentJupiterDcaAccounts` to use creation timestamp and enhanced logging details. Added filtering to display only active JupiterDca accounts based on specific conditions and included the size of the filtered list in the logs. --- jupiter/src/test/java/JupiterTest.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/jupiter/src/test/java/JupiterTest.java b/jupiter/src/test/java/JupiterTest.java index 022452f..b8e6f11 100644 --- a/jupiter/src/test/java/JupiterTest.java +++ b/jupiter/src/test/java/JupiterTest.java @@ -273,7 +273,7 @@ public void testJupiterTestOracleDeserialization() throws RpcException { assertTrue(testOracle.getPublishTime() > 0); // Add more assertions as needed } - + @Test public void testJupiterManager() { JupiterManager manager = new JupiterManager(client); @@ -357,10 +357,20 @@ public void testGetAllJupiterDcaAccounts() { public void getMostRecentJupiterDcaAccounts() { JupiterManager manager = new JupiterManager(client); List dcaAccounts = manager.getAllDcaAccounts(); - dcaAccounts.sort(Comparator.comparingLong(JupiterDca::getIdx).reversed()); + dcaAccounts.sort(Comparator.comparingLong(JupiterDca::getCreatedAt).reversed()); + for (int i = 0; i < 10; i++) { JupiterDca dca = dcaAccounts.get(i); - log.info("DCA #{}: {}", i + 1, dca); + log.info("DCA {} #{}: {}", Instant.ofEpochSecond(dca.getCreatedAt()),i + 1, dca); } + + log.info("Only showing ones where nextCycleAt > createdAt && nextCycleAt > now && inUsed < inDeposited"); + List activeDcas = dcaAccounts.stream() + .filter(dca -> dca.getNextCycleAt() > dca.getCreatedAt() && dca.getNextCycleAt() > Instant.now().getEpochSecond()) + .filter(dca -> dca.getInUsed() < dca.getInDeposited()) + .toList(); + + activeDcas.forEach(dca -> log.info("DCA {} #{}: {}", Instant.ofEpochSecond(dca.getCreatedAt()), dcaAccounts.indexOf(dca) + 1, dca)); + log.info("Size: {}", activeDcas.size()); } } \ No newline at end of file