use of io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction in project nem2-sdk-java by nemtech.
the class AccountRestrictionIntegrationTest method sendAccountRestrictionTransaction.
private void sendAccountRestrictionTransaction(RepositoryType type, TransactionType transactionType, boolean add, AccountOperationRestrictionFlags accountRestrictionFlags) {
List<TransactionType> additions = add ? Collections.singletonList(transactionType) : Collections.emptyList();
List<TransactionType> deletions = !add ? Collections.singletonList(transactionType) : Collections.emptyList();
AccountOperationRestrictionTransaction transaction = AccountOperationRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), accountRestrictionFlags, additions, deletions).maxFee(maxFee).build();
AccountOperationRestrictionTransaction processedTransaction = announceAndValidate(type, testAccount, transaction);
Assertions.assertEquals(accountRestrictionFlags, processedTransaction.getRestrictionFlags());
Assertions.assertEquals(additions, processedTransaction.getRestrictionAdditions());
Assertions.assertEquals(deletions, processedTransaction.getRestrictionDeletions());
}
use of io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction 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.AccountOperationRestrictionTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperVertxTest method shouldCreateAccountOperationRestriction.
@Test
public void shouldCreateAccountOperationRestriction() throws Exception {
TransactionInfoDTO transactionInfoDTO = TestHelperVertx.loadTransactionInfoDTO("accountOperationRestrictionTransaction.json");
AccountOperationRestrictionTransaction transaction = (AccountOperationRestrictionTransaction) map(transactionInfoDTO);
validateStandaloneTransaction(transaction, transactionInfoDTO);
Assertions.assertEquals(AccountOperationRestrictionFlags.ALLOW_OUTGOING_TRANSACTION_TYPE, transaction.getRestrictionFlags());
Assertions.assertEquals(1, transaction.getRestrictionAdditions().size());
Assertions.assertEquals(TransactionType.MOSAIC_METADATA, transaction.getRestrictionAdditions().get(0));
}
use of io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method shouldCreateAccountOperationRestriction.
@Test
public void shouldCreateAccountOperationRestriction() throws Exception {
TransactionInfoDTO transactionInfoDTO = TestHelperOkHttp.loadTransactionInfoDTO("accountOperationRestrictionTransaction.json");
AccountOperationRestrictionTransaction transaction = (AccountOperationRestrictionTransaction) map(transactionInfoDTO);
validateStandaloneTransaction(transaction, transactionInfoDTO);
Assertions.assertEquals(AccountOperationRestrictionFlags.ALLOW_OUTGOING_TRANSACTION_TYPE, transaction.getRestrictionFlags());
Assertions.assertEquals(1, transaction.getRestrictionAdditions().size());
Assertions.assertEquals(TransactionType.MOSAIC_METADATA, transaction.getRestrictionAdditions().get(0));
}
Aggregations