Search in sources :

Example 1 with AccountAddressRestrictionTransaction

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());
}
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 2 with AccountAddressRestrictionTransaction

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

Example 3 with AccountAddressRestrictionTransaction

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

Example 4 with AccountAddressRestrictionTransaction

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

Example 5 with AccountAddressRestrictionTransaction

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

Aggregations

AccountAddressRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction)5 Test (org.junit.jupiter.api.Test)3 Account (io.nem.symbol.sdk.model.account.Account)1 AccountRestrictions (io.nem.symbol.sdk.model.account.AccountRestrictions)1 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)1 AccountOperationRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)1 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)1 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)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