use of org.tron.core.exception.RevokingStoreIllegalStateException in project java-tron by tronprotocol.
the class RevokingStoreTest method testPop.
@Test
public synchronized void testPop() {
revokingDatabase.getStack().clear();
TestRevokingTronStore tronDatabase = new TestRevokingTronStore("testrevokingtronstore-testPop", revokingDatabase);
TestProtoCapsule testProtoCapsule = new TestProtoCapsule();
IntStream.rangeClosed(1, 10).forEach(i -> {
try (Dialog tmpDialog = revokingDatabase.buildDialog()) {
tronDatabase.put(testProtoCapsule.getData(), testProtoCapsule);
Assert.assertFalse(tronDatabase.getDbSource().allKeys().isEmpty());
Assert.assertEquals(revokingDatabase.getActiveDialog(), 1);
tmpDialog.commit();
Assert.assertEquals(revokingDatabase.getStack().size(), i);
Assert.assertEquals(revokingDatabase.getActiveDialog(), 0);
} catch (RevokingStoreIllegalStateException e) {
logger.debug(e.getMessage(), e);
}
});
try {
revokingDatabase.pop();
} catch (RevokingStoreIllegalStateException e) {
logger.debug(e.getMessage(), e);
}
Assert.assertTrue(tronDatabase.getDbSource().allKeys().isEmpty());
Assert.assertEquals(revokingDatabase.getStack().size(), 9);
tronDatabase.close();
}
use of org.tron.core.exception.RevokingStoreIllegalStateException 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