use of org.hyperledger.besu.enclave.Enclave in project besu by hyperledger.
the class PrivacyPrecompiledContractTest method testInvalidPrivateTransaction.
@Test
public void testInvalidPrivateTransaction() {
final Enclave enclave = mock(Enclave.class);
when(enclave.retrievePrivacyGroup(PAYLOAD_TEST_PRIVACY_GROUP_ID)).thenReturn(new PrivacyGroup(PAYLOAD_TEST_PRIVACY_GROUP_ID, PrivacyGroup.Type.PANTHEON, "", "", Arrays.asList(VALID_BASE64_ENCLAVE_KEY.toBase64String())));
final PrivacyPrecompiledContract contract = new PrivacyPrecompiledContract(new SpuriousDragonGasCalculator(), enclave, worldStateArchive, privateStateRootResolver, privateStateGenesisAllocator, "RestrictedPrivacyTest");
contract.setPrivateTransactionProcessor(mockPrivateTxProcessor(TransactionProcessingResult.invalid(ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE))));
final PrivateTransaction privateTransaction = privateTransactionBesu();
final byte[] payload = convertPrivateTransactionToBytes(privateTransaction);
final String privateFrom = privateTransaction.getPrivateFrom().toBase64String();
final ReceiveResponse response = new ReceiveResponse(payload, PAYLOAD_TEST_PRIVACY_GROUP_ID, privateFrom);
when(enclave.receive(any(String.class))).thenReturn(response);
final PrecompiledContract.PrecompileContractResult result = contract.computePrecompile(privateTransactionLookupId, messageFrame);
final Bytes actual = result.getOutput();
assertThat(actual).isEqualTo(Bytes.EMPTY);
}
Aggregations