Search in sources :

Example 1 with MutableTrieCache

use of co.rsk.db.MutableTrieCache in project rskj by rsksmart.

the class BridgeUtilsTest method isFreeBridgeTx.

private void isFreeBridgeTx(boolean expected, RskAddress destinationAddress, byte[] privKeyBytes) {
    BridgeSupportFactory bridgeSupportFactory = new BridgeSupportFactory(new RepositoryBtcBlockStoreWithCache.Factory(constants.getBridgeConstants().getBtcParams()), constants.getBridgeConstants(), activationConfig);
    Bridge bridge = new Bridge(PrecompiledContracts.BRIDGE_ADDR, constants, activationConfig, bridgeSupportFactory);
    org.ethereum.core.Transaction rskTx = CallTransaction.createCallTransaction(0, 1, 1, destinationAddress, 0, Bridge.UPDATE_COLLECTIONS, constants.getChainId());
    rskTx.sign(privKeyBytes);
    TrieStore trieStore = new TrieStoreImpl(new HashMapDB());
    Repository repository = new MutableRepository(new MutableTrieCache(new MutableTrieImpl(trieStore, new Trie())));
    Block rskExecutionBlock = new BlockGenerator().createChildBlock(getGenesisInstance(trieStore));
    bridge.init(rskTx, rskExecutionBlock, repository.startTracking(), null, null, null);
    Assert.assertEquals(expected, BridgeUtils.isFreeBridgeTx(rskTx, constants, activationConfig.forBlock(rskExecutionBlock.getNumber())));
}
Also used : TrieStoreImpl(co.rsk.trie.TrieStoreImpl) MutableTrieCache(co.rsk.db.MutableTrieCache) HashMapDB(org.ethereum.datasource.HashMapDB) TrieStore(co.rsk.trie.TrieStore) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) MutableRepository(org.ethereum.db.MutableRepository) Block(org.ethereum.core.Block) MutableTrieImpl(co.rsk.db.MutableTrieImpl) Transaction(org.ethereum.core.Transaction) Trie(co.rsk.trie.Trie)

Aggregations

BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)1 MutableTrieCache (co.rsk.db.MutableTrieCache)1 MutableTrieImpl (co.rsk.db.MutableTrieImpl)1 Trie (co.rsk.trie.Trie)1 TrieStore (co.rsk.trie.TrieStore)1 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)1 Block (org.ethereum.core.Block)1 Repository (org.ethereum.core.Repository)1 Transaction (org.ethereum.core.Transaction)1 HashMapDB (org.ethereum.datasource.HashMapDB)1 MutableRepository (org.ethereum.db.MutableRepository)1