use of org.web3j.protocol.besu.response.privacy.PrivacyGroup in project besu by hyperledger.
the class PrivacyGroupAcceptanceTest method nodeCanCreatePrivacyGroupWithoutName.
@Test
public void nodeCanCreatePrivacyGroupWithoutName() {
final String privacyGroupId = alice.execute(privacyTransactions.createPrivacyGroup(null, "my group description", alice, bob));
assertThat(privacyGroupId).isNotNull();
final PrivacyGroup expected = new PrivacyGroup(privacyGroupId, PrivacyGroup.Type.PANTHEON, "", "my group description", Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));
alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
}
use of org.web3j.protocol.besu.response.privacy.PrivacyGroup in project besu by hyperledger.
the class PrivacyGroupAcceptanceTest method nodeCanCreatePrivacyGroup.
@Test
public void nodeCanCreatePrivacyGroup() {
Log4j2ConfiguratorUtil.setLevel("", Level.DEBUG);
final String privacyGroupId = alice.execute(privacyTransactions.createPrivacyGroup("myGroupName", "my group description", alice, bob));
assertThat(privacyGroupId).isNotNull();
final PrivacyGroup expected = new PrivacyGroup(privacyGroupId, PrivacyGroup.Type.PANTHEON, "myGroupName", "my group description", Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));
alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
}
use of org.web3j.protocol.besu.response.privacy.PrivacyGroup in project besu by hyperledger.
the class PrivacyGroupAcceptanceTest method nodeCanCreatePrivacyGroupWithoutOptionalParams.
@Test
public void nodeCanCreatePrivacyGroupWithoutOptionalParams() {
final String privacyGroupId = alice.execute(privacyTransactions.createPrivacyGroup(null, null, alice));
assertThat(privacyGroupId).isNotNull();
final PrivacyGroup expected = new PrivacyGroup(privacyGroupId, PrivacyGroup.Type.PANTHEON, "", "", Base64String.wrapList(alice.getEnclaveKey()));
alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
}
use of org.web3j.protocol.besu.response.privacy.PrivacyGroup in project web3j by web3j.
the class BesuOnChainPrivacyIntegrationTest method testCreateAddRemoveOnChainPrivacyGroup.
@Test
public void testCreateAddRemoveOnChainPrivacyGroup() throws Exception {
Base64String privacyGroupId = Base64String.wrap(generateRandomBytes(32));
final String createTxHash = besu.privOnChainCreatePrivacyGroup(privacyGroupId, ALICE, ENCLAVE_KEY_ALICE, Collections.singletonList(ENCLAVE_KEY_BOB)).send().getTransactionHash();
TransactionReceipt createReceipt = processor.waitForTransactionReceipt(createTxHash);
assertTrue(createReceipt.isStatusOK());
final String addTxHash = besu.privOnChainAddToPrivacyGroup(privacyGroupId, ALICE, ENCLAVE_KEY_ALICE, Collections.singletonList(ENCLAVE_KEY_CHARLIE)).send().getTransactionHash();
TransactionReceipt addReceipt = processor.waitForTransactionReceipt(addTxHash);
assertTrue(addReceipt.isStatusOK());
List<PrivacyGroup> groups = besu.privOnChainFindPrivacyGroup(Arrays.asList(ENCLAVE_KEY_ALICE, ENCLAVE_KEY_BOB, ENCLAVE_KEY_CHARLIE)).send().getGroups();
assertTrue(groups.stream().anyMatch(g -> g.getPrivacyGroupId().equals(privacyGroupId) && g.getMembers().size() == 3));
final String removeTxHash = besu.privOnChainRemoveFromPrivacyGroup(privacyGroupId, ALICE, ENCLAVE_KEY_ALICE, ENCLAVE_KEY_CHARLIE).send().getTransactionHash();
TransactionReceipt removeReceipt = processor.waitForTransactionReceipt(removeTxHash);
assertTrue(removeReceipt.isStatusOK());
List<PrivacyGroup> removedGroups = besu.privOnChainFindPrivacyGroup(Arrays.asList(ENCLAVE_KEY_ALICE, ENCLAVE_KEY_BOB)).send().getGroups();
assertTrue(removedGroups.stream().anyMatch(g -> g.getPrivacyGroupId().equals(privacyGroupId) && g.getMembers().size() == 2));
}
use of org.web3j.protocol.besu.response.privacy.PrivacyGroup in project web3j by web3j.
the class BesuOnChainPrivacyIntegrationTest method testCreateAndFindOnChainPrivacyGroup.
@Test
public void testCreateAndFindOnChainPrivacyGroup() throws Exception {
Base64String privacyGroupId = Base64String.wrap(generateRandomBytes(32));
final String txHash = besu.privOnChainCreatePrivacyGroup(privacyGroupId, ALICE, ENCLAVE_KEY_ALICE, Collections.singletonList(ENCLAVE_KEY_BOB)).send().getTransactionHash();
TransactionReceipt receipt = processor.waitForTransactionReceipt(txHash);
assertTrue(receipt.isStatusOK());
List<PrivacyGroup> groups = besu.privOnChainFindPrivacyGroup(Arrays.asList(ENCLAVE_KEY_ALICE, ENCLAVE_KEY_BOB)).send().getGroups();
assertTrue(groups.stream().anyMatch(x -> x.getPrivacyGroupId().equals(privacyGroupId)));
}
Aggregations