@ -57,6 +57,7 @@ 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.log.Log ;
import org.hyperledger.besu.evm.precompile.PrecompiledContract ;
import org.hyperledger.besu.evm.tracing.OperationTracer ;
import org.hyperledger.besu.evm.worldstate.WorldUpdater ;
@ -169,7 +170,9 @@ public class PrivacyPrecompiledContractTest {
new ReceiveResponse ( payload , PAYLOAD_TEST_PRIVACY_GROUP_ID , privateFrom ) ;
when ( enclave . receive ( any ( String . class ) ) ) . thenReturn ( response ) ;
final Bytes actual = contract . compute ( privateTransactionLookupId , messageFrame ) ;
final PrecompiledContract . PrecompileContractResult result =
contract . computePrecompile ( privateTransactionLookupId , messageFrame ) ;
final Bytes actual = result . getOutput ( ) ;
assertThat ( actual ) . isEqualTo ( Bytes . fromHexString ( DEFAULT_OUTPUT ) ) ;
}
@ -181,8 +184,11 @@ public class PrivacyPrecompiledContractTest {
when ( enclave . receive ( any ( String . class ) ) ) . thenThrow ( EnclaveClientException . class ) ;
final Bytes expected = contract . compute ( privateTransactionLookupId , messageFrame ) ;
assertThat ( expected ) . isEqualTo ( Bytes . EMPTY ) ;
final PrecompiledContract . PrecompileContractResult result =
contract . computePrecompile ( privateTransactionLookupId , messageFrame ) ;
final Bytes actual = result . getOutput ( ) ;
assertThat ( actual ) . isEqualTo ( Bytes . EMPTY ) ;
}
@Test ( expected = RuntimeException . class )
@ -192,7 +198,7 @@ public class PrivacyPrecompiledContractTest {
when ( enclave . receive ( any ( String . class ) ) ) . thenThrow ( new RuntimeException ( ) ) ;
contract . compute ( privateTransactionLookupId , messageFrame ) ;
contract . computePrecompile ( privateTransactionLookupId , messageFrame ) ;
}
@Test
@ -207,7 +213,7 @@ public class PrivacyPrecompiledContractTest {
when ( enclave . receive ( eq ( privateTransactionLookupId . toBase64String ( ) ) ) )
. thenReturn ( responseWithoutSenderKey ) ;
assertThatThrownBy ( ( ) - > contract . compute ( privateTransactionLookupId , messageFrame ) )
assertThatThrownBy ( ( ) - > contract . computePrecompile ( privateTransactionLookupId , messageFrame ) )
. isInstanceOf ( EnclaveConfigurationException . class )
. hasMessage ( "Incompatible Orion version. Orion version must be 1.6.0 or greater." ) ;
}
@ -242,8 +248,11 @@ public class PrivacyPrecompiledContractTest {
when ( enclave . receive ( eq ( privateTransactionLookupId . toBase64String ( ) ) ) )
. thenReturn ( responseWithWrongSenderKey ) ;
final Bytes expected = contract . compute ( privateTransactionLookupId , messageFrame ) ;
assertThat ( expected ) . isEqualTo ( Bytes . EMPTY ) ;
final PrecompiledContract . PrecompileContractResult result =
contract . computePrecompile ( privateTransactionLookupId , messageFrame ) ;
final Bytes actual = result . getOutput ( ) ;
assertThat ( actual ) . isEqualTo ( Bytes . EMPTY ) ;
}
@Test
@ -271,7 +280,9 @@ public class PrivacyPrecompiledContractTest {
new ReceiveResponse ( payload , PAYLOAD_TEST_PRIVACY_GROUP_ID , privateFrom ) ;
when ( enclave . receive ( any ( String . class ) ) ) . thenReturn ( response ) ;
final Bytes actual = contract . compute ( privateTransactionLookupId , messageFrame ) ;
final PrecompiledContract . PrecompileContractResult result =
contract . computePrecompile ( privateTransactionLookupId , messageFrame ) ;
final Bytes actual = result . getOutput ( ) ;
assertThat ( actual ) . isEqualTo ( Bytes . fromHexString ( DEFAULT_OUTPUT ) ) ;
}
@ -310,7 +321,9 @@ public class PrivacyPrecompiledContractTest {
when ( enclave . receive ( any ( String . class ) ) ) . thenReturn ( response ) ;
final Bytes actual = contract . compute ( privateTransactionLookupId , messageFrame ) ;
final PrecompiledContract . PrecompileContractResult result =
contract . computePrecompile ( privateTransactionLookupId , messageFrame ) ;
final Bytes actual = result . getOutput ( ) ;
assertThat ( actual ) . isEqualTo ( Bytes . EMPTY ) ;
}
@ -324,8 +337,11 @@ public class PrivacyPrecompiledContractTest {
final MessageFrame frame = mock ( MessageFrame . class ) ;
when ( frame . getContextVariable ( KEY_PRIVATE_METADATA_UPDATER ) ) . thenReturn ( null ) ;
final Bytes result = emptyContract . compute ( null , frame ) ;
assertThat ( result ) . isEqualTo ( Bytes . EMPTY ) ;
final PrecompiledContract . PrecompileContractResult result =
emptyContract . computePrecompile ( null , frame ) ;
final Bytes actual = result . getOutput ( ) ;
assertThat ( actual ) . isEqualTo ( Bytes . EMPTY ) ;
}
private byte [ ] convertPrivateTransactionToBytes ( final PrivateTransaction privateTransaction ) {