use of org.ethereum.util.BuildInfo in project rskj by rsksmart.
the class MainNetMinerTest method submitBitcoinBlockProofOfWorkNotGoodEnough.
/*
* This test is probabilistic, but it has a really high chance to pass. We will generate
* a random block that it is unlikely to pass the Long.MAX_VALUE difficulty, though
* it may happen once. Twice would be suspicious.
*/
@Test
public void submitBitcoinBlockProofOfWorkNotGoodEnough() {
/* We need a low target */
BlockChainBuilder blockChainBuilder = new BlockChainBuilder();
BlockChainImpl blockchain = blockChainBuilder.build();
Genesis gen = (Genesis) BlockChainImplTest.getGenesisBlock(blockChainBuilder.getTrieStore());
gen.getHeader().setDifficulty(new BlockDifficulty(BigInteger.valueOf(Long.MAX_VALUE)));
blockchain.setStatus(gen, gen.getCumulativeDifficulty());
EthereumImpl ethereumImpl = Mockito.mock(EthereumImpl.class);
MinerClock clock = new MinerClock(true, Clock.systemUTC());
MinerServer minerServer = new MinerServerImpl(config, ethereumImpl, mainchainView, null, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), blockToMineBuilder(), clock, blockFactory, new BuildInfo("cb7f28e", "master"), ConfigUtils.getDefaultMiningConfig());
try {
minerServer.start();
MinerWork work = minerServer.getWork();
co.rsk.bitcoinj.core.BtcBlock bitcoinMergedMiningBlock = getMergedMiningBlock(work);
bitcoinMergedMiningBlock.setNonce(2);
SubmitBlockResult result = minerServer.submitBitcoinBlock(work.getBlockHashForMergedMining(), bitcoinMergedMiningBlock);
Assert.assertEquals("ERROR", result.getStatus());
Assert.assertNull(result.getBlockInfo());
Mockito.verify(ethereumImpl, Mockito.times(0)).addNewMinedBlock(Mockito.any());
} finally {
minerServer.stop();
}
}
use of org.ethereum.util.BuildInfo in project rskj by rsksmart.
the class MinerServerTest method extraDataWithClientData.
@Test
public void extraDataWithClientData() {
MinerServer minerServer = new MinerServerImpl(config, null, null, null, null, null, null, null, new BuildInfo("cb7f28e", "master"), ConfigUtils.getDefaultMiningConfig());
minerServer.setExtraData("tincho".getBytes());
byte[] extraData = minerServer.getExtraData();
RLPList decodedExtraData = RLP.decodeList(extraData);
assertEquals(3, decodedExtraData.size());
byte[] firstItem = decodedExtraData.get(0).getRLPData();
assertNotNull(firstItem);
assertEquals(1, (RLP.decodeInt(firstItem, 0)));
byte[] secondItem = decodedExtraData.get(1).getRLPData();
assertNotNull(secondItem);
assertEquals(config.projectVersionModifier().concat("-cb7f28e"), new String(secondItem));
byte[] thirdItem = decodedExtraData.get(2).getRLPData();
assertNotNull(thirdItem);
assertEquals("tincho", new String(thirdItem));
}
Aggregations