use of org.hyperledger.besu.tests.web3j.generated.CrossContractReader in project besu by hyperledger.
the class PrivateContractPublicStateAcceptanceTest method privateContractMustNotBeAbleToCallPublicContractWhichInstantiatesContract.
@Test
public void privateContractMustNotBeAbleToCallPublicContractWhichInstantiatesContract() throws Exception {
final CrossContractReader privateReader = transactionNode.execute(privateContractTransactions.createSmartContract(CrossContractReader.class, transactionNode.getTransactionSigningKey(), transactionNode.getEnclaveKey()));
final CrossContractReader publicReader = transactionNode.execute(contractTransactions.createSmartContract(CrossContractReader.class));
assertThatExceptionOfType(TransactionException.class).isThrownBy(() -> privateReader.deployRemote(publicReader.getContractAddress()).send()).returns(0, e -> e.getTransactionReceipt().get().getLogs().size());
}
use of org.hyperledger.besu.tests.web3j.generated.CrossContractReader in project besu by hyperledger.
the class PrivateContractPublicStateAcceptanceTest method privateContractMustNotBeAbleToCallPublicContractWhichChangesState.
@Test
public void privateContractMustNotBeAbleToCallPublicContractWhichChangesState() throws Exception {
final CrossContractReader privateReader = transactionNode.execute(privateContractTransactions.createSmartContract(CrossContractReader.class, transactionNode.getTransactionSigningKey(), transactionNode.getEnclaveKey()));
final CrossContractReader publicReader = transactionNode.execute(contractTransactions.createSmartContract(CrossContractReader.class));
assertThatExceptionOfType(TransactionException.class).isThrownBy(() -> privateReader.incrementRemote(publicReader.getContractAddress()).send()).returns("0x", e -> ((PrivateTransactionReceipt) e.getTransactionReceipt().get()).getOutput());
}
use of org.hyperledger.besu.tests.web3j.generated.CrossContractReader in project besu by hyperledger.
the class PrivateContractPublicStateAcceptanceTest method mustNotAllowAccessToPrivateStateFromPublicTx.
@Test
public void mustNotAllowAccessToPrivateStateFromPublicTx() throws Exception {
final EventEmitter privateEventEmitter = transactionNode.execute((privateContractTransactions.createSmartContract(EventEmitter.class, transactionNode.getTransactionSigningKey(), transactionNode.getEnclaveKey())));
final TransactionReceipt receipt = privateEventEmitter.store(BigInteger.valueOf(12)).send();
assertThat(receipt).isNotNull();
final CrossContractReader publicReader = transactionNode.execute(contractTransactions.createSmartContract(CrossContractReader.class));
final RemoteFunctionCall<BigInteger> functionCall = publicReader.read(privateEventEmitter.getContractAddress());
assertThatThrownBy(functionCall::send).isInstanceOf(ContractCallException.class);
}
use of org.hyperledger.besu.tests.web3j.generated.CrossContractReader in project besu by hyperledger.
the class PrivateContractPublicStateAcceptanceTest method privateContractMustNotBeAbleToCallSelfDestructOnPublicContract.
@Test
public void privateContractMustNotBeAbleToCallSelfDestructOnPublicContract() throws Exception {
final CrossContractReader privateReader = transactionNode.execute(privateContractTransactions.createSmartContract(CrossContractReader.class, transactionNode.getTransactionSigningKey(), transactionNode.getEnclaveKey()));
final CrossContractReader publicReader = transactionNode.getBesu().execute(contractTransactions.createSmartContract(CrossContractReader.class));
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());
}
use of org.hyperledger.besu.tests.web3j.generated.CrossContractReader in project besu by hyperledger.
the class PrivateContractPublicStateAcceptanceTest method mustAllowAccessToPublicStateFromPrivateTx.
@Test
public void mustAllowAccessToPublicStateFromPrivateTx() throws Exception {
final EventEmitter publicEventEmitter = transactionNode.execute(contractTransactions.createSmartContract(EventEmitter.class));
final TransactionReceipt receipt = publicEventEmitter.store(BigInteger.valueOf(12)).send();
assertThat(receipt).isNotNull();
final CrossContractReader reader = transactionNode.execute(privateContractTransactions.createSmartContract(CrossContractReader.class, transactionNode.getTransactionSigningKey(), transactionNode.getEnclaveKey()));
final RemoteFunctionCall<BigInteger> remoteFunctionCall = reader.read(publicEventEmitter.getContractAddress());
final BigInteger result = remoteFunctionCall.send();
assertThat(result).isEqualTo(BigInteger.valueOf(12));
}
Aggregations