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]));
}
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));
}
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);
}
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]));
}
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);
}
Aggregations