use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class BridgeTest method receiveHeader_empty_parameter.
@Test
public void receiveHeader_empty_parameter() throws VMException {
ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
doReturn(true).when(activations).isActive(eq(RSKIP200), anyLong());
BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
Bridge bridge = spy(getBridgeInstance(bridgeSupportMock, activations));
byte[] data = Bridge.RECEIVE_HEADER.encode(new Object[] {});
assertNull(bridge.execute(data));
verify(bridge, never()).receiveHeader(any(Object[].class));
verifyZeroInteractions(bridgeSupportMock);
}
use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class BridgeTest method registerBtcTransaction_afterRskip199_acceptsExternalCalls.
@Test
public void registerBtcTransaction_afterRskip199_acceptsExternalCalls() throws VMException, IOException, BlockStoreException {
ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
doReturn(true).when(activations).isActive(eq(RSKIP199), anyLong());
BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
Bridge bridge = getBridgeInstance(bridgeSupportMock, activations);
byte[] value = Sha256Hash.ZERO_HASH.getBytes();
int zero = 0;
byte[] data = Bridge.REGISTER_BTC_TRANSACTION.encode(new Object[] { value, zero, value });
bridge.execute(data);
verify(bridgeSupportMock, times(1)).registerBtcTransaction(any(Transaction.class), any(byte[].class), anyInt(), any(byte[].class));
}
use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class BridgeTest method registerBtcTransaction_beforeRskip199_acceptsCallFromFederationMember.
@Test
public void registerBtcTransaction_beforeRskip199_acceptsCallFromFederationMember() throws VMException, IOException, BlockStoreException {
ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
doReturn(false).when(activations).isActive(eq(RSKIP199), anyLong());
BtcECKey fed1Key = new BtcECKey();
RskAddress fed1Address = new RskAddress(ECKey.fromPublicOnly(fed1Key.getPubKey()).getAddress());
List<BtcECKey> federationKeys = Arrays.asList(fed1Key, new BtcECKey(), new BtcECKey());
federationKeys.sort(BtcECKey.PUBKEY_COMPARATOR);
Federation activeFederation = new Federation(FederationTestUtils.getFederationMembersWithKeys(federationKeys), Instant.ofEpochMilli(1000), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST));
BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
when(bridgeSupportMock.getActiveFederation()).thenReturn(activeFederation);
Transaction rskTx = mock(Transaction.class);
when(rskTx.getSender()).thenReturn(fed1Address);
Bridge bridge = getBridgeInstance(rskTx, bridgeSupportMock, activations);
byte[] value = Sha256Hash.ZERO_HASH.getBytes();
int zero = 0;
byte[] data = Bridge.REGISTER_BTC_TRANSACTION.encode(new Object[] { value, zero, value });
bridge.execute(data);
verify(bridgeSupportMock, times(1)).registerBtcTransaction(any(Transaction.class), any(byte[].class), anyInt(), any(byte[].class));
}
use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class RemascRskAddressActivationTest method testActivation.
@Test
public void testActivation() {
final RskAddress rskLabsAddress = new RskAddress("14d3065c8Eb89895f4df12450EC6b130049F8034");
final RskAddress rskLabsAddressRskip218 = new RskAddress("dcb12179ba4697350f66224c959bdd9c282818df");
final RemascTransaction txMock = mock(RemascTransaction.class);
final Repository repositoryMock = mock(Repository.class);
final BlockStore blockStoreMock = mock(BlockStore.class);
final List<LogInfo> logs = Collections.emptyList();
final ActivationConfig activationConfig = mock(ActivationConfig.class);
final Block blockMock = mock(Block.class);
final RemascConfig remascConfig = spy(new RemascConfigFactory(RemascContract.REMASC_CONFIG).createRemascConfig("regtest"));
final Remasc remasc = new Remasc(Constants.regtest(), activationConfig, repositoryMock, blockStoreMock, remascConfig, txMock, PrecompiledContracts.REMASC_ADDR, blockMock, logs);
when(remascConfig.getRskLabsAddress()).thenReturn(rskLabsAddress);
when(remascConfig.getRskLabsAddressRskip218()).thenReturn(rskLabsAddressRskip218);
when(activationConfig.isActive(ConsensusRule.RSKIP218, 1)).thenReturn(false);
when(activationConfig.isActive(ConsensusRule.RSKIP218, 2)).thenReturn(true);
when(blockMock.getNumber()).thenReturn(1L);
RskAddress actualAddress = remasc.getRskLabsAddress();
Assert.assertEquals(rskLabsAddress, actualAddress);
Assert.assertEquals(blockMock.getNumber(), 1L);
Assert.assertFalse(activationConfig.isActive(ConsensusRule.RSKIP218, blockMock.getNumber()));
verify(remascConfig).getRskLabsAddress();
when(blockMock.getNumber()).thenReturn(2L);
actualAddress = remasc.getRskLabsAddress();
Assert.assertEquals(rskLabsAddressRskip218, actualAddress);
Assert.assertEquals(blockMock.getNumber(), 2L);
Assert.assertTrue(activationConfig.isActive(ConsensusRule.RSKIP218, blockMock.getNumber()));
verify(remascConfig).getRskLabsAddressRskip218();
}
use of org.ethereum.config.blockchain.upgrades.ActivationConfig in project rskj by rsksmart.
the class ProofOfWorkRuleTest method bytesAfterMergedMiningHashAreMoreThan128.
@Test
public void bytesAfterMergedMiningHashAreMoreThan128() {
// This test shows that a Mining Pools can not add more than 2 outputs with 36 bytes each,
// otherwise solutions will not be taken as valid.
RskSystemProperties props = new TestSystemProperties() {
@Override
public ActivationConfig getActivationConfig() {
return ActivationConfigsForTest.all();
}
};
ActivationConfig config = props.getActivationConfig();
Constants networkConstants = props.getNetworkConstants();
BlockGenerator blockGenerator = new BlockGenerator(networkConstants, config);
Block newBlock = blockGenerator.getBlock(1);
// fork detection data is for heights > 449
while (newBlock.getNumber() < 455) newBlock = blockGenerator.createChildBlock(newBlock);
String output1 = "6a24b9e11b6de9aa87561948d72e494fed2fb56bf8fd4193425f9350037f34dec5b13be7";
String output2 = "aa21a9ed90a5e7d6d8093d20aa54fb01f57da374e016d4a01ddec0210088675e5e3fee4e";
String output3 = "1111a9ed90a5e7d6d8093d20aa54fb01f57da374e016d4a01ddec0210088675e5e3fee4e";
byte[] mergedMiningLink = org.bouncycastle.util.Arrays.concatenate(RskMiningConstants.RSK_TAG, newBlock.getHashForMergedMining());
co.rsk.bitcoinj.core.NetworkParameters params = co.rsk.bitcoinj.params.RegTestParams.get();
co.rsk.bitcoinj.core.BtcTransaction coinbaseTransaction = MinerUtils.getBitcoinCoinbaseTransaction(params, mergedMiningLink);
coinbaseTransaction.addOutput(new co.rsk.bitcoinj.core.TransactionOutput(params, coinbaseTransaction, co.rsk.bitcoinj.core.Coin.valueOf(0), Hex.decode(output1)));
coinbaseTransaction.addOutput(new co.rsk.bitcoinj.core.TransactionOutput(params, coinbaseTransaction, co.rsk.bitcoinj.core.Coin.valueOf(0), Hex.decode(output2)));
coinbaseTransaction.addOutput(new co.rsk.bitcoinj.core.TransactionOutput(params, coinbaseTransaction, co.rsk.bitcoinj.core.Coin.valueOf(0), Hex.decode(output3)));
Block block = new BlockMiner(config).mineBlock(newBlock, coinbaseTransaction);
ProofOfWorkRule rule = new ProofOfWorkRule(props);
assertFalse(rule.isValid(block));
}
Aggregations