use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class BlockChainImplInvalidTest method setup.
@Before
public void setup() {
objects = new RskTestContext(new String[0]) {
@Override
protected synchronized RskSystemProperties buildRskSystemProperties() {
RskSystemProperties rskSystemProperties = super.buildRskSystemProperties();
ActivationConfig activationConfigSpy = spy(rskSystemProperties.getActivationConfig());
RskSystemProperties rskSystemPropertiesSpy = spy(rskSystemProperties);
doReturn(true).when(activationConfigSpy).isActive(eq(ConsensusRule.RSKIP126), anyLong());
doReturn(activationConfigSpy).when(rskSystemPropertiesSpy).getActivationConfig();
return rskSystemPropertiesSpy;
}
@Override
protected GenesisLoader buildGenesisLoader() {
return new TestGenesisLoader(getTrieStore(), "rsk-unittests.json", BigInteger.ZERO, true, true, true);
}
@Override
public BlockValidator buildBlockValidator() {
return new BlockValidatorImpl(getBlockStore(), getBlockParentDependantValidationRule(), getBlockValidationRule());
}
};
blockChain = objects.getBlockchain();
}
use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class BlockExecutorTest method validateStateRootWithRskip126DisabledAndValidStateRoot.
@Test
public void validateStateRootWithRskip126DisabledAndValidStateRoot() {
TrieStore trieStore = new TrieStoreImpl(new HashMapDB());
Trie trie = new Trie(trieStore);
Block block = new BlockGenerator().getBlock(1);
block.setStateRoot(trie.getHash().getBytes());
BlockResult blockResult = new BlockResult(block, Collections.emptyList(), Collections.emptyList(), 0, Coin.ZERO, trie);
RskSystemProperties cfg = spy(CONFIG);
ActivationConfig activationConfig = spy(cfg.getActivationConfig());
doReturn(false).when(activationConfig).isActive(eq(RSKIP126), anyLong());
doReturn(activationConfig).when(cfg).getActivationConfig();
BlockExecutor executor = buildBlockExecutor(trieStore, cfg);
Assert.assertTrue(executor.validateStateRoot(block.getHeader(), blockResult));
}
use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class BlockExecutorTest method validateStateRootWithRskip126DisabledAndInvalidStateRoot.
@Test
public void validateStateRootWithRskip126DisabledAndInvalidStateRoot() {
TrieStore trieStore = new TrieStoreImpl(new HashMapDB());
Trie trie = new Trie(trieStore);
Block block = new BlockGenerator().getBlock(1);
block.setStateRoot(new byte[] { 1, 2, 3, 4 });
BlockResult blockResult = new BlockResult(block, Collections.emptyList(), Collections.emptyList(), 0, Coin.ZERO, trie);
RskSystemProperties cfg = spy(CONFIG);
ActivationConfig activationConfig = spy(cfg.getActivationConfig());
doReturn(false).when(activationConfig).isActive(eq(RSKIP126), anyLong());
doReturn(activationConfig).when(cfg).getActivationConfig();
BlockExecutor executor = buildBlockExecutor(trieStore, cfg);
Assert.assertTrue(executor.validateStateRoot(block.getHeader(), blockResult));
}
use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class BridgeTest method registerBtcCoinbaseTransaction_after_RSKIP143_activation.
@Test
public void registerBtcCoinbaseTransaction_after_RSKIP143_activation() throws VMException {
ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
doReturn(true).when(activations).isActive(eq(RSKIP143), anyLong());
BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
Bridge bridge = getBridgeInstance(bridgeSupportMock, activations);
byte[] value = Sha256Hash.ZERO_HASH.getBytes();
Integer zero = new Integer(0);
byte[] data = Bridge.REGISTER_BTC_COINBASE_TRANSACTION.encode(new Object[] { value, zero, value, zero, zero });
bridge.execute(data);
verify(bridgeSupportMock, times(1)).registerBtcCoinbaseTransaction(value, Sha256Hash.wrap(value), value, Sha256Hash.wrap(value), value);
}
use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class BridgeTest method getBridgeInstance.
private Bridge getBridgeInstance(Federation activeFederation, Federation retiringFederation, int senderPK, BridgeSupport bridgeSupportMock) {
doReturn(activeFederation).when(bridgeSupportMock).getActiveFederation();
doReturn(retiringFederation).when(bridgeSupportMock).getRetiringFederation();
ECKey key = ECKey.fromPrivate(BigInteger.valueOf(senderPK));
Transaction rskTxMock = mock(Transaction.class);
doReturn(new RskAddress(key.getAddress())).when(rskTxMock).getSender();
ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
doReturn(true).when(activations).isActive(eq(RSKIP143), anyLong());
return getBridgeInstance(rskTxMock, bridgeSupportMock, activations);
}
Aggregations