use of io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction in project nem2-sdk-java by nemtech.
the class AccountRestrictionIntegrationTest method addRestrictionsToRandomAddress.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addRestrictionsToRandomAddress(RepositoryType type) {
Account testAccount = this.helper().createTestAccount(type);
Account testAccount2 = this.helper().createTestAccount(type);
Account testAccount3 = this.helper().createTestAccount(type);
Account testAccount4 = this.helper().createTestAccount(type);
AccountOperationRestrictionTransaction operationRestrictions = AccountOperationRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), AccountOperationRestrictionFlags.BLOCK_OUTGOING_TRANSACTION_TYPE, Arrays.asList(TransactionType.HASH_LOCK, TransactionType.SECRET_LOCK), Collections.emptyList()).maxFee(maxFee).build();
AccountAddressRestrictionTransaction accountRestrictions1 = AccountAddressRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), AccountAddressRestrictionFlags.BLOCK_ADDRESS, Arrays.asList(testAccount2.getAddress(), testAccount3.getAddress()), Collections.emptyList()).maxFee(maxFee).build();
AccountAddressRestrictionTransaction accountRestrictions2 = AccountAddressRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), AccountAddressRestrictionFlags.BLOCK_OUTGOING_ADDRESS, Collections.singletonList(testAccount4.getAddress()), Collections.emptyList()).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Arrays.asList(operationRestrictions.toAggregate(testAccount.getPublicAccount()), accountRestrictions1.toAggregate(testAccount.getPublicAccount()), accountRestrictions2.toAggregate(testAccount.getPublicAccount()))).maxFee(maxFee).build();
helper().announceAndValidate(type, testAccount, aggregateTransaction);
sleep(1000);
AccountRestrictions accountRestrictions = get(getRepositoryFactory(type).createRestrictionAccountRepository().getAccountRestrictions(testAccount.getAddress()));
Assertions.assertEquals(3, accountRestrictions.getRestrictions().size());
}
use of io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction in project nem2-sdk-java by nemtech.
the class AccountRestrictionIntegrationTest method sendAccountRestrictionAddress.
private void sendAccountRestrictionAddress(RepositoryType type, UnresolvedAddress unresolvedAddress, boolean add, AccountAddressRestrictionFlags accountRestrictionFlags) {
List<UnresolvedAddress> additions = add ? Collections.singletonList(unresolvedAddress) : Collections.emptyList();
List<UnresolvedAddress> deletions = !add ? Collections.singletonList(unresolvedAddress) : Collections.emptyList();
AccountAddressRestrictionTransaction transaction = AccountAddressRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), accountRestrictionFlags, additions, deletions).maxFee(maxFee).build();
AccountAddressRestrictionTransaction processedTransaction = announceAndValidate(type, testAccount, transaction);
Assertions.assertEquals(accountRestrictionFlags, processedTransaction.getRestrictionFlags());
Assertions.assertEquals(accountRestrictionFlags, processedTransaction.getRestrictionFlags());
Assertions.assertEquals(additions, processedTransaction.getRestrictionAdditions());
Assertions.assertEquals(deletions, processedTransaction.getRestrictionDeletions());
}
use of io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperVertxTest method shouldCreateAccountAddressRestriction.
@Test
public void shouldCreateAccountAddressRestriction() throws Exception {
TransactionInfoDTO transactionInfoDTO = TestHelperVertx.loadTransactionInfoDTO("accountAddressRestrictionTransaction.json");
AccountAddressRestrictionTransaction transaction = (AccountAddressRestrictionTransaction) map(transactionInfoDTO);
validateStandaloneTransaction(transaction, transactionInfoDTO);
Assertions.assertEquals(AccountAddressRestrictionFlags.ALLOW_INCOMING_ADDRESS, transaction.getRestrictionFlags());
Assertions.assertEquals(1, transaction.getRestrictionAdditions().size());
Assertions.assertEquals(MapperUtils.toAddress("90DD539FC43C3703715A7445EA9188544F9086BC93A22465"), transaction.getRestrictionAdditions().get(0));
Assertions.assertEquals(MapperUtils.toAddress("9067C932B35C128FB23AAD0153036FF8DA44E52448D2E633"), transaction.getRestrictionDeletions().get(0));
}
use of io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method shouldCreateAccountAddressRestriction.
@Test
public void shouldCreateAccountAddressRestriction() {
TransactionInfoDTO transactionInfoDTO = TestHelperOkHttp.loadTransactionInfoDTO("accountAddressRestrictionTransaction.json");
AccountAddressRestrictionTransaction transaction = (AccountAddressRestrictionTransaction) map(transactionInfoDTO);
validateStandaloneTransaction(transaction, transactionInfoDTO);
Assertions.assertEquals(AccountAddressRestrictionFlags.ALLOW_INCOMING_ADDRESS, transaction.getRestrictionFlags());
Assertions.assertEquals(1, transaction.getRestrictionAdditions().size());
Assertions.assertEquals(MapperUtils.toAddress("90DD539FC43C3703715A7445EA9188544F9086BC93A22465"), transaction.getRestrictionAdditions().get(0));
Assertions.assertEquals(MapperUtils.toAddress("9067C932B35C128FB23AAD0153036FF8DA44E52448D2E633"), transaction.getRestrictionDeletions().get(0));
}
use of io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method accountAddressRestrictionTransactionResolveAlias.
@Test
void accountAddressRestrictionTransactionResolveAlias() throws ExecutionException, InterruptedException {
String transactionHash = "aaaa";
TransactionFactory<AccountAddressRestrictionTransaction> factory = AccountAddressRestrictionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), AccountAddressRestrictionFlags.ALLOW_INCOMING_ADDRESS, Arrays.asList(addressNamespace1, address2, addressNamespace2), Arrays.asList(addressNamespace2, addressNamespace3, address3)).transactionInfo(TransactionInfo.create(height, 4, "ABC", transactionHash, ""));
AccountAddressRestrictionTransaction transaction = factory.build();
simulateStatement(height, 5, 0);
List<String> hashes = Collections.singletonList(transactionHash);
Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
AccountAddressRestrictionTransaction resolvedTransaction = (AccountAddressRestrictionTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
Assertions.assertEquals(Arrays.asList(address1, address2, address2), resolvedTransaction.getRestrictionAdditions());
Assertions.assertEquals(Arrays.asList(address2, address3, address3), resolvedTransaction.getRestrictionDeletions());
}
Aggregations