@ -17,6 +17,8 @@ package org.hyperledger.besu.ethereum.mainnet.precompiles.privacy;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.catchThrowable ;
import static org.assertj.core.api.Assertions.catchThrowable ;
import static org.mockito.ArgumentMatchers.any ;
import static org.mockito.ArgumentMatchers.any ;
import static org.mockito.ArgumentMatchers.anyBoolean ;
import static org.mockito.ArgumentMatchers.eq ;
import static org.mockito.ArgumentMatchers.nullable ;
import static org.mockito.ArgumentMatchers.nullable ;
import static org.mockito.Mockito.mock ;
import static org.mockito.Mockito.mock ;
import static org.mockito.Mockito.when ;
import static org.mockito.Mockito.when ;
@ -26,14 +28,12 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.enclave.Enclave ;
import org.hyperledger.besu.enclave.Enclave ;
import org.hyperledger.besu.enclave.EnclaveFactory ;
import org.hyperledger.besu.enclave.EnclaveFactory ;
import org.hyperledger.besu.enclave.types.SendResponse ;
import org.hyperledger.besu.enclave.types.SendResponse ;
import org.hyperledger.besu.ethereum.chain.Blockchain ;
import org.hyperledger.besu.ethereum.core.Block ;
import org.hyperledger.besu.ethereum.core.Block ;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator ;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator ;
import org.hyperledger.besu.ethereum.core.MutableWorldState ;
import org.hyperledger.besu.ethereum.core.MutableWorldState ;
import org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture ;
import org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture ;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader ;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader ;
import org.hyperledger.besu.ethereum.core.WorldUpdater ;
import org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils ;
import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator ;
import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator ;
import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator ;
import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver ;
import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver ;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction ;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction ;
@ -44,9 +44,11 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult ;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult ;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput ;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput ;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup ;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup ;
import org.hyperledger.besu.ethereum.vm.MessageFrame ;
import org.hyperledger.besu.ethereum.vm.OperationTracer ;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive ;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive ;
import org.hyperledger.besu.evm.frame.MessageFrame ;
import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator ;
import org.hyperledger.besu.evm.tracing.OperationTracer ;
import org.hyperledger.besu.evm.worldstate.WorldUpdater ;
import org.hyperledger.enclave.testutil.EnclaveKeyConfiguration ;
import org.hyperledger.enclave.testutil.EnclaveKeyConfiguration ;
import org.hyperledger.enclave.testutil.OrionTestHarness ;
import org.hyperledger.enclave.testutil.OrionTestHarness ;
import org.hyperledger.enclave.testutil.OrionTestHarnessFactory ;
import org.hyperledger.enclave.testutil.OrionTestHarnessFactory ;
@ -85,7 +87,6 @@ public class PrivacyPrecompiledContractIntegrationTest {
private static Enclave enclave ;
private static Enclave enclave ;
private static MessageFrame messageFrame ;
private static MessageFrame messageFrame ;
private static Blockchain blockchain ;
private static OrionTestHarness testHarness ;
private static OrionTestHarness testHarness ;
private static WorldStateArchive worldStateArchive ;
private static WorldStateArchive worldStateArchive ;
@ -99,7 +100,6 @@ public class PrivacyPrecompiledContractIntegrationTest {
TransactionProcessingResult . successful (
TransactionProcessingResult . successful (
null , 0 , 0 , Bytes . fromHexString ( DEFAULT_OUTPUT ) , null ) ;
null , 0 , 0 , Bytes . fromHexString ( DEFAULT_OUTPUT ) , null ) ;
when ( mockPrivateTransactionProcessor . processTransaction (
when ( mockPrivateTransactionProcessor . processTransaction (
nullable ( Blockchain . class ) ,
nullable ( WorldUpdater . class ) ,
nullable ( WorldUpdater . class ) ,
nullable ( WorldUpdater . class ) ,
nullable ( WorldUpdater . class ) ,
nullable ( ProcessableBlockHeader . class ) ,
nullable ( ProcessableBlockHeader . class ) ,
@ -129,22 +129,23 @@ public class PrivacyPrecompiledContractIntegrationTest {
final EnclaveFactory factory = new EnclaveFactory ( vertx ) ;
final EnclaveFactory factory = new EnclaveFactory ( vertx ) ;
enclave = factory . createVertxEnclave ( testHarness . clientUrl ( ) ) ;
enclave = factory . createVertxEnclave ( testHarness . clientUrl ( ) ) ;
messageFrame = mock ( MessageFrame . class ) ;
messageFrame = mock ( MessageFrame . class ) ;
blockchain = mock ( Blockchain . class ) ;
final BlockDataGenerator blockGenerator = new BlockDataGenerator ( ) ;
final BlockDataGenerator blockGenerator = new BlockDataGenerator ( ) ;
final Block genesis = blockGenerator . genesisBlock ( ) ;
final Block genesis = blockGenerator . genesisBlock ( ) ;
final Block block =
final Block block =
blockGenerator . block (
blockGenerator . block (
new BlockDataGenerator . BlockOptions ( ) . setParentHash ( genesis . getHeader ( ) . getHash ( ) ) ) ;
new BlockDataGenerator . BlockOptions ( ) . setParentHash ( genesis . getHeader ( ) . getHash ( ) ) ) ;
when ( blockchain . getGenesisBlock ( ) ) . thenReturn ( genesis ) ;
when ( messageFrame . getBlockValues ( ) ) . thenReturn ( block . getHeader ( ) ) ;
when ( blockchain . getBlockByHash ( block . getHash ( ) ) ) . thenReturn ( Optional . of ( block ) ) ;
when ( blockchain . getBlockByHash ( genesis . getHash ( ) ) ) . thenReturn ( Optional . of ( genesis ) ) ;
when ( messageFrame . getBlockchain ( ) ) . thenReturn ( blockchain ) ;
when ( messageFrame . getBlockHeader ( ) ) . thenReturn ( block . getHeader ( ) ) ;
final PrivateMetadataUpdater privateMetadataUpdater = mock ( PrivateMetadataUpdater . class ) ;
final PrivateMetadataUpdater privateMetadataUpdater = mock ( PrivateMetadataUpdater . class ) ;
when ( privateMetadataUpdater . getPrivateBlockMetadata ( any ( ) ) ) . thenReturn ( null ) ;
when ( privateMetadataUpdater . getPrivateBlockMetadata ( any ( ) ) ) . thenReturn ( null ) ;
when ( privateMetadataUpdater . getPrivacyGroupHeadBlockMap ( ) )
when ( privateMetadataUpdater . getPrivacyGroupHeadBlockMap ( ) )
. thenReturn ( PrivacyGroupHeadBlockMap . empty ( ) ) ;
. thenReturn ( PrivacyGroupHeadBlockMap . empty ( ) ) ;
when ( messageFrame . getPrivateMetadataUpdater ( ) ) . thenReturn ( privateMetadataUpdater ) ;
when ( messageFrame . getContextVariable (
eq ( PrivateStateUtils . KEY_IS_PERSISTING_PRIVATE_STATE ) , anyBoolean ( ) ) )
. thenReturn ( false ) ;
when ( messageFrame . getContextVariable ( eq ( PrivateStateUtils . KEY_PRIVATE_METADATA_UPDATER ) ) )
. thenReturn ( privateMetadataUpdater ) ;
when ( messageFrame . hasContextVariable ( eq ( PrivateStateUtils . KEY_PRIVATE_METADATA_UPDATER ) ) )
. thenReturn ( true ) ;
worldStateArchive = mock ( WorldStateArchive . class ) ;
worldStateArchive = mock ( WorldStateArchive . class ) ;
final MutableWorldState mutableWorldState = mock ( MutableWorldState . class ) ;
final MutableWorldState mutableWorldState = mock ( MutableWorldState . class ) ;