|
14 | 14 | import org.junit.After; |
15 | 15 | import org.junit.Rule; |
16 | 16 | import org.junit.rules.TemporaryFolder; |
| 17 | +import org.rocksdb.RocksDBException; |
17 | 18 | import org.tron.api.WalletGrpc; |
18 | 19 | import org.tron.common.application.Application; |
19 | 20 | import org.tron.common.application.ApplicationFactory; |
|
26 | 27 | import org.tron.common.utils.Utils; |
27 | 28 | import org.tron.core.config.DefaultConfig; |
28 | 29 | import org.tron.core.config.args.Args; |
| 30 | +import org.tron.plugins.utils.db.DBInterface; |
| 31 | +import org.tron.plugins.utils.db.DBIterator; |
| 32 | +import org.tron.plugins.utils.db.DbTool; |
29 | 33 | import picocli.CommandLine; |
30 | 34 |
|
31 | 35 | @Slf4j |
@@ -141,6 +145,10 @@ public void testTools(String dbType, int checkpointVersion, boolean advanceSnaps |
141 | 145 | Path historyDir = Paths.get(dbPath, "history"); |
142 | 146 | assertTrue(historyDir.resolve("balance-trace").toFile().exists()); |
143 | 147 | assertTrue(historyDir.resolve("account-trace").toFile().exists()); |
| 148 | + if (historyBalanceLookup) { |
| 149 | + assertDbHasEntries(historyDir, "balance-trace"); |
| 150 | + assertDbHasEntries(historyDir, "account-trace"); |
| 151 | + } |
144 | 152 | // backup original database to database_bak |
145 | 153 | File database = new File(Paths.get(dbPath, databaseDir).toString()); |
146 | 154 | if (!database.renameTo(new File(Paths.get(dbPath, databaseDir + "_bak").toString()))) { |
@@ -169,6 +177,18 @@ public void testTools(String dbType, int checkpointVersion, boolean advanceSnaps |
169 | 177 | DbLite.reSetRecentBlks(); |
170 | 178 | } |
171 | 179 |
|
| 180 | + private static void assertDbHasEntries(Path parent, String dbName) { |
| 181 | + try { |
| 182 | + DBInterface db = DbTool.getDB(parent.toString(), dbName); |
| 183 | + try (DBIterator it = db.iterator()) { |
| 184 | + it.seekToFirst(); |
| 185 | + assertTrue(dbName + " should have at least one entry", it.hasNext()); |
| 186 | + } |
| 187 | + } catch (IOException | RocksDBException e) { |
| 188 | + throw new RuntimeException(e); |
| 189 | + } |
| 190 | + } |
| 191 | + |
172 | 192 | private void generateSomeTransactions(int during) { |
173 | 193 | during *= 1000; // ms |
174 | 194 | int runTime = 0; |
|
0 commit comments