use of org.hyperledger.besu.evm.frame.BlockValues in project hedera-services by hashgraph.
the class CallEvmTxProcessorTest method assertTransactionSenderAndValue.
@Test
void assertTransactionSenderAndValue() {
// setup:
doReturn(Optional.of(receiver.getId().asEvmAddress())).when(transaction).getTo();
given(worldState.updater()).willReturn(mock(HederaWorldState.Updater.class));
given(codeCache.getIfPresent(any())).willReturn(new Code());
given(transaction.getSender()).willReturn(sender.getId().asEvmAddress());
given(transaction.getValue()).willReturn(Wei.of(1L));
final MessageFrame.Builder commonInitialFrame = MessageFrame.builder().messageFrameStack(mock(Deque.class)).maxStackSize(MAX_STACK_SIZE).worldUpdater(mock(WorldUpdater.class)).initialGas(mock(Gas.class)).originator(sender.getId().asEvmAddress()).gasPrice(mock(Wei.class)).sender(sender.getId().asEvmAddress()).value(Wei.of(transaction.getValue().getAsBigInteger())).apparentValue(Wei.of(transaction.getValue().getAsBigInteger())).blockValues(mock(BlockValues.class)).depth(0).completer(__ -> {
}).miningBeneficiary(mock(Address.class)).blockHashLookup(h -> null);
// when:
MessageFrame buildMessageFrame = callEvmTxProcessor.buildInitialFrame(commonInitialFrame, worldState.updater(), (Address) transaction.getTo().get(), Bytes.EMPTY);
// expect:
assertEquals(transaction.getSender(), buildMessageFrame.getSenderAddress());
assertEquals(transaction.getValue(), buildMessageFrame.getApparentValue());
}
use of org.hyperledger.besu.evm.frame.BlockValues in project hedera-services by hashgraph.
the class CreateEvmTxProcessorTest method assertTransactionSenderAndValue.
@Test
void assertTransactionSenderAndValue() {
// setup:
doReturn(Optional.of(receiver.getId().asEvmAddress())).when(transaction).getTo();
given(transaction.getSender()).willReturn(sender.getId().asEvmAddress());
given(transaction.getValue()).willReturn(Wei.of(1L));
final MessageFrame.Builder commonInitialFrame = MessageFrame.builder().messageFrameStack(mock(Deque.class)).maxStackSize(MAX_STACK_SIZE).worldUpdater(mock(WorldUpdater.class)).initialGas(mock(Gas.class)).originator(sender.getId().asEvmAddress()).gasPrice(mock(Wei.class)).sender(sender.getId().asEvmAddress()).value(Wei.of(transaction.getValue().getAsBigInteger())).apparentValue(Wei.of(transaction.getValue().getAsBigInteger())).blockValues(mock(BlockValues.class)).depth(0).completer(__ -> {
}).miningBeneficiary(mock(Address.class)).blockHashLookup(h -> null);
// when:
MessageFrame buildMessageFrame = createEvmTxProcessor.buildInitialFrame(commonInitialFrame, worldState.updater(), (Address) transaction.getTo().get(), Bytes.EMPTY);
// expect:
assertEquals(transaction.getSender(), buildMessageFrame.getSenderAddress());
assertEquals(transaction.getValue(), buildMessageFrame.getApparentValue());
}
use of org.hyperledger.besu.evm.frame.BlockValues in project besu by hyperledger.
the class PrevRanDaoOperationTest method pushesPrevRandaoWhenDifficultyZero.
@Test
public void pushesPrevRandaoWhenDifficultyZero() {
PrevRanDaoOperation op = new PrevRanDaoOperation(new LondonGasCalculator());
MessageFrame messageFrame = mock(MessageFrame.class);
BlockValues blockHeader = mock(BlockValues.class);
Bytes32 prevRandao = Bytes32.fromHexString("0xb0b0face");
when(blockHeader.getDifficultyBytes()).thenReturn(UInt256.ZERO);
when(blockHeader.getMixHashOrPrevRandao()).thenReturn(prevRandao);
when(messageFrame.getBlockValues()).thenReturn(blockHeader);
EVM evm = mock(EVM.class);
Operation.OperationResult r = op.executeFixedCostOperation(messageFrame, evm);
assertThat(r.getHaltReason()).isNotPresent();
verify(messageFrame).pushStackItem(prevRandao);
}
use of org.hyperledger.besu.evm.frame.BlockValues in project besu by hyperledger.
the class PrivacyPrecompiledContract method isMining.
boolean isMining(final MessageFrame messageFrame) {
boolean isMining = false;
final BlockValues currentBlockHeader = messageFrame.getBlockValues();
if (!BlockHeader.class.isAssignableFrom(currentBlockHeader.getClass())) {
if (messageFrame.getContextVariable(KEY_IS_PERSISTING_PRIVATE_STATE, false)) {
throw new IllegalArgumentException("The MessageFrame contains an illegal block header type. Cannot persist private block" + " metadata without current block hash.");
} else {
isMining = true;
}
}
return isMining;
}
use of org.hyperledger.besu.evm.frame.BlockValues in project besu by hyperledger.
the class PrevRanDaoOperationTest method pushesDifficultyWhenPresent.
@Test
public void pushesDifficultyWhenPresent() {
PrevRanDaoOperation op = new PrevRanDaoOperation(new LondonGasCalculator());
MessageFrame messageFrame = mock(MessageFrame.class);
BlockValues blockHeader = mock(BlockValues.class);
Bytes32 prevRandao = Bytes32.fromHexString("0xb0b0face");
Bytes difficulty = Bytes.random(32);
when(blockHeader.getDifficultyBytes()).thenReturn(difficulty);
when(blockHeader.getMixHashOrPrevRandao()).thenReturn(prevRandao);
when(messageFrame.getBlockValues()).thenReturn(blockHeader);
EVM evm = mock(EVM.class);
Operation.OperationResult r = op.executeFixedCostOperation(messageFrame, evm);
assertThat(r.getHaltReason()).isNotPresent();
verify(messageFrame).pushStackItem(difficulty);
}
Aggregations