Search in sources :

Example 1 with PrivateTransaction

use of org.hyperledger.besu.ethereum.privacy.PrivateTransaction in project besu by hyperledger.

the class MultiTenancyAcceptanceTest method privGetTransactionReceiptSuccessShouldReturnTransactionReceiptAfterMined.

@Test
public void privGetTransactionReceiptSuccessShouldReturnTransactionReceiptAfterMined() throws JsonProcessingException {
    final PrivateTransaction validSignedPrivateTransaction = getValidSignedPrivateTransaction(senderAddress);
    final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction);
    retrievePrivacyGroupEnclaveStub();
    sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1);
    receiveEnclaveStub(validSignedPrivateTransaction);
    final Hash transactionReceipt = node.execute(privacyTransactions.sendRawTransaction(rlpOutput.encoded().toHexString()));
    node.verify(priv.getSuccessfulTransactionReceipt(transactionReceipt));
}
Also used : PrivateTransaction(org.hyperledger.besu.ethereum.privacy.PrivateTransaction) Hash(org.hyperledger.besu.datatypes.Hash) BytesValueRLPOutput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput) Test(org.junit.Test)

Example 2 with PrivateTransaction

use of org.hyperledger.besu.ethereum.privacy.PrivateTransaction in project besu by hyperledger.

the class MultiTenancyAcceptanceTest method privGetTransactionCountSuccessShouldReturnExpectedTransactionCount.

@Test
public void privGetTransactionCountSuccessShouldReturnExpectedTransactionCount() throws JsonProcessingException {
    final PrivateTransaction validSignedPrivateTransaction = getValidSignedPrivateTransaction(senderAddress);
    final String accountAddress = validSignedPrivateTransaction.getSender().toHexString();
    final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction);
    retrievePrivacyGroupEnclaveStub();
    sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1);
    receiveEnclaveStub(validSignedPrivateTransaction);
    node.verify(priv.getTransactionCount(accountAddress, PRIVACY_GROUP_ID, 0));
    final Hash transactionReceipt = node.execute(privacyTransactions.sendRawTransaction(rlpOutput.encoded().toHexString()));
    node.verify(priv.getSuccessfulTransactionReceipt(transactionReceipt));
    node.verify(priv.getTransactionCount(accountAddress, PRIVACY_GROUP_ID, 1));
}
Also used : PrivateTransaction(org.hyperledger.besu.ethereum.privacy.PrivateTransaction) Hash(org.hyperledger.besu.datatypes.Hash) BytesValueRLPOutput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput) Test(org.junit.Test)

Example 3 with PrivateTransaction

use of org.hyperledger.besu.ethereum.privacy.PrivateTransaction in project besu by hyperledger.

the class MultiTenancyAcceptanceTest method privGetPrivateTransactionSuccessShouldReturnExpectedPrivateTransaction.

@Test
public void privGetPrivateTransactionSuccessShouldReturnExpectedPrivateTransaction() throws JsonProcessingException {
    final PrivateTransaction validSignedPrivateTransaction = getValidSignedPrivateTransaction(senderAddress);
    receiveEnclaveStub(validSignedPrivateTransaction);
    retrievePrivacyGroupEnclaveStub();
    sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1);
    final Hash transactionHash = node.execute(privacyTransactions.sendRawTransaction(getRLPOutput(validSignedPrivateTransaction).encoded().toHexString()));
    node.verify(priv.getSuccessfulTransactionReceipt(transactionHash));
    node.verify(priv.getPrivateTransaction(transactionHash, validSignedPrivateTransaction));
}
Also used : PrivateTransaction(org.hyperledger.besu.ethereum.privacy.PrivateTransaction) Hash(org.hyperledger.besu.datatypes.Hash) Test(org.junit.Test)

Example 4 with PrivateTransaction

use of org.hyperledger.besu.ethereum.privacy.PrivateTransaction in project besu by hyperledger.

the class MultiTenancyValidationFailAcceptanceTest method sendRawTransactionShouldFailWhenPrivacyGroupDoesNotContainEnclaveKey.

@Test
public void sendRawTransactionShouldFailWhenPrivacyGroupDoesNotContainEnclaveKey() throws JsonProcessingException {
    final PrivateTransaction validSignedPrivateTransaction = getValidSignedPrivateTransaction(senderAddress, ENCLAVE_PUBLIC_KEY);
    retrievePrivacyGroupEnclaveStub();
    final Transaction<Hash> transaction = privacyTransactions.sendRawTransaction(getRLPOutput(validSignedPrivateTransaction).encoded().toHexString());
    node.verify(priv.multiTenancyValidationFail(transaction, ENCLAVE_ERROR));
}
Also used : PrivateTransaction(org.hyperledger.besu.ethereum.privacy.PrivateTransaction) Hash(org.hyperledger.besu.datatypes.Hash) Test(org.junit.Test)

Example 5 with PrivateTransaction

use of org.hyperledger.besu.ethereum.privacy.PrivateTransaction in project besu by hyperledger.

the class MultiTenancyValidationFailAcceptanceTest method sendRawTransactionShouldFailWhenPrivateFromNotMatchEnclaveKey.

@Test
public void sendRawTransactionShouldFailWhenPrivateFromNotMatchEnclaveKey() throws JsonProcessingException {
    final PrivateTransaction validSignedPrivateTransaction = getValidSignedPrivateTransaction(senderAddress, OTHER_ENCLAVE_PUBLIC_KEY);
    retrievePrivacyGroupEnclaveStub();
    final Transaction<Hash> transaction = privacyTransactions.sendRawTransaction(getRLPOutput(validSignedPrivateTransaction).encoded().toHexString());
    node.verify(priv.multiTenancyValidationFail(transaction, JsonRpcError.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY));
}
Also used : PrivateTransaction(org.hyperledger.besu.ethereum.privacy.PrivateTransaction) Hash(org.hyperledger.besu.datatypes.Hash) Test(org.junit.Test)

Aggregations

PrivateTransaction (org.hyperledger.besu.ethereum.privacy.PrivateTransaction)36 Test (org.junit.Test)26 Hash (org.hyperledger.besu.datatypes.Hash)14 Bytes (org.apache.tuweni.bytes.Bytes)11 BytesValueRLPOutput (org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput)10 ReceiveResponse (org.hyperledger.besu.enclave.types.ReceiveResponse)8 Transaction (org.hyperledger.besu.ethereum.core.Transaction)8 Enclave (org.hyperledger.besu.enclave.Enclave)7 JsonRpcSuccessResponse (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse)6 PrecompiledContract (org.hyperledger.besu.evm.precompile.PrecompiledContract)6 Bytes32 (org.apache.tuweni.bytes.Bytes32)5 ExecutedPrivateTransaction (org.hyperledger.besu.ethereum.privacy.ExecutedPrivateTransaction)5 PrivacyGroup (org.hyperledger.besu.enclave.types.PrivacyGroup)4 JsonRpcRequestContext (org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext)4 MutableWorldState (org.hyperledger.besu.ethereum.core.MutableWorldState)4 PrivateTransactionReceipt (org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt)4 PrivateMetadataUpdater (org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater)4 TransactionProcessingResult (org.hyperledger.besu.ethereum.processing.TransactionProcessingResult)4 WorldUpdater (org.hyperledger.besu.evm.worldstate.WorldUpdater)4 Nonnull (javax.annotation.Nonnull)3