Search in sources :

Example 21 with ActivationConfig

use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.

the class BridgeTest method getBtcBlockchainBestChainHeightOnlyAllowsLocalCalls_afterRskip220.

@Test
public void getBtcBlockchainBestChainHeightOnlyAllowsLocalCalls_afterRskip220() {
    ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
    doReturn(true).when(activations).isActive(eq(RSKIP220), anyLong());
    Bridge bridge = getBridgeInstance(mock(BridgeSupport.class), activations);
    assertFalse(bridge.getBtcBlockchainBestChainHeightOnlyAllowsLocalCalls(new Object[0]));
}
Also used : ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 22 with ActivationConfig

use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.

the class BridgeTest method receiveHeader_before_RSKIP200.

@Test
public void receiveHeader_before_RSKIP200() throws VMException {
    ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
    doReturn(false).when(activations).isActive(eq(RSKIP200), anyLong());
    BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
    Bridge bridge = spy(getBridgeInstance(bridgeSupportMock, activations));
    NetworkParameters networkParameters = constants.bridgeConstants.getBtcParams();
    co.rsk.bitcoinj.core.BtcBlock block = new co.rsk.bitcoinj.core.BtcBlock(networkParameters, 1, PegTestUtils.createHash(1), PegTestUtils.createHash(1), 1, Utils.encodeCompactBits(networkParameters.getMaxTarget()), 1, new ArrayList<>()).cloneAsHeader();
    Object[] parameters = new Object[] { block.bitcoinSerialize() };
    byte[] data = Bridge.RECEIVE_HEADER.encode(parameters);
    bridge.execute(data);
    assertNull(bridge.execute(data));
    verify(bridge, never()).receiveHeader(any(Object[].class));
}
Also used : co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) NetworkParameters(co.rsk.bitcoinj.core.NetworkParameters) ArrayList(java.util.ArrayList) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 23 with ActivationConfig

use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.

the class BridgeTest method receiveHeader_bridgeSupport_Exception.

@Test(expected = VMException.class)
public void receiveHeader_bridgeSupport_Exception() throws VMException, IOException, BlockStoreException {
    ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
    doReturn(true).when(activations).isActive(eq(RSKIP200), anyLong());
    BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
    doThrow(new IOException()).when(bridgeSupportMock).receiveHeader(any());
    Bridge bridge = getBridgeInstance(bridgeSupportMock, activations);
    NetworkParameters networkParameters = constants.bridgeConstants.getBtcParams();
    co.rsk.bitcoinj.core.BtcBlock block = new co.rsk.bitcoinj.core.BtcBlock(networkParameters, 1, PegTestUtils.createHash(1), PegTestUtils.createHash(1), 1, Utils.encodeCompactBits(networkParameters.getMaxTarget()), 1, new ArrayList<>()).cloneAsHeader();
    Object[] parameters = new Object[] { block.bitcoinSerialize() };
    byte[] data = Bridge.RECEIVE_HEADER.encode(parameters);
    bridge.execute(data);
}
Also used : co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) NetworkParameters(co.rsk.bitcoinj.core.NetworkParameters) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 24 with ActivationConfig

use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.

the class BridgeTest method getBtcBlockchainBestChainHeightOnlyAllowsLocalCalls_beforeRskip220.

@Test
public void getBtcBlockchainBestChainHeightOnlyAllowsLocalCalls_beforeRskip220() {
    ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
    doReturn(false).when(activations).isActive(eq(RSKIP220), anyLong());
    Bridge bridge = getBridgeInstance(mock(BridgeSupport.class), activations);
    assertTrue(bridge.getBtcBlockchainBestChainHeightOnlyAllowsLocalCalls(new Object[0]));
}
Also used : ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 25 with ActivationConfig

use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.

the class BridgeTest method registerBtcCoinbaseTransaction_after_RSKIP143_activation_null_data.

@Test
public void registerBtcCoinbaseTransaction_after_RSKIP143_activation_null_data() 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[] data = Bridge.REGISTER_BTC_COINBASE_TRANSACTION.encodeSignature();
    byte[] result = bridge.execute(data);
    assertNull(result);
    data = ByteUtil.merge(Bridge.REGISTER_BTC_COINBASE_TRANSACTION.encodeSignature(), Hex.decode("ab"));
    result = bridge.execute(data);
    assertNull(result);
    data = ByteUtil.merge(Bridge.REGISTER_BTC_COINBASE_TRANSACTION.encodeSignature(), Hex.decode("0000000000000000000000000000000000000000000000080000000000000000"));
    result = bridge.execute(data);
    assertNull(result);
}
Also used : ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Aggregations

ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)30 Test (org.junit.Test)25 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)19 RskAddress (co.rsk.core.RskAddress)9 RskSystemProperties (co.rsk.config.RskSystemProperties)8 Before (org.junit.Before)8 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)7 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)6 Keccak256 (co.rsk.crypto.Keccak256)5 Trie (co.rsk.trie.Trie)5 TrieStore (co.rsk.trie.TrieStore)5 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)5 BigInteger (java.math.BigInteger)5 Constants (org.ethereum.config.Constants)5 BlockStoreException (co.rsk.bitcoinj.store.BlockStoreException)4 TestSystemProperties (co.rsk.config.TestSystemProperties)4 IOException (java.io.IOException)4 CallTransaction (org.ethereum.core.CallTransaction)4 Transaction (org.ethereum.core.Transaction)4 EVMAssembler (co.rsk.asm.EVMAssembler)3