Search in sources :

Example 1 with EnclaveKeyConfiguration

use of org.hyperledger.enclave.testutil.EnclaveKeyConfiguration in project besu by hyperledger.

the class PluginPrivacySigningAcceptanceTest method setup.

@Before
public void setup() throws IOException {
    minerNode = privacyBesu.create(new PrivacyNodeConfiguration(false, false, true, new BesuNodeConfigurationBuilder().name("miner").miningEnabled().jsonRpcEnabled().webSocketEnabled().enablePrivateTransactions().keyFilePath(BOB.getPrivateKeyPath()).plugins(Collections.singletonList("testPlugins")).extraCLIOptions(List.of("--plugin-privacy-service-encryption-prefix=0xAA", "--plugin-privacy-service-signing-enabled=true", "--plugin-privacy-service-signing-key=8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63")).build(), new EnclaveKeyConfiguration(BOB.getEnclaveKeyPaths(), BOB.getEnclavePrivateKeyPaths())), EnclaveType.NOOP, Optional.empty());
    privacyCluster.start(minerNode);
}
Also used : EnclaveKeyConfiguration(org.hyperledger.enclave.testutil.EnclaveKeyConfiguration) BesuNodeConfigurationBuilder(org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder) PrivacyNodeConfiguration(org.hyperledger.besu.tests.acceptance.dsl.node.configuration.privacy.PrivacyNodeConfiguration) Before(org.junit.Before)

Example 2 with EnclaveKeyConfiguration

use of org.hyperledger.enclave.testutil.EnclaveKeyConfiguration in project besu by hyperledger.

the class PrivacyPrecompiledContractIntegrationTest method setUpOnce.

@BeforeAll
public static void setUpOnce() throws Exception {
    testHarness = TesseraTestHarnessFactory.create("enclave", Files.createTempDirectory(folder, "enclave"), new EnclaveKeyConfiguration("enclave_key_0.pub", "enclave_key_1.key"), Optional.empty());
    testHarness.start();
    final EnclaveFactory factory = new EnclaveFactory(vertx);
    enclave = factory.createVertxEnclave(testHarness.clientUrl());
    messageFrame = mock(MessageFrame.class);
    final BlockDataGenerator blockGenerator = new BlockDataGenerator();
    final Block genesis = blockGenerator.genesisBlock();
    final Block block = blockGenerator.block(new BlockDataGenerator.BlockOptions().setParentHash(genesis.getHeader().getHash()));
    when(messageFrame.getBlockValues()).thenReturn(block.getHeader());
    final PrivateMetadataUpdater privateMetadataUpdater = mock(PrivateMetadataUpdater.class);
    when(privateMetadataUpdater.getPrivateBlockMetadata(any())).thenReturn(null);
    when(privateMetadataUpdater.getPrivacyGroupHeadBlockMap()).thenReturn(PrivacyGroupHeadBlockMap.empty());
    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);
    final MutableWorldState mutableWorldState = mock(MutableWorldState.class);
    when(mutableWorldState.updater()).thenReturn(mock(WorldUpdater.class));
    when(worldStateArchive.getMutable()).thenReturn(mutableWorldState);
    when(worldStateArchive.getMutable(any(), any())).thenReturn(Optional.of(mutableWorldState));
    privateStateStorage = mock(PrivateStateStorage.class);
    final PrivateStateStorage.Updater storageUpdater = mock(PrivateStateStorage.Updater.class);
    when(privateStateStorage.getPrivacyGroupHeadBlockMap(any())).thenReturn(Optional.of(PrivacyGroupHeadBlockMap.empty()));
    when(storageUpdater.putPrivateBlockMetadata(nullable(Bytes32.class), nullable(Bytes32.class), any())).thenReturn(storageUpdater);
    when(storageUpdater.putTransactionReceipt(nullable(Bytes32.class), nullable(Bytes32.class), any())).thenReturn(storageUpdater);
    when(privateStateStorage.updater()).thenReturn(storageUpdater);
}
Also used : MutableWorldState(org.hyperledger.besu.ethereum.core.MutableWorldState) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) WorldUpdater(org.hyperledger.besu.evm.worldstate.WorldUpdater) PrivateStateStorage(org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage) BlockDataGenerator(org.hyperledger.besu.ethereum.core.BlockDataGenerator) Bytes32(org.apache.tuweni.bytes.Bytes32) EnclaveFactory(org.hyperledger.besu.enclave.EnclaveFactory) EnclaveKeyConfiguration(org.hyperledger.enclave.testutil.EnclaveKeyConfiguration) WorldStateArchive(org.hyperledger.besu.ethereum.worldstate.WorldStateArchive) Block(org.hyperledger.besu.ethereum.core.Block) PrivateMetadataUpdater(org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with EnclaveKeyConfiguration

use of org.hyperledger.enclave.testutil.EnclaveKeyConfiguration in project besu by hyperledger.

the class PrivGetPrivateTransactionIntegrationTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    vertx = Vertx.vertx();
    testHarness = TesseraTestHarnessFactory.create("enclave", Files.createTempDirectory(folder, "enclave"), new EnclaveKeyConfiguration("enclave_key_0.pub", "enclave_key_0.key"), Optional.empty());
    testHarness.start();
    final EnclaveFactory factory = new EnclaveFactory(vertx);
    enclave = factory.createVertxEnclave(testHarness.clientUrl());
    privacyController = new RestrictedDefaultPrivacyController(blockchain, privateStateStorage, enclave, null, null, null, null, null);
}
Also used : EnclaveFactory(org.hyperledger.besu.enclave.EnclaveFactory) EnclaveKeyConfiguration(org.hyperledger.enclave.testutil.EnclaveKeyConfiguration) RestrictedDefaultPrivacyController(org.hyperledger.besu.ethereum.privacy.RestrictedDefaultPrivacyController) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

EnclaveKeyConfiguration (org.hyperledger.enclave.testutil.EnclaveKeyConfiguration)3 EnclaveFactory (org.hyperledger.besu.enclave.EnclaveFactory)2 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 Block (org.hyperledger.besu.ethereum.core.Block)1 BlockDataGenerator (org.hyperledger.besu.ethereum.core.BlockDataGenerator)1 MutableWorldState (org.hyperledger.besu.ethereum.core.MutableWorldState)1 RestrictedDefaultPrivacyController (org.hyperledger.besu.ethereum.privacy.RestrictedDefaultPrivacyController)1 PrivateMetadataUpdater (org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater)1 PrivateStateStorage (org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage)1 WorldStateArchive (org.hyperledger.besu.ethereum.worldstate.WorldStateArchive)1 MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)1 WorldUpdater (org.hyperledger.besu.evm.worldstate.WorldUpdater)1 BesuNodeConfigurationBuilder (org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder)1 PrivacyNodeConfiguration (org.hyperledger.besu.tests.acceptance.dsl.node.configuration.privacy.PrivacyNodeConfiguration)1 Before (org.junit.Before)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1