use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class BlockStoreTest method saveHeader.
@Test
public void saveHeader() {
BlockStore store = new BlockStore();
BlockHeader blockHeader = new BlockHeader(new byte[] {}, new byte[] {}, RskAddress.nullAddress().getBytes(), new Bloom().getData(), new byte[] {}, 1, new byte[] {}, 0, 0, new byte[] {}, new byte[] {}, new byte[] {}, new byte[] {}, new byte[] {}, 0);
store.saveHeader(blockHeader);
Assert.assertTrue(store.hasHeader(blockHeader.getHash()));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class ExtraDataRuleTests method blockWithValidLongerExtraDataThanAccepted.
@Test
public void blockWithValidLongerExtraDataThanAccepted() {
BlockHeader blockHeader = Mockito.mock(BlockHeader.class);
Mockito.when(blockHeader.getExtraData()).thenReturn(new byte[43]);
Block block = new Block(blockHeader);
ExtraDataRule rule = new ExtraDataRule(42);
Assert.assertFalse(rule.isValid(block));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class ExtraDataRuleTests method blockWithValidExtraData.
@Test
public void blockWithValidExtraData() {
BlockHeader blockHeader = Mockito.mock(BlockHeader.class);
Mockito.when(blockHeader.getExtraData()).thenReturn(new byte[32]);
Block block = new Block(blockHeader);
ExtraDataRule rule = new ExtraDataRule(42);
Assert.assertTrue(rule.isValid(block));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class GasLimitRuleTests method getBlock.
private static Block getBlock(long gasLimitValue) {
byte[] gasLimit = new DataWord(gasLimitValue).getData();
BlockHeader header = new BlockHeader(null, null, RskAddress.nullAddress().getBytes(), null, BlockDifficulty.ZERO.getBytes(), 0, gasLimit, 0, 0, null, null, 0);
return new Block(header);
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class LocalBasicTest method runDifficultyTest.
@Test
public void runDifficultyTest() throws IOException, ParseException {
config.setGenesisInfo("frontier.json");
config.setBlockchainConfig(new MainNetConfig());
String json = getJSON("difficulty");
DifficultyTestSuite testSuite = new DifficultyTestSuite(json);
for (DifficultyTestCase testCase : testSuite.getTestCases()) {
logger.info("Running {}\n", testCase.getName());
BlockHeader current = testCase.getCurrent();
BlockHeader parent = testCase.getParent();
BlockDifficulty calc = new DifficultyCalculator(config).calcDifficulty(current, parent);
int c = calc.compareTo(parent.getDifficulty());
if (c > 0)
logger.info(" Difficulty increase test\n");
else if (c < 0)
logger.info(" Difficulty decrease test\n");
else
logger.info(" Difficulty without change test\n");
assertEquals(testCase.getExpectedDifficulty(), calc);
}
}
Aggregations