use of org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain in project besu by hyperledger.
the class GoQuorumBlockProcessorTest method noAccountCreatedWhenBlockRewardIsZeroAndSkipped.
@Test
public void noAccountCreatedWhenBlockRewardIsZeroAndSkipped() {
final Blockchain blockchain = new ReferenceTestBlockchain();
final GoQuorumBlockProcessor blockProcessor = new GoQuorumBlockProcessor(transactionProcessor, transactionReceiptFactory, Wei.ZERO, BlockHeader::getCoinbase, true, Optional.of(goQuorumPrivacyParameters));
final MutableWorldState worldState = ReferenceTestWorldState.create(emptyMap());
final Hash initialHash = worldState.rootHash();
final BlockHeader emptyBlockHeader = new BlockHeaderTestFixture().transactionsRoot(Hash.EMPTY_LIST_HASH).ommersHash(Hash.EMPTY_LIST_HASH).buildHeader();
blockProcessor.processBlock(blockchain, worldState, emptyBlockHeader, emptyList(), emptyList());
// An empty block with 0 reward should not change the world state
assertThat(worldState.rootHash()).isEqualTo(initialHash);
}
use of org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain in project besu by hyperledger.
the class GoQuorumBlockProcessorTest method accountCreatedWhenBlockRewardIsZeroAndNotSkipped.
@Test
public void accountCreatedWhenBlockRewardIsZeroAndNotSkipped() {
final Blockchain blockchain = new ReferenceTestBlockchain();
final GoQuorumBlockProcessor blockProcessor = new GoQuorumBlockProcessor(transactionProcessor, transactionReceiptFactory, Wei.ZERO, BlockHeader::getCoinbase, false, Optional.of(goQuorumPrivacyParameters));
final MutableWorldState worldState = ReferenceTestWorldState.create(emptyMap());
final Hash initialHash = worldState.rootHash();
final BlockHeader emptyBlockHeader = new BlockHeaderTestFixture().transactionsRoot(Hash.EMPTY_LIST_HASH).ommersHash(Hash.EMPTY_LIST_HASH).buildHeader();
blockProcessor.processBlock(blockchain, worldState, emptyBlockHeader, emptyList(), emptyList());
// An empty block with 0 reward should change the world state prior to EIP158
assertThat(worldState.rootHash()).isNotEqualTo(initialHash);
}
use of org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain in project besu by hyperledger.
the class MainnetBlockProcessorTest method accountCreatedWhenBlockRewardIsZeroAndNotSkipped.
@Test
public void accountCreatedWhenBlockRewardIsZeroAndNotSkipped() {
final Blockchain blockchain = new ReferenceTestBlockchain();
final MainnetBlockProcessor blockProcessor = new MainnetBlockProcessor(transactionProcessor, transactionReceiptFactory, Wei.ZERO, BlockHeader::getCoinbase, false, Optional.empty());
final MutableWorldState worldState = ReferenceTestWorldState.create(emptyMap());
final Hash initialHash = worldState.rootHash();
final BlockHeader emptyBlockHeader = new BlockHeaderTestFixture().transactionsRoot(Hash.EMPTY_LIST_HASH).ommersHash(Hash.EMPTY_LIST_HASH).buildHeader();
blockProcessor.processBlock(blockchain, worldState, emptyBlockHeader, emptyList(), emptyList());
// An empty block with 0 reward should change the world state prior to EIP158
assertThat(worldState.rootHash()).isNotEqualTo(initialHash);
}
use of org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain in project besu by hyperledger.
the class DebugOperationTracerTest method validMessageFrameBuilder.
private MessageFrameTestFixture validMessageFrameBuilder() {
final BlockHeader blockHeader = new BlockHeaderTestFixture().number(1).buildHeader();
final ReferenceTestBlockchain blockchain = new ReferenceTestBlockchain(blockHeader.getNumber());
return new MessageFrameTestFixture().initialGas(INITIAL_GAS).worldUpdater(worldUpdater).gasPrice(Wei.of(25)).blockHeader(blockHeader).blockchain(blockchain).depth(DEPTH);
}
use of org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain in project besu by hyperledger.
the class GoQuorumBlockProcessorTest method enclaveNotAvailable.
@Test
public void enclaveNotAvailable() {
final Blockchain blockchain = new ReferenceTestBlockchain();
final GoQuorumBlockProcessor blockProcessor = new GoQuorumBlockProcessor(transactionProcessor, transactionReceiptFactory, Wei.ZERO, BlockHeader::getCoinbase, false, Optional.of(goQuorumPrivacyParameters));
final MutableWorldState worldState = ReferenceTestWorldState.create(emptyMap());
final Block block = mock(Block.class);
final BlockHeader blockHeader = mock(BlockHeader.class);
final BlockBody blockBody = mock(BlockBody.class);
final Transaction transaction = mock(Transaction.class);
when(transaction.getGasLimit()).thenReturn(1000L);
when(transaction.isGoQuorumPrivateTransaction(true)).thenReturn(true);
when(transaction.getPayload()).thenReturn(Bytes.wrap(new byte[] { (byte) 1 }));
when(block.getBody()).thenReturn(blockBody);
when(blockBody.getTransactions()).thenReturn(Collections.singletonList(transaction));
when(blockBody.getOmmers()).thenReturn(Collections.emptyList());
when(blockHeader.getNumber()).thenReturn(20000L);
when(blockHeader.getGasLimit()).thenReturn(20000L);
when(block.getHeader()).thenReturn(blockHeader);
when(goQuorumEnclave.receive(any())).thenThrow(new EnclaveServerException(1, "a"));
when(transactionProcessor.getTransactionValidator()).thenReturn(transactionValidator);
when(transactionValidator.getGoQuorumCompatibilityMode()).thenReturn(true);
assertThatThrownBy(() -> blockProcessor.processBlock(blockchain, worldState, worldState, block)).isExactlyInstanceOf(EnclaveServerException.class).hasMessageContaining("a");
}
Aggregations