use of neo.model.ScriptVerificationResultEnum in project neo-java by coranos.
the class TestVm method testTransaction.
private void testTransaction(final long blockHeight, final int txIx) {
final LocalNodeData localNodeData = CONTROLLER.getLocalNodeData();
final BlockDb blockDb = localNodeData.getBlockDb();
final Block block = blockDb.getFullBlockFromHeight(blockHeight);
final int maxTxIx = block.getTransactionList().size();
final Transaction tx = block.getTransactionList().get(txIx);
final long maxIndex = blockDb.getHeaderOfBlockWithMaxIndex().getIndexAsLong();
LOG.info("STARTED block {} of {} tx {} of {} : {} {}", blockHeight, maxIndex, txIx, maxTxIx, tx.type, tx.getHash());
final ScriptVerificationResultEnum verifyScriptsResult = VerifyScriptUtil.verifyScripts(blockDb, tx);
if (!verifyScriptsResult.equals(ScriptVerificationResultEnum.PASS)) {
LOG.error("FAILURE block {} of {} tx {} of {} : {} {} : {}", blockHeight, maxIndex, txIx, maxTxIx, tx.type, tx.getHash(), verifyScriptsResult);
throw new RuntimeException("script failed : " + verifyScriptsResult);
} else {
LOG.info("SUCCESS block {} of {} tx {} of {} : {} {}", blockHeight, maxIndex, txIx, maxTxIx, tx.type, tx.getHash());
}
}
use of neo.model.ScriptVerificationResultEnum in project neo-java by coranos.
the class TestVm method test999Vm.
@Test
public void test999Vm() {
LOG.info("STARTED vm");
final LocalNodeData localNodeData = CONTROLLER.getLocalNodeData();
final BlockDb blockDb = localNodeData.getBlockDb();
final long maxIndex = blockDb.getHeaderOfBlockWithMaxIndex().getIndexAsLong();
long startMs = -1;
for (long blockHeight = 0; blockHeight <= maxIndex; blockHeight++) {
LOG.info("STARTED block {} of {} ", blockHeight, maxIndex);
final Block block = blockDb.getFullBlockFromHeight(blockHeight);
final int maxTxIx = block.getTransactionList().size();
for (int txIx = 0; txIx < maxTxIx; txIx++) {
final Transaction tx = block.getTransactionList().get(txIx);
if (tx.type.equals(TransactionType.ISSUE_TRANSACTION)) {
LOG.info("SKIPPED block {} of {} tx {} of {} : {}", blockHeight, maxIndex, txIx, maxTxIx, tx.getHash());
} else {
LOG.info("STARTED block {} of {} tx {} of {} : {} {}", blockHeight, maxIndex, txIx, maxTxIx, tx.type, tx.getHash());
final ScriptVerificationResultEnum verifyScriptsResult = VerifyScriptUtil.verifyScripts(blockDb, tx);
if (!verifyScriptsResult.equals(ScriptVerificationResultEnum.PASS)) {
LOG.error("FAILURE block {} of {} tx {} of {} : {} {} : {}", blockHeight, maxIndex, txIx, maxTxIx, tx.type, tx.getHash(), verifyScriptsResult);
throw new RuntimeException("script failed : " + tx.type + ":" + verifyScriptsResult);
} else {
LOG.info("SUCCESS block {} of {} tx {} of {} : {} {}", blockHeight, maxIndex, txIx, maxTxIx, tx.type, tx.getHash());
}
}
}
final Timestamp blockTs = block.getTimestamp();
if (startMs < 0) {
startMs = blockTs.getTime();
}
final long ms = blockTs.getTime() - startMs;
if (ms > (86400 * 1000)) {
final String targetDateStr = DATE_FORMAT.format(blockTs);
LOG.info("INTERIM vm {} of {}, date {}", INTEGER_FORMAT.format(blockHeight), INTEGER_FORMAT.format(maxIndex), targetDateStr);
startMs = blockTs.getTime();
}
}
LOG.debug("SUCCESS vm");
}
Aggregations