Search in sources :

Example 6 with Dialog

use of org.tron.core.db.AbstractRevokingStore.Dialog 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();
}
Also used : Dialog(org.tron.core.db.AbstractRevokingStore.Dialog) DialogOptional(org.tron.common.utils.DialogOptional) RevokingStoreIllegalStateException(org.tron.core.exception.RevokingStoreIllegalStateException) Test(org.junit.Test)

Aggregations

Dialog (org.tron.core.db.AbstractRevokingStore.Dialog)6 RevokingStoreIllegalStateException (org.tron.core.exception.RevokingStoreIllegalStateException)6 BlockCapsule (org.tron.core.capsule.BlockCapsule)3 ContractExeException (org.tron.core.exception.ContractExeException)3 ContractValidateException (org.tron.core.exception.ContractValidateException)3 ValidateSignatureException (org.tron.core.exception.ValidateSignatureException)3 Test (org.junit.Test)2 ByteString (com.google.protobuf.ByteString)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 DialogOptional (org.tron.common.utils.DialogOptional)1 TransactionCapsule (org.tron.core.capsule.TransactionCapsule)1 BalanceInsufficientException (org.tron.core.exception.BalanceInsufficientException)1 HighFreqException (org.tron.core.exception.HighFreqException)1 UnLinkedBlockException (org.tron.core.exception.UnLinkedBlockException)1