Fix AT failure because of additional field sent by Orion (#299)

Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
pull/301/head
pinges 5 years ago committed by Usman Saleem
parent 5535203893
commit b7a1422165
  1. 11
      enclave/src/main/java/org/hyperledger/besu/enclave/types/ReceiveResponse.java
  2. 7
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransactionTest.java
  3. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceiptTest.java
  4. 3
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java
  5. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivacyControllerTest.java

@ -18,18 +18,21 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonPropertyOrder({"payload", "privacyGroupId"})
@JsonPropertyOrder({"payload", "privacyGroupId", "senderKey"})
public class ReceiveResponse {
private final byte[] payload;
private final String privacyGroupId;
private final String senderKey;
@JsonCreator
public ReceiveResponse(
@JsonProperty(value = "payload") final byte[] payload,
@JsonProperty(value = "privacyGroupId") final String privacyGroupId) {
@JsonProperty(value = "privacyGroupId") final String privacyGroupId,
@JsonProperty(value = "senderKey") final String senderKey) {
this.payload = payload;
this.privacyGroupId = privacyGroupId;
this.senderKey = senderKey;
}
public byte[] getPayload() {
@ -39,4 +42,8 @@ public class ReceiveResponse {
public String getPrivacyGroupId() {
return privacyGroupId;
}
public String getSenderKey() {
return senderKey;
}
}

@ -143,7 +143,9 @@ public class PrivGetPrivateTransactionTest {
when(privacyController.retrieveTransaction(anyString(), any()))
.thenReturn(
new ReceiveResponse(
Base64.getEncoder().encodeToString(bvrlp.encoded().toArray()).getBytes(UTF_8), ""));
Base64.getEncoder().encodeToString(bvrlp.encoded().toArray()).getBytes(UTF_8),
"",
null));
final JsonRpcSuccessResponse response =
(JsonRpcSuccessResponse) privGetPrivateTransaction.response(request);
final PrivateTransactionResult result = (PrivateTransactionResult) response.getResult();
@ -179,7 +181,8 @@ public class PrivGetPrivateTransactionTest {
.thenReturn(
new ReceiveResponse(
Base64.getEncoder().encodeToString(bvrlp.encoded().toArrayUnsafe()).getBytes(UTF_8),
""));
"",
null));
final JsonRpcSuccessResponse response =
(JsonRpcSuccessResponse) privGetPrivateTransaction.response(request);

@ -157,7 +157,9 @@ public class PrivGetTransactionReceiptTest {
when(privacyController.retrieveTransaction(anyString(), any()))
.thenReturn(
new ReceiveResponse(
Base64.getEncoder().encode(RLP.encode(privateTransaction::writeTo).toArray()), ""));
Base64.getEncoder().encode(RLP.encode(privateTransaction::writeTo).toArray()),
"",
null));
when(blockchainQueries.getBlockchain()).thenReturn(blockchain);
final TransactionLocation transactionLocation = new TransactionLocation(Hash.EMPTY, 0);

@ -126,7 +126,8 @@ public class PrivacyPrecompiledContractTest {
new SpuriousDragonGasCalculator(), enclave, worldStateArchive, privateStateStorage);
contract.setPrivateTransactionProcessor(mockPrivateTxProcessor());
final ReceiveResponse response = new ReceiveResponse(VALID_PRIVATE_TRANSACTION_RLP_BASE64, "");
final ReceiveResponse response =
new ReceiveResponse(VALID_PRIVATE_TRANSACTION_RLP_BASE64, "", null);
when(enclave.receive(any(String.class))).thenReturn(response);
final Bytes actual = contract.compute(key, messageFrame);

@ -105,7 +105,7 @@ public class PrivacyControllerTest {
private Enclave mockEnclave() {
Enclave mockEnclave = mock(Enclave.class);
SendResponse response = new SendResponse(TRANSACTION_KEY);
ReceiveResponse receiveResponse = new ReceiveResponse(new byte[0], "mock");
ReceiveResponse receiveResponse = new ReceiveResponse(new byte[0], "mock", null);
when(mockEnclave.send(anyString(), anyString(), anyList())).thenReturn(response);
when(mockEnclave.send(anyString(), anyString(), anyString())).thenReturn(response);
when(mockEnclave.receive(any(), any())).thenReturn(receiveResponse);
@ -250,7 +250,7 @@ public class PrivacyControllerTest {
@Test
public void retrievesTransaction() {
when(enclave.receive(anyString(), anyString()))
.thenReturn(new ReceiveResponse(PAYLOAD, PRIVACY_GROUP_ID));
.thenReturn(new ReceiveResponse(PAYLOAD, PRIVACY_GROUP_ID, null));
final ReceiveResponse receiveResponse =
privacyController.retrieveTransaction(TRANSACTION_KEY, ENCLAVE_PUBLIC_KEY);

Loading…
Cancel
Save