use of org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture in project besu by hyperledger.
the class SStoreOperationTest method createMessageFrame.
private MessageFrame createMessageFrame(final Address address, final Gas initialGas, final Gas remainingGas) {
final Blockchain blockchain = mock(Blockchain.class);
final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
final WorldUpdater worldStateUpdater = worldStateArchive.getMutable().updater();
final BlockHeader blockHeader = new BlockHeaderTestFixture().buildHeader();
final MessageFrame frame = new MessageFrameTestFixture().address(address).worldUpdater(worldStateUpdater).blockHeader(blockHeader).blockchain(blockchain).initialGas(initialGas).build();
worldStateUpdater.getOrCreate(address).getMutable().setBalance(Wei.of(1));
worldStateUpdater.commit();
frame.setGasRemaining(remainingGas);
return frame;
}
use of org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture in project besu by hyperledger.
the class PkiQbftBlockCreatorTest method before.
@Before
public void before() {
blockCreator = mock(BlockCreator.class);
cmsCreator = mock(CmsCreator.class);
pkiQbftBlockCreator = new PkiQbftBlockCreator(blockCreator, cmsCreator, extraDataCodec);
blockHeaderBuilder = new BlockHeaderTestFixture();
}
use of org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture in project besu by hyperledger.
the class QbftGetSignerMetricsTest method generateBlock.
private SignerMetricResult generateBlock(final long number) {
final Address proposerAddressBlock = VALIDATORS[(int) (number % VALIDATORS.length)];
final BlockHeader header = new BlockHeaderTestFixture().number(number).buildHeader();
when(blockchainQueries.getBlockHeaderByNumber(number)).thenReturn(Optional.of(header));
when(blockInterface.getProposerOfBlock(header)).thenReturn(proposerAddressBlock);
when(validatorProvider.getValidatorsAfterBlock(header)).thenReturn(Arrays.asList(VALIDATORS));
final SignerMetricResult signerMetricResult = new SignerMetricResult(proposerAddressBlock);
signerMetricResult.incrementeNbBlock();
signerMetricResult.setLastProposedBlockNumber(number);
return signerMetricResult;
}
use of org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture in project besu by hyperledger.
the class QbftBlockHeaderUtils method createPresetHeaderBuilder.
public static BlockHeaderTestFixture createPresetHeaderBuilder(final long number, final NodeKey proposerNodeKey, final List<Address> validators, final BlockHeader parent, final HeaderModifier modifier, final Optional<Wei> baseFee) {
final BlockHeaderTestFixture builder = new BlockHeaderTestFixture();
final QbftExtraDataCodec qbftExtraDataEncoder = new QbftExtraDataCodec();
populateDefaultBlockHeader(number, proposerNodeKey, parent, modifier, builder, qbftExtraDataEncoder, baseFee);
final BftExtraData bftExtraData = BftExtraDataFixture.createExtraData(builder.buildHeader(), Bytes.wrap(new byte[BftExtraDataCodec.EXTRA_VANITY_LENGTH]), Optional.of(Vote.authVote(Address.fromHexString("1"))), validators, singletonList(proposerNodeKey), ROUND_NUMBER, qbftExtraDataEncoder);
builder.extraData(qbftExtraDataEncoder.encode(bftExtraData));
return builder;
}
use of org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture in project besu by hyperledger.
the class AncestryValidationRuleTest method incrementingNumberAndLinkedHashesReturnTrue.
@Test
public void incrementingNumberAndLinkedHashesReturnTrue() {
final AncestryValidationRule uut = new AncestryValidationRule();
final BlockHeader parentHeader = new BlockHeaderTestFixture().buildHeader();
final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture();
headerBuilder.parentHash(parentHeader.getHash());
headerBuilder.number(parentHeader.getNumber() + 1);
final BlockHeader header = headerBuilder.buildHeader();
assertThat(uut.validate(header, parentHeader)).isTrue();
}
Aggregations