diff --git a/src/test/java/org/bdware/sc/test/synctest/MemoryDumpRecoverTest.java b/src/test/java/org/bdware/sc/memory/test/MemoryDumpRecoverTest.java similarity index 94% rename from src/test/java/org/bdware/sc/test/synctest/MemoryDumpRecoverTest.java rename to src/test/java/org/bdware/sc/memory/test/MemoryDumpRecoverTest.java index 69834d8..1e4af6e 100644 --- a/src/test/java/org/bdware/sc/test/synctest/MemoryDumpRecoverTest.java +++ b/src/test/java/org/bdware/sc/memory/test/MemoryDumpRecoverTest.java @@ -1,6 +1,7 @@ -package org.bdware.sc.test.synctest; +package org.bdware.sc.memory.test; -import java.io.*; +import java.io.FileInputStream; +import java.io.IOException; import java.util.Scanner; public class MemoryDumpRecoverTest { @@ -14,7 +15,7 @@ public class MemoryDumpRecoverTest { StringBuilder sb = new StringBuilder(); try { Scanner sc = new Scanner(new FileInputStream(file)); - for (; sc.hasNextLine();) { + while (sc.hasNextLine()) { sb.append(sc.nextLine()).append("\n"); } } catch (Exception e) { diff --git a/src/test/java/org/bdware/sc/test/synctest/MemoryDumpTest.java b/src/test/java/org/bdware/sc/memory/test/MemoryDumpTest.java similarity index 97% rename from src/test/java/org/bdware/sc/test/synctest/MemoryDumpTest.java rename to src/test/java/org/bdware/sc/memory/test/MemoryDumpTest.java index c069ef9..af994aa 100644 --- a/src/test/java/org/bdware/sc/test/synctest/MemoryDumpTest.java +++ b/src/test/java/org/bdware/sc/memory/test/MemoryDumpTest.java @@ -1,6 +1,6 @@ -package org.bdware.sc.test.synctest; +package org.bdware.sc.memory.test; -import java.io.*; +import java.io.IOException; public class MemoryDumpTest { public static void main(String[] args) throws IOException { diff --git a/src/test/java/org/bdware/sc/memory/test/PrintMemory.java b/src/test/java/org/bdware/sc/memory/test/PrintMemory.java new file mode 100644 index 0000000..a478e4c --- /dev/null +++ b/src/test/java/org/bdware/sc/memory/test/PrintMemory.java @@ -0,0 +1,32 @@ +package org.bdware.sc.memory.test; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.bdware.sc.memory.MemoryDumpUtil; +import org.bdware.sc.util.HashUtil; +import org.junit.Test; + +import java.net.URL; + +public class PrintMemory { + private static final Logger LOGGER = LogManager.getLogger(PrintMemory.class); + + @Test + public void printBDCoin() { + printMemory("/memory/BDCoin.ckpt"); + } + + @Test + public void printCounter() { + printMemory("/memory/Counter.ckpt"); + } + + private void printMemory(String path) { + URL resource = this.getClass().getResource(path); + assert null != resource; + String content = MemoryDumpUtil.getContentFromFile(resource.getFile()); + assert null != content; + LOGGER.info(content.length()); + LOGGER.info(HashUtil.sha3(content)); + } +} diff --git a/src/test/java/org/bdware/sc/test/synctest/PrintMemory.java b/src/test/java/org/bdware/sc/test/synctest/PrintMemory.java deleted file mode 100644 index 5afa3b9..0000000 --- a/src/test/java/org/bdware/sc/test/synctest/PrintMemory.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.bdware.sc.test.synctest; - -import org.bdware.sc.memory.MemoryDumpUtil; - -public class PrintMemory { - - public static void main(String[] args){ - printMemory(); - } - - public static void printMemory(){ - String path = "/Users/zhangyixuan/Lab/new/BDContract/front-agent/BDWareProjectDir/ADSPDir/-1676897265/memory/2020-08-15-22:04:17_175580150"; - - String path2 = "/Users/zhangyixuan/Lab/new/BDContract/front-agent/BDWareProjectDir/memory/mathOperation/2021-01-30.15:38:13"; - String content = MemoryDumpUtil.getContentFromFile(path2); - System.out.println(content); - } -} diff --git a/src/test/resources/memory/BDCoin.ckpt b/src/test/resources/memory/BDCoin.ckpt new file mode 100644 index 0000000..df5f643 Binary files /dev/null and b/src/test/resources/memory/BDCoin.ckpt differ diff --git a/src/test/resources/memory/Counter.ckpt b/src/test/resources/memory/Counter.ckpt new file mode 100644 index 0000000..f8cec9f Binary files /dev/null and b/src/test/resources/memory/Counter.ckpt differ