@Test
public void forkTest() {

    // check that TransactionInfo is always returned from the main chain for
    // transaction which included into blocks from different forks
    String contractSrc =
            "contract Adder {" +
            "  int public lastResult;" +
            "  function add(int a, int b) returns (int) {lastResult = a + b; return lastResult; }" +
            "}";
    HashMapDB txDb = new HashMapDB();
    StandaloneBlockchain bc = new StandaloneBlockchain();
    TransactionStore transactionStore = new TransactionStore(txDb);
    bc.getBlockchain().withTransactionStore(transactionStore);
    SolidityContract contract = bc.submitNewContract(contractSrc);
    Block b1 = bc.createBlock();
    contract.callFunction("add", 555, 222);
    Block b2 = bc.createBlock();
    Transaction tx1 = b2.getTransactionsList().get(0);
    TransactionInfo txInfo = bc.getBlockchain().getTransactionInfo(tx1.getHash());
    Assert.assertTrue(Arrays.equals(txInfo.getBlockHash(), b2.getHash()));
    Block b2_ = bc.createForkBlock(b1);
    contract.callFunction("add", 555, 222); // tx with the same hash as before
    Block b3_ = bc.createForkBlock(b2_);
    TransactionInfo txInfo_ = bc.getBlockchain().getTransactionInfo(tx1.getHash());
    Assert.assertTrue(Arrays.equals(txInfo_.getBlockHash(), b3_.getHash()));
    Block b3 = bc.createForkBlock(b2);
    Block b4 = bc.createForkBlock(b3);
    txInfo = bc.getBlockchain().getTransactionInfo(tx1.getHash());
    Assert.assertTrue(Arrays.equals(txInfo.getBlockHash(), b2.getHash()));
}