Search in sources :

Example 1 with TestProgramInvokeFactory

use of org.ethereum.jsontestsuite.TestProgramInvokeFactory in project rskj by rsksmart.

the class StateTestRunner method runImpl.

public List<String> runImpl() {
    logger.info("");
    repository = RepositoryBuilder.build(stateTestCase.getPre());
    logger.info("loaded repository");
    transaction = TransactionBuilder.build(stateTestCase.getTransaction());
    logger.info("transaction: {}", transaction.toString());
    BlockStore blockStore = new IndexedBlockStore(new HashMap<>(), new HashMapDB(), null);
    blockchain = new BlockChainImpl(config, repository, blockStore, null, null, null, null, null);
    env = EnvBuilder.build(stateTestCase.getEnv());
    invokeFactory = new TestProgramInvokeFactory(env);
    block = BlockBuilder.build(env);
    block.setStateRoot(repository.getRoot());
    block.flushRLP();
    blockchain.setBestBlock(block);
    // blockchain.setProgramInvokeFactory(invokeFactory);
    // blockchain.startTracking();
    ProgramResult programResult = executeTransaction(transaction);
    repository.flushNoReconnect();
    List<LogInfo> origLogs = programResult.getLogInfoList();
    List<LogInfo> postLogs = LogBuilder.build(stateTestCase.getLogs());
    List<String> logsResult = LogsValidator.valid(origLogs, postLogs);
    Repository postRepository = RepositoryBuilder.build(stateTestCase.getPost());
    List<String> repoResults = RepositoryValidator.valid(repository, postRepository, false);
    logger.info("--------- POST Validation---------");
    List<String> outputResults = OutputValidator.valid(Hex.toHexString(programResult.getHReturn()), stateTestCase.getOut());
    List<String> results = new ArrayList<>();
    results.addAll(repoResults);
    results.addAll(logsResult);
    results.addAll(outputResults);
    for (String result : results) {
        logger.error(result);
    }
    logger.info("\n\n");
    return results;
}
Also used : IndexedBlockStore(org.ethereum.db.IndexedBlockStore) BlockStore(org.ethereum.db.BlockStore) LogInfo(org.ethereum.vm.LogInfo) IndexedBlockStore(org.ethereum.db.IndexedBlockStore) BlockChainImpl(co.rsk.core.bc.BlockChainImpl) ProgramResult(org.ethereum.vm.program.ProgramResult) ArrayList(java.util.ArrayList) HashMapDB(org.ethereum.datasource.HashMapDB) TestProgramInvokeFactory(org.ethereum.jsontestsuite.TestProgramInvokeFactory) Repository(org.ethereum.core.Repository)

Aggregations

BlockChainImpl (co.rsk.core.bc.BlockChainImpl)1 ArrayList (java.util.ArrayList)1 Repository (org.ethereum.core.Repository)1 HashMapDB (org.ethereum.datasource.HashMapDB)1 BlockStore (org.ethereum.db.BlockStore)1 IndexedBlockStore (org.ethereum.db.IndexedBlockStore)1 TestProgramInvokeFactory (org.ethereum.jsontestsuite.TestProgramInvokeFactory)1 LogInfo (org.ethereum.vm.LogInfo)1 ProgramResult (org.ethereum.vm.program.ProgramResult)1