Skip to content

Commit 3032ef5

Browse files
committed
add assert in ManagerTest.switchBack and ManagerTest.donotswitch
1 parent d35e2ee commit 3032ef5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/test/java/org/tron/core/db/ManagerTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,19 @@ public void doNotSwitch()
315315
dbManager.pushBlock(blockCapsule0);
316316
dbManager.pushBlock(blockCapsule1);
317317
context.getBean(KhaosDatabase.class).removeBlk(dbManager.getBlockIdByNum(num));
318+
Exception exception = null;
318319
try {
319320
dbManager.pushBlock(blockCapsule2);
320321
} catch (NonCommonBlockException e) {
321322
logger.info("do not switch fork");
322323
Assert.assertNotNull(dbManager.getBlockStore().get(blockCapsule0.getBlockId().getBytes()));
324+
Assert.assertEquals(blockCapsule0.getBlockId(),
325+
dbManager.getBlockStore().get(blockCapsule0.getBlockId().getBytes()).getBlockId());
326+
exception = e;
327+
}
328+
329+
if (exception == null) {
330+
throw new IllegalStateException();
323331
}
324332
}
325333

@@ -365,11 +373,13 @@ public void switchBack()
365373
dbManager.pushBlock(blockCapsule1);
366374
try {
367375
dbManager.pushBlock(blockCapsule2);
368-
} catch (Exception e) {
376+
} catch (ValidateScheduleException e) {
369377
logger.info("the fork chain has error block");
370378
}
371379

372380
Assert.assertNotNull(dbManager.getBlockStore().get(blockCapsule0.getBlockId().getBytes()));
381+
Assert.assertEquals(blockCapsule0.getBlockId(),
382+
dbManager.getBlockStore().get(blockCapsule0.getBlockId().getBytes()).getBlockId());
373383
}
374384

375385
private Map<ByteString, String> addTestWitnessAndAccount() {

0 commit comments

Comments
 (0)