Search in sources :

Example 1 with AccountOperationRestrictionTransaction

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());
}
Also used : TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)

Example 2 with AccountOperationRestrictionTransaction

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());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AccountAddressRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) AccountRestrictions(io.nem.symbol.sdk.model.account.AccountRestrictions) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with AccountOperationRestrictionTransaction

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));
}
Also used : TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) Test(org.junit.jupiter.api.Test)

Example 4 with AccountOperationRestrictionTransaction

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));
}
Also used : TransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) Test(org.junit.jupiter.api.Test)

Aggregations

AccountOperationRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)4 Test (org.junit.jupiter.api.Test)2 Account (io.nem.symbol.sdk.model.account.Account)1 AccountRestrictions (io.nem.symbol.sdk.model.account.AccountRestrictions)1 AccountAddressRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction)1 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)1 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)1 TransactionInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO)1 TransactionInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1