use of org.tron.common.utils.DialogOptional in project java-tron by tronprotocol.
the class RevokingStoreTest method testUndo.
@Test
public synchronized void testUndo() {
revokingDatabase.getStack().clear();
TestRevokingTronStore tronDatabase = new TestRevokingTronStore("testrevokingtronstore-testUndo", revokingDatabase);
TestProtoCapsule testProtoCapsule = new TestProtoCapsule();
DialogOptional dialog = DialogOptional.of(revokingDatabase.buildDialog());
IntStream.range(0, 10).forEach(i -> {
try (Dialog tmpDialog = revokingDatabase.buildDialog()) {
tronDatabase.put(testProtoCapsule.getData(), testProtoCapsule);
Assert.assertFalse(tronDatabase.getDbSource().allKeys().isEmpty());
Assert.assertEquals(revokingDatabase.getStack().size(), 2);
tmpDialog.merge();
Assert.assertEquals(revokingDatabase.getStack().size(), 1);
} catch (RevokingStoreIllegalStateException e) {
logger.debug(e.getMessage(), e);
}
});
Assert.assertEquals(revokingDatabase.getStack().size(), 1);
dialog.reset();
Assert.assertTrue(revokingDatabase.getStack().isEmpty());
Assert.assertTrue(tronDatabase.getDbSource().allKeys().isEmpty());
Assert.assertEquals(revokingDatabase.getActiveDialog(), 0);
tronDatabase.close();
}
Aggregations