use of org.web3j.utils.Restriction.RESTRICTED in project web3j by web3j.
the class BesuPrivacyQuickstartIntegrationTest method privacyGroupContract.
@Test
public void privacyGroupContract() throws Exception {
// Build new privacy group using the create API
final Base64String aliceBobGroup = nodeAlice.privCreatePrivacyGroup(Arrays.asList(ENCLAVE_KEY_ALICE, ENCLAVE_KEY_BOB), "AliceBob", "AliceBob group").send().getPrivacyGroupId();
// Find the privacy group that was built by Alice from Bob's node
final Base64String aliceBobGroupFromBobNode = nodeBob.privFindPrivacyGroup(Arrays.asList(ENCLAVE_KEY_ALICE, ENCLAVE_KEY_BOB)).send().getGroups().stream().filter(g -> g.getName().equals("AliceBob") && g.getDescription().equals("AliceBob group") && g.getPrivacyGroupId().equals(aliceBobGroup)).findFirst().orElseThrow(RuntimeException::new).getPrivacyGroupId();
TransactionReceiptProcessor transactionReceiptProcessor = new PollingPrivateTransactionReceiptProcessor(nodeAlice, DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH);
PrivateTransactionManager tmBob = new PrivateTransactionManager(nodeBob, BOB, transactionReceiptProcessor, ChainIdLong.NONE, ENCLAVE_KEY_BOB, aliceBobGroupFromBobNode, RESTRICTED);
PrivateTransactionManager tmAlice = new PrivateTransactionManager(nodeAlice, ALICE, transactionReceiptProcessor, ChainIdLong.NONE, ENCLAVE_KEY_ALICE, aliceBobGroupFromBobNode, RESTRICTED);
final HumanStandardToken tokenAlice = HumanStandardToken.deploy(nodeAlice, tmAlice, ZERO_GAS_PROVIDER, BigInteger.TEN, "eea_token", BigInteger.TEN, "EEATKN").send();
final HumanStandardToken tokenBob = HumanStandardToken.load(tokenAlice.getContractAddress(), nodeBob, tmBob, ZERO_GAS_PROVIDER);
tokenAlice.transfer(BOB.getAddress(), BigInteger.TEN).send();
testBalances(tokenAlice, tokenBob, BigInteger.ZERO, BigInteger.TEN);
}
use of org.web3j.utils.Restriction.RESTRICTED in project web3j by web3j.
the class BesuOnChainPrivacyIntegrationTest method testCanExecuteSmartContractsInOnChainPrivacyGroup.
@Test
public void testCanExecuteSmartContractsInOnChainPrivacyGroup() throws Exception {
Base64String aliceBobGroup = Base64String.wrap(generateRandomBytes(32));
final String createTxHash = besu.privOnChainCreatePrivacyGroup(aliceBobGroup, ALICE, ENCLAVE_KEY_ALICE, Collections.singletonList(ENCLAVE_KEY_BOB)).send().getTransactionHash();
TransactionReceipt createReceipt = processor.waitForTransactionReceipt(createTxHash);
assertTrue(createReceipt.isStatusOK());
// Find the privacy group that was built by Alice from Bob's node
final Base64String aliceBobGroupFromBobNode = besu.privOnChainFindPrivacyGroup(Arrays.asList(ENCLAVE_KEY_ALICE, ENCLAVE_KEY_BOB)).send().getGroups().stream().filter(g -> g.getPrivacyGroupId().equals(aliceBobGroup)).findFirst().orElseThrow(RuntimeException::new).getPrivacyGroupId();
TransactionReceiptProcessor transactionReceiptProcessor = new PollingPrivateTransactionReceiptProcessor(besu, DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH);
PrivateTransactionManager tmAlice = new PrivateTransactionManager(besu, ALICE, transactionReceiptProcessor, ChainIdLong.NONE, ENCLAVE_KEY_ALICE, aliceBobGroupFromBobNode, RESTRICTED);
PrivateTransactionManager tmBob = new PrivateTransactionManager(besu, BOB, transactionReceiptProcessor, ChainIdLong.NONE, ENCLAVE_KEY_BOB, aliceBobGroupFromBobNode, RESTRICTED);
final HumanStandardToken tokenAlice = HumanStandardToken.deploy(besu, tmAlice, ZERO_GAS_PROVIDER, BigInteger.TEN, "eea_token", BigInteger.TEN, "EEATKN").send();
final HumanStandardToken tokenBob = HumanStandardToken.load(tokenAlice.getContractAddress(), besu, tmBob, ZERO_GAS_PROVIDER);
tokenAlice.transfer(BOB.getAddress(), BigInteger.TEN).send();
testBalances(tokenAlice, tokenBob, BigInteger.ZERO, BigInteger.TEN);
}
Aggregations