Search in sources :

Example 6 with RevokingStoreIllegalStateException

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

Example 7 with RevokingStoreIllegalStateException

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();
}
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

RevokingStoreIllegalStateException (org.tron.core.exception.RevokingStoreIllegalStateException)7 Dialog (org.tron.core.db.AbstractRevokingStore.Dialog)6 BlockCapsule (org.tron.core.capsule.BlockCapsule)4 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 TransactionCapsule (org.tron.core.capsule.TransactionCapsule)2 ByteString (com.google.protobuf.ByteString)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 DialogOptional (org.tron.common.utils.DialogOptional)1 BalanceInsufficientException (org.tron.core.exception.BalanceInsufficientException)1 HighFreqException (org.tron.core.exception.HighFreqException)1 UnLinkedBlockException (org.tron.core.exception.UnLinkedBlockException)1