Skip to content

Commit

Permalink
Accept PR suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <[email protected]>
  • Loading branch information
Gabriel-Trintinalia committed Dec 17, 2024
1 parent cc0bcca commit 6c6276f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class BlockSimulatorServiceImpl implements BlockSimulationService {
* @param miningConfiguration the mining configuration
* @param transactionSimulator the transaction simulator
* @param protocolSchedule the protocol schedule
* @param blockchain the blockchain
*/
public BlockSimulatorServiceImpl(
final WorldStateArchive worldStateArchive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,39 +196,41 @@ public void shouldApplyStateOverridesCorrectly() {

@Test
public void shouldApplyBlockHeaderOverridesCorrectly() {
BlockOverrides blockOverrides = mock(BlockOverrides.class);
ProtocolSpec protocolSpec = mock(ProtocolSpec.class);

var expectedTimestamp = Optional.of(1L);
var expectedBlockNumber = Optional.of(2L);
var expectedFeeRecipient = Optional.of(Address.fromHexString("0x1"));
var expectedBaseFeePerGas = Optional.of(Wei.of(7L));
var expectedGasLimit = Optional.of(5L);
var expectedDifficulty = Optional.of(BigInteger.ONE);
var expectedMixHashOrPrevRandao = Optional.of(Hash.hash(Bytes.fromHexString("0x01")));
var expectedExtraData = Optional.of(Bytes.fromHexString("0x02"));

when(blockOverrides.getTimestamp()).thenReturn(expectedTimestamp);
when(blockOverrides.getBlockNumber()).thenReturn(expectedBlockNumber);
when(blockOverrides.getFeeRecipient()).thenReturn(expectedFeeRecipient);
when(blockOverrides.getBaseFeePerGas()).thenReturn(expectedBaseFeePerGas);
when(blockOverrides.getGasLimit()).thenReturn(expectedGasLimit);
when(blockOverrides.getDifficulty()).thenReturn(expectedDifficulty);
when(blockOverrides.getMixHashOrPrevRandao()).thenReturn(expectedMixHashOrPrevRandao);
when(blockOverrides.getExtraData()).thenReturn(expectedExtraData);
var expectedTimestamp = 1L;
var expectedBlockNumber = 2L;
var expectedFeeRecipient = Address.fromHexString("0x1");
var expectedBaseFeePerGas = Wei.of(7L);
var expectedGasLimit = 5L;
var expectedDifficulty = BigInteger.ONE;
var expectedMixHashOrPrevRandao = Hash.hash(Bytes.fromHexString("0x01"));
var expectedExtraData = Bytes.fromHexString("0x02");

BlockOverrides blockOverrides =
BlockOverrides.builder()
.timestamp(expectedTimestamp)
.blockNumber(expectedBlockNumber)
.feeRecipient(expectedFeeRecipient)
.baseFeePerGas(expectedBaseFeePerGas)
.gasLimit(expectedGasLimit)
.difficulty(expectedDifficulty)
.mixHashOrPrevRandao(expectedMixHashOrPrevRandao)
.extraData(expectedExtraData)
.build();

BlockHeader result =
blockSimulator.applyBlockHeaderOverrides(blockHeader, protocolSpec, blockOverrides);

assertNotNull(result);
assertEquals(expectedTimestamp.get(), result.getTimestamp());
assertEquals(expectedBlockNumber.get(), result.getNumber());
assertEquals(expectedFeeRecipient.get(), result.getCoinbase());
assertEquals(expectedBaseFeePerGas, result.getBaseFee());
assertEquals(expectedGasLimit.get(), result.getGasLimit());
assertThat(result.getDifficulty()).isEqualTo(Difficulty.of(expectedDifficulty.get()));
assertEquals(expectedMixHashOrPrevRandao.get(), result.getMixHash());
assertEquals(expectedExtraData.get(), result.getExtraData());
assertEquals(expectedTimestamp, result.getTimestamp());
assertEquals(expectedBlockNumber, result.getNumber());
assertEquals(expectedFeeRecipient, result.getCoinbase());
assertEquals(Optional.of(expectedBaseFeePerGas), result.getBaseFee());
assertEquals(expectedGasLimit, result.getGasLimit());
assertThat(result.getDifficulty()).isEqualTo(Difficulty.of(expectedDifficulty));
assertEquals(expectedMixHashOrPrevRandao, result.getMixHash());
assertEquals(expectedExtraData, result.getExtraData());
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files
knownHash = 'np8ChmBg/Fc8DiWlTn5PgRJbnuHtjbJGNIfaQgXv/tM='
knownHash = '+YR9PYN+gPCvXzK2w52ypz9dZ0FOy0G3I1PljZasOkU='
}
check.dependsOn('checkAPIChanges')

Expand Down

0 comments on commit 6c6276f

Please sign in to comment.