Update web3j in acceptance tests to ~4.8.6 (#2616)

* Update web3j in acceptance tests to ~4.8.6

Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>

* Acceptance tests updated as behaviour in web3j has changed

Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>

* Increase timeout for transaction receipt polling

Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>

* web3j can't seem to encode empty lists

Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>

* Increase timeout again! to 60s

Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>

* Make retries consistent.

Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>

* Fix merge from main

Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>

Co-authored-by: mark-terry <36909937+mark-terry@users.noreply.github.com>
Co-authored-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/2635/head
Antony Denyer 3 years ago committed by GitHub
parent 183f275f88
commit b0e57a450d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/CallOnChainPermissioningPrivateSmartContractFunction.java
  2. 16
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/CallPrivateSmartContractFunction.java
  3. 12
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/DeployPrivateSmartContractTransaction.java
  4. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/DeployPrivateSmartContractWithPrivacyGroupIdTransaction.java
  5. 9
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransaction.java
  6. 9
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransactionWithPrivacyGroupId.java
  7. 19
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/PrivateContractTransactions.java
  8. 232
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/PrivateTransactionManager.java
  9. 33
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java
  10. 1
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/DeployPrivateSmartContractAcceptanceTest.java
  11. 5
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PluginPrivacySigningAcceptanceTest.java
  12. 37
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateContractPublicStateAcceptanceTest.java
  13. 5
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/BftPrivacyClusterAcceptanceTest.java
  14. 7
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/contracts/PrivacyProxyTest.java
  15. 2
      consensus/qbft/build.gradle
  16. 2
      ethereum/permissioning/build.gradle
  17. 10
      gradle/versions.gradle

@ -21,8 +21,10 @@ import java.io.IOException;
import java.math.BigInteger;
import org.web3j.crypto.Credentials;
import org.web3j.tx.PrivateTransactionManager;
import org.web3j.tx.gas.BesuPrivacyGasProvider;
import org.web3j.utils.Base64String;
import org.web3j.utils.Restriction;
public class CallOnChainPermissioningPrivateSmartContractFunction implements Transaction<String> {
@ -51,10 +53,9 @@ public class CallOnChainPermissioningPrivateSmartContractFunction implements Tra
@Override
public String execute(final NodeRequests node) {
final PrivateTransactionManager privateTransactionManager =
new PrivateTransactionManager.Builder(
node.privacy().getBesuClient(), senderCredentials, privateFrom)
.setPrivacyGroupId(privacyGroupId)
.build();
node.privacy()
.getTransactionManager(
senderCredentials, privateFrom, privacyGroupId, Restriction.RESTRICTED);
try {
return privateTransactionManager

@ -22,6 +22,7 @@ import java.math.BigInteger;
import java.util.List;
import org.web3j.crypto.Credentials;
import org.web3j.tx.PrivateTransactionManager;
import org.web3j.tx.gas.BesuPrivacyGasProvider;
import org.web3j.utils.Base64String;
import org.web3j.utils.Restriction;
@ -92,19 +93,18 @@ public class CallPrivateSmartContractFunction implements Transaction<String> {
@Override
public String execute(final NodeRequests node) {
final PrivateTransactionManager.Builder builder =
new PrivateTransactionManager.Builder(
node.privacy().getBesuClient(), senderCredentials, privateFrom)
.setRestriction(restriction);
final PrivateTransactionManager privateTransactionManager;
if (privateFor != null) {
builder.setPrivateFor(privateFor);
privateTransactionManager =
node.privacy()
.getTransactionManager(senderCredentials, privateFrom, privateFor, restriction);
} else {
builder.setPrivacyGroupId(privacyGroupId);
privateTransactionManager =
node.privacy()
.getTransactionManager(senderCredentials, privateFrom, privacyGroupId, restriction);
}
final PrivateTransactionManager privateTransactionManager = builder.build();
try {
return privateTransactionManager
.sendTransaction(

@ -25,6 +25,7 @@ import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.tx.Contract;
import org.web3j.tx.PrivateTransactionManager;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.BesuPrivacyGasProvider;
import org.web3j.tx.gas.ContractGasProvider;
@ -39,19 +40,16 @@ public class DeployPrivateSmartContractTransaction<T extends Contract> implement
private final Class<T> clazz;
private final Credentials senderCredentials;
private final Restriction restriction;
private final Base64String privateFrom;
private final List<Base64String> privateFor;
public DeployPrivateSmartContractTransaction(
final Class<T> clazz,
final String transactionSigningKey,
final Restriction restriction,
final String privateFrom,
final List<String> privateFor) {
this.clazz = clazz;
this.senderCredentials = Credentials.create(transactionSigningKey);
this.restriction = restriction;
this.privateFrom = Base64String.wrap(privateFrom);
this.privateFor = Base64String.wrapList(privateFor);
}
@ -60,11 +58,9 @@ public class DeployPrivateSmartContractTransaction<T extends Contract> implement
public T execute(final NodeRequests node) {
final PrivateTransactionManager privateTransactionManager =
new PrivateTransactionManager.Builder(
node.privacy().getBesuClient(), senderCredentials, privateFrom)
.setPrivateFor(privateFor)
.setRestriction(restriction)
.build();
node.privacy()
.getTransactionManager(
senderCredentials, privateFrom, privateFor, Restriction.RESTRICTED);
try {
final Method method =

@ -24,6 +24,7 @@ import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.tx.Contract;
import org.web3j.tx.PrivateTransactionManager;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.BesuPrivacyGasProvider;
import org.web3j.tx.gas.ContractGasProvider;
@ -60,11 +61,8 @@ public class DeployPrivateSmartContractWithPrivacyGroupIdTransaction<T extends C
public T execute(final NodeRequests node) {
final PrivateTransactionManager privateTransactionManager =
new PrivateTransactionManager.Builder(
node.privacy().getBesuClient(), senderCredentials, privateFrom)
.setPrivacyGroupId(privacyGroupId)
.setRestriction(restriction)
.build();
node.privacy()
.getTransactionManager(senderCredentials, privateFrom, privacyGroupId, restriction);
try {
final Method method =

@ -24,10 +24,12 @@ import java.util.List;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.tx.Contract;
import org.web3j.tx.PrivateTransactionManager;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.BesuPrivacyGasProvider;
import org.web3j.tx.gas.ContractGasProvider;
import org.web3j.utils.Base64String;
import org.web3j.utils.Restriction;
public class LoadPrivateSmartContractTransaction<T extends Contract> implements Transaction<T> {
private static final BesuPrivacyGasProvider GAS_PROVIDER =
@ -58,10 +60,9 @@ public class LoadPrivateSmartContractTransaction<T extends Contract> implements
@Override
public T execute(final NodeRequests node) {
final PrivateTransactionManager privateTransactionManager =
new PrivateTransactionManager.Builder(
node.privacy().getBesuClient(), senderCredentials, privateFrom)
.setPrivateFor(privateFor)
.build();
node.privacy()
.getTransactionManager(
senderCredentials, privateFrom, privateFor, Restriction.RESTRICTED);
try {
final Method method =

@ -23,10 +23,12 @@ import java.math.BigInteger;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.tx.Contract;
import org.web3j.tx.PrivateTransactionManager;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.BesuPrivacyGasProvider;
import org.web3j.tx.gas.ContractGasProvider;
import org.web3j.utils.Base64String;
import org.web3j.utils.Restriction;
public class LoadPrivateSmartContractTransactionWithPrivacyGroupId<T extends Contract>
implements Transaction<T> {
@ -59,10 +61,9 @@ public class LoadPrivateSmartContractTransactionWithPrivacyGroupId<T extends Con
@Override
public T execute(final NodeRequests node) {
final PrivateTransactionManager privateTransactionManager =
new PrivateTransactionManager.Builder(
node.privacy().getBesuClient(), senderCredentials, privateFrom)
.setPrivacyGroupId(privacyGroupId)
.build();
node.privacy()
.getTransactionManager(
senderCredentials, privateFrom, privacyGroupId, Restriction.RESTRICTED);
try {
final Method method =

@ -51,31 +51,16 @@ public class PrivateContractTransactions {
final String privateFrom,
final String... privateFor) {
return createSmartContract(
clazz,
transactionSigningKey,
Restriction.RESTRICTED,
privateFrom,
Arrays.asList(privateFor));
clazz, transactionSigningKey, privateFrom, Arrays.asList(privateFor));
}
public <T extends Contract> DeployPrivateSmartContractTransaction<T> createSmartContract(
final Class<T> clazz,
final String transactionSigningKey,
final Restriction restriction,
final String privateFrom,
final String... privateFor) {
return createSmartContract(
clazz, transactionSigningKey, restriction, privateFrom, Arrays.asList(privateFor));
}
public <T extends Contract> DeployPrivateSmartContractTransaction<T> createSmartContract(
final Class<T> clazz,
final String transactionSigningKey,
final Restriction restriction,
final String privateFrom,
final List<String> privateFor) {
return new DeployPrivateSmartContractTransaction<>(
clazz, transactionSigningKey, restriction, privateFrom, privateFor);
clazz, transactionSigningKey, privateFrom, privateFor);
}
public CallPrivateSmartContractFunction callSmartContract(

@ -1,232 +0,0 @@
/*
* Copyright ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.privacy.contract;
import static org.web3j.utils.Restriction.RESTRICTED;
import java.io.IOException;
import java.math.BigInteger;
import java.util.List;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.besu.Besu;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.EthCall;
import org.web3j.protocol.core.methods.response.EthGetCode;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
import org.web3j.protocol.eea.crypto.PrivateTransactionEncoder;
import org.web3j.protocol.eea.crypto.RawPrivateTransaction;
import org.web3j.tx.ChainIdLong;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.response.PollingPrivateTransactionReceiptProcessor;
import org.web3j.tx.response.TransactionReceiptProcessor;
import org.web3j.utils.Base64String;
import org.web3j.utils.Numeric;
import org.web3j.utils.PrivacyGroupUtils;
import org.web3j.utils.Restriction;
public class PrivateTransactionManager extends TransactionManager {
private final Besu besu;
private final Credentials credentials;
private final long chainId;
private final Base64String privateFrom;
private final List<Base64String> privateFor;
private final Base64String privacyGroupId;
private final Restriction restriction;
public PrivateTransactionManager(
final Besu besu,
final Credentials credentials,
final TransactionReceiptProcessor transactionReceiptProcessor,
final long chainId,
final Base64String privateFrom,
final Base64String privacyGroupId,
final Restriction restriction) {
super(transactionReceiptProcessor, credentials.getAddress());
this.besu = besu;
this.credentials = credentials;
this.chainId = chainId;
this.privateFrom = privateFrom;
this.privateFor = null;
this.privacyGroupId = privacyGroupId;
this.restriction = restriction;
}
public PrivateTransactionManager(
final Besu besu,
final Credentials credentials,
final TransactionReceiptProcessor transactionReceiptProcessor,
final long chainId,
final Base64String privateFrom,
final List<Base64String> privateFor,
final Restriction restriction) {
super(transactionReceiptProcessor, credentials.getAddress());
this.besu = besu;
this.credentials = credentials;
this.chainId = chainId;
this.privateFrom = privateFrom;
this.privateFor = privateFor;
this.privacyGroupId = PrivacyGroupUtils.generateLegacyGroup(privateFrom, privateFor);
this.restriction = restriction;
}
public static class Builder {
private final Besu besu;
private final Credentials credentials;
private long chainId;
private final Base64String privateFrom;
private Base64String privacyGroupId;
private TransactionReceiptProcessor transactionReceiptProcessor;
private Restriction restriction = RESTRICTED;
private List<Base64String> privateFor = null;
public Builder(final Besu besu, final Credentials credentials, final Base64String privateFrom) {
this.besu = besu;
this.credentials = credentials;
this.chainId = ChainIdLong.NONE;
this.privateFrom = privateFrom;
transactionReceiptProcessor =
new PollingPrivateTransactionReceiptProcessor(
besu, DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH);
}
public Builder setRestriction(final Restriction restriction) {
this.restriction = restriction;
return this;
}
public Builder setTransactionReceiptProcessor(
final TransactionReceiptProcessor transactionReceiptProcessor) {
this.transactionReceiptProcessor = transactionReceiptProcessor;
return this;
}
public Builder setPrivacyGroupId(final Base64String privacyGroupId) {
this.privacyGroupId = privacyGroupId;
return this;
}
public Builder setPrivateFor(final List<Base64String> privateFor) {
this.privateFor = privateFor;
return this;
}
public Builder setChainId(final long chainId) {
this.chainId = chainId;
return this;
}
public PrivateTransactionManager build() {
if (privateFor != null) {
return new PrivateTransactionManager(
besu,
credentials,
transactionReceiptProcessor,
chainId,
privateFrom,
privateFor,
restriction);
} else {
return new PrivateTransactionManager(
besu,
credentials,
transactionReceiptProcessor,
chainId,
privateFrom,
privacyGroupId,
restriction);
}
}
}
@Override
public EthSendTransaction sendTransaction(
final BigInteger gasPrice,
final BigInteger gasLimit,
final String to,
final String data,
final BigInteger value,
final boolean constructor)
throws IOException {
final BigInteger nonce =
besu.privGetTransactionCount(credentials.getAddress(), privacyGroupId)
.send()
.getTransactionCount();
final RawPrivateTransaction transaction;
if (privateFor != null) {
transaction =
RawPrivateTransaction.createTransaction(
nonce, gasPrice, gasLimit, to, data, privateFrom, privateFor, restriction);
} else {
transaction =
RawPrivateTransaction.createTransaction(
nonce, gasPrice, gasLimit, to, data, privateFrom, privacyGroupId, restriction);
}
return signAndSend(transaction);
}
@Override
public String sendCall(
final String to, final String data, final DefaultBlockParameter defaultBlockParameter)
throws IOException {
final EthCall ethCall =
besu.privCall(
Transaction.createEthCallTransaction(getFromAddress(), to, data),
defaultBlockParameter,
privacyGroupId.toString())
.send();
return ethCall.getValue();
}
@Override
public EthGetCode getCode(
final String contractAddress, final DefaultBlockParameter defaultBlockParameter)
throws IOException {
return this.besu
.privGetCode(privacyGroupId.toString(), contractAddress, defaultBlockParameter)
.send();
}
public String sign(final RawPrivateTransaction rawTransaction) {
final byte[] signedMessage;
if (chainId > ChainIdLong.NONE) {
signedMessage = PrivateTransactionEncoder.signMessage(rawTransaction, chainId, credentials);
} else {
signedMessage = PrivateTransactionEncoder.signMessage(rawTransaction, credentials);
}
return Numeric.toHexString(signedMessage);
}
public EthSendTransaction signAndSend(final RawPrivateTransaction rawTransaction)
throws IOException {
final String hexValue = sign(rawTransaction);
return this.besu.eeaSendRawTransaction(hexValue).send();
}
}

@ -54,15 +54,48 @@ import org.web3j.protocol.core.methods.response.EthUninstallFilter;
import org.web3j.protocol.eea.crypto.PrivateTransactionEncoder;
import org.web3j.protocol.eea.crypto.RawPrivateTransaction;
import org.web3j.protocol.exceptions.TransactionException;
import org.web3j.tx.ChainIdLong;
import org.web3j.tx.Contract;
import org.web3j.tx.PrivateTransactionManager;
import org.web3j.tx.response.PollingPrivateTransactionReceiptProcessor;
import org.web3j.utils.Base64String;
import org.web3j.utils.Numeric;
import org.web3j.utils.Restriction;
public class PrivacyRequestFactory {
private final SecureRandom secureRandom;
public PrivateTransactionManager getTransactionManager(
final Credentials credentials,
final Base64String privateFrom,
final List<Base64String> privateFor,
final Restriction restriction) {
return new PrivateTransactionManager(
getBesuClient(),
credentials,
new PollingPrivateTransactionReceiptProcessor(getBesuClient(), 1000, 60),
ChainIdLong.NONE,
privateFrom,
privateFor,
restriction);
}
public PrivateTransactionManager getTransactionManager(
final Credentials credentials,
final Base64String privateFrom,
final Base64String privacyGroupId,
final Restriction restriction) {
return new PrivateTransactionManager(
getBesuClient(),
credentials,
new PollingPrivateTransactionReceiptProcessor(getBesuClient(), 1000, 60),
ChainIdLong.NONE,
privateFrom,
privacyGroupId,
restriction);
}
public static class GetPrivacyPrecompileAddressResponse extends Response<Address> {}
public static class GetPrivateTransactionResponse

@ -58,7 +58,6 @@ public class DeployPrivateSmartContractAcceptanceTest extends ParameterizedEncla
privateContractTransactions.createSmartContract(
EventEmitter.class,
minerNode.getTransactionSigningKey(),
restriction,
minerNode.getEnclaveKey()));
privateContractVerifier

@ -16,7 +16,6 @@ package org.hyperledger.besu.tests.acceptance.privacy;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.tests.acceptance.dsl.privacy.account.PrivacyAccountResolver.BOB;
import static org.web3j.utils.Restriction.UNRESTRICTED;
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder;
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.privacy.PrivacyNodeConfiguration;
@ -77,7 +76,6 @@ public class PluginPrivacySigningAcceptanceTest extends PrivacyAcceptanceTestBas
privateContractTransactions.createSmartContract(
EventEmitter.class,
minerNode.getTransactionSigningKey(),
UNRESTRICTED,
minerNode.getEnclaveKey()));
privateContractVerifier
@ -89,11 +87,10 @@ public class PluginPrivacySigningAcceptanceTest extends PrivacyAcceptanceTestBas
minerNode
.execute(
ethTransactions.getTransactionReceipt(
"0x5586b8321e26cdabd68e0139955b90f97c0fc082519d07e1c0b9db26862ff2ff"))
"0x3d232ce6be958f99ff6a669cbc759bca19e35f5561045998cf843ec9a8b28530"))
.get();
assertThat(pmtReceipt.getStatus()).isEqualTo("0x1");
assertThat(pmtReceipt.getFrom()).isEqualTo("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73");
}
}

@ -15,6 +15,7 @@
package org.hyperledger.besu.tests.acceptance.privacy;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.web3j.utils.Restriction.UNRESTRICTED;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.ParameterizedEnclaveTestBase;
@ -27,12 +28,12 @@ import java.io.IOException;
import java.math.BigInteger;
import java.util.Optional;
import org.junit.Ignore;
import org.junit.Test;
import org.testcontainers.containers.Network;
import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.protocol.exceptions.TransactionException;
import org.web3j.tx.exceptions.ContractCallException;
import org.web3j.utils.Restriction;
@ -69,7 +70,6 @@ public class PrivateContractPublicStateAcceptanceTest extends ParameterizedEncla
}
@Test
@Ignore("Web3j needs to be updated https://github.com/hyperledger/besu/issues/2098")
public void mustAllowAccessToPublicStateFromPrivateTx() throws Exception {
final EventEmitter publicEventEmitter =
transactionNode.execute(contractTransactions.createSmartContract(EventEmitter.class));
@ -82,7 +82,6 @@ public class PrivateContractPublicStateAcceptanceTest extends ParameterizedEncla
privateContractTransactions.createSmartContract(
CrossContractReader.class,
transactionNode.getTransactionSigningKey(),
restriction,
transactionNode.getEnclaveKey()));
final RemoteFunctionCall<BigInteger> remoteFunctionCall =
@ -99,7 +98,6 @@ public class PrivateContractPublicStateAcceptanceTest extends ParameterizedEncla
(privateContractTransactions.createSmartContract(
EventEmitter.class,
transactionNode.getTransactionSigningKey(),
restriction,
transactionNode.getEnclaveKey())));
final TransactionReceipt receipt = privateEventEmitter.store(BigInteger.valueOf(12)).send();
@ -119,18 +117,16 @@ public class PrivateContractPublicStateAcceptanceTest extends ParameterizedEncla
privateContractTransactions.createSmartContract(
CrossContractReader.class,
transactionNode.getTransactionSigningKey(),
restriction,
transactionNode.getEnclaveKey()));
final CrossContractReader publicReader =
transactionNode.execute(
contractTransactions.createSmartContract(CrossContractReader.class));
final PrivateTransactionReceipt transactionReceipt =
(PrivateTransactionReceipt)
privateReader.incrementRemote(publicReader.getContractAddress()).send();
assertThat(transactionReceipt.getOutput()).isEqualTo("0x");
assertThatExceptionOfType(TransactionException.class)
.isThrownBy(() -> privateReader.incrementRemote(publicReader.getContractAddress()).send())
.returns(
"0x", e -> ((PrivateTransactionReceipt) e.getTransactionReceipt().get()).getOutput());
}
@Test
@ -141,18 +137,15 @@ public class PrivateContractPublicStateAcceptanceTest extends ParameterizedEncla
privateContractTransactions.createSmartContract(
CrossContractReader.class,
transactionNode.getTransactionSigningKey(),
restriction,
transactionNode.getEnclaveKey()));
final CrossContractReader publicReader =
transactionNode.execute(
contractTransactions.createSmartContract(CrossContractReader.class));
final PrivateTransactionReceipt transactionReceipt =
(PrivateTransactionReceipt)
privateReader.deployRemote(publicReader.getContractAddress()).send();
assertThat(transactionReceipt.getLogs().size()).isEqualTo(0);
assertThatExceptionOfType(TransactionException.class)
.isThrownBy(() -> privateReader.deployRemote(publicReader.getContractAddress()).send())
.returns(0, e -> e.getTransactionReceipt().get().getLogs().size());
}
@Test
@ -162,7 +155,6 @@ public class PrivateContractPublicStateAcceptanceTest extends ParameterizedEncla
privateContractTransactions.createSmartContract(
CrossContractReader.class,
transactionNode.getTransactionSigningKey(),
restriction,
transactionNode.getEnclaveKey()));
final CrossContractReader publicReader =
@ -170,10 +162,11 @@ public class PrivateContractPublicStateAcceptanceTest extends ParameterizedEncla
.getBesu()
.execute(contractTransactions.createSmartContract(CrossContractReader.class));
final PrivateTransactionReceipt transactionReceipt =
(PrivateTransactionReceipt)
privateReader.remoteDestroy(publicReader.getContractAddress()).send();
assertThat(transactionReceipt.getOutput()).isEqualTo("0x");
assertThatExceptionOfType(TransactionException.class)
.isThrownBy(() -> privateReader.remoteDestroy(publicReader.getContractAddress()).send())
.withMessage(
"Transaction null has failed with status: 0x0. Gas used: unknown. Revert reason: '0x'.")
.returns(
"0x", e -> ((PrivateTransactionReceipt) e.getTransactionReceipt().get()).getOutput());
}
}

@ -137,7 +137,6 @@ public class BftPrivacyClusterAcceptanceTest extends PrivacyAcceptanceTestBase {
privateContractTransactions.createSmartContract(
EventEmitter.class,
alice.getTransactionSigningKey(),
bftPrivacyType.restriction,
alice.getEnclaveKey(),
bob.getEnclaveKey()));
@ -178,7 +177,6 @@ public class BftPrivacyClusterAcceptanceTest extends PrivacyAcceptanceTestBase {
privateContractTransactions.createSmartContract(
EventEmitter.class,
alice.getTransactionSigningKey(),
bftPrivacyType.restriction,
alice.getEnclaveKey(),
bob.getEnclaveKey()));
@ -193,7 +191,6 @@ public class BftPrivacyClusterAcceptanceTest extends PrivacyAcceptanceTestBase {
privateContractTransactions.createSmartContract(
EventEmitter.class,
alice.getTransactionSigningKey(),
bftPrivacyType.restriction,
alice.getEnclaveKey(),
bob.getEnclaveKey()));
@ -212,7 +209,6 @@ public class BftPrivacyClusterAcceptanceTest extends PrivacyAcceptanceTestBase {
privateContractTransactions.createSmartContract(
EventEmitter.class,
alice.getTransactionSigningKey(),
bftPrivacyType.restriction,
alice.getEnclaveKey(),
bob.getEnclaveKey(),
charlie.getEnclaveKey()));
@ -253,7 +249,6 @@ public class BftPrivacyClusterAcceptanceTest extends PrivacyAcceptanceTestBase {
privateContractTransactions.createSmartContract(
EventEmitter.class,
alice.getTransactionSigningKey(),
bftPrivacyType.restriction,
alice.getEnclaveKey(),
bob.getEnclaveKey()));

@ -28,7 +28,6 @@ import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
@ -50,7 +49,7 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
private static final String RAW_GET_PARTICIPANTS = "0x5aa68ac0";
private static final String RAW_ADD_PARTICIPANT =
"0xb4926e2500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000";
"0xb4926e2500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001f772b2ee55f016431cefe724a05814324bb96e9afdb73e338665a693d4653678";
private BesuNode minerNode;
private DefaultOnChainPrivacyGroupManagementContract defaultOnChainPrivacyGroupManagementContract;
@ -78,14 +77,14 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
.verify(onChainPrivacyGroupManagementProxy);
assertThat(RAW_GET_PARTICIPANTS)
.isEqualTo(onChainPrivacyGroupManagementProxy.getParticipants().encodeFunctionCall());
assertThat(RAW_ADD_PARTICIPANT)
.isEqualTo(
onChainPrivacyGroupManagementProxy
.addParticipants(Collections.emptyList())
.addParticipants(List.of(firstParticipant.raw()))
.encodeFunctionCall());
}
@Ignore("return 0x which causes web3j to throw exception instead of return empty list")
@Test
public void deploysWithNoParticipant() throws Exception {
final List<byte[]> participants = onChainPrivacyGroupManagementProxy.getParticipants().send();

@ -72,7 +72,7 @@ dependencies {
implementation 'io.vertx:vertx-core'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.web3j:abi:5.0.0'
implementation 'org.web3j:abi'
integrationTestImplementation project(path: ':config', configuration: 'testSupportArtifacts')
integrationTestImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')

@ -40,7 +40,7 @@ dependencies {
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-toml'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.web3j:abi:5.0.0'
implementation 'org.web3j:abi'
testImplementation project(':config')
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')

@ -152,13 +152,13 @@ dependencyManagement {
dependency 'org.testcontainers:testcontainers:1.16.0'
dependency 'org.web3j:abi:4.5.15'
dependency 'org.web3j:besu:4.5.15'
dependency('org.web3j:core:4.5.15') {
dependency 'org.web3j:abi:4.8.6'
dependency 'org.web3j:besu:4.8.6'
dependency('org.web3j:core:4.8.6') {
exclude group: 'com.github.jnr', name: 'jnr-unixsocket'
}
dependency 'org.web3j:crypto:4.5.15'
dependency 'org.web3j:quorum:4.5.15'
dependency 'org.web3j:crypto:4.8.6'
dependency 'org.web3j:quorum:4.8.4'
dependency 'org.xerial.snappy:snappy-java:1.1.8.4'

Loading…
Cancel
Save