use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class PrevMinGasPriceValidatorTest method noParentBlock.
@Test
public void noParentBlock() {
BlockHeader header = Mockito.mock(BlockHeader.class);
Block block = Mockito.mock(Block.class);
Mockito.when(block.getHeader()).thenReturn(header);
Mockito.when(header.getParentHash()).thenReturn(new Keccak256(PARENT_HASH));
Mockito.when(header.getMinimumGasPrice()).thenReturn(BLOCK_MGP);
PrevMinGasPriceRule pmgpv = new PrevMinGasPriceRule();
Assert.assertFalse(pmgpv.isValid(header, null));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class PrevMinGasPriceValidatorTest method validMGPInNewBlock.
@Test
public void validMGPInNewBlock() {
BlockHeader header = Mockito.mock(BlockHeader.class);
Block block = Mockito.mock(Block.class);
Mockito.when(block.getHeader()).thenReturn(header);
Block parent = Mockito.mock(Block.class);
Mockito.when(header.getParentHash()).thenReturn(new Keccak256(PARENT_HASH));
Mockito.when(header.getMinimumGasPrice()).thenReturn(BLOCK_MGP);
Mockito.when(parent.getMinimumGasPrice()).thenReturn(PARENT_BLOCK_MGP);
PrevMinGasPriceRule pmgpv = new PrevMinGasPriceRule();
Assert.assertFalse(pmgpv.isValid(header, parent));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class PrevMinGasPriceValidatorTest method noMinGasPrice.
@Test
public void noMinGasPrice() {
BlockHeader header = Mockito.mock(BlockHeader.class);
Block block = Mockito.mock(Block.class);
Mockito.when(block.getHeader()).thenReturn(header);
Block parent = Mockito.mock(Block.class);
Mockito.when(header.isGenesis()).thenReturn(false);
Mockito.when(header.getMinimumGasPrice()).thenReturn(null);
PrevMinGasPriceRule pmgpv = new PrevMinGasPriceRule();
Assert.assertFalse(pmgpv.isValid(header, parent));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class BlockTimeStampValidationRuleTest method blockInTheFuture.
@Test
public void blockInTheFuture() {
int validPeriod = 540;
BlockTimeStampValidationRule validationRule = new BlockTimeStampValidationRule(validPeriod, preRskip179Config, timeProvider);
when(timeProvider.currentTimeMillis()).thenReturn(10_000_000L);
BlockHeader header = mock(BlockHeader.class);
Block block = mock(Block.class);
when(block.getHeader()).thenReturn(header);
when(header.getTimestamp()).thenReturn(10_000L + 2 * validPeriod);
assertFalse(validationRule.isValid(header));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class BlockTimeStampValidationRuleTest method blockTimeLowerThanParentTime.
@Test
public void blockTimeLowerThanParentTime() {
int validPeriod = 540;
BlockTimeStampValidationRule validationRule = new BlockTimeStampValidationRule(validPeriod, preRskip179Config, timeProvider);
when(timeProvider.currentTimeMillis()).thenReturn(10_000_000L);
BlockHeader header = mock(BlockHeader.class);
Block block = mock(Block.class);
when(block.getHeader()).thenReturn(header);
Block parent = mock(Block.class);
when(header.getTimestamp()).thenReturn(10_000L);
when(parent.getTimestamp()).thenReturn(10_000L + 1000);
assertFalse(validationRule.isValid(header, parent));
}
Aggregations