use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnUnconfirmedRemovedTransactionViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnUnconfirmedRemovedTransactionViaListener(RepositoryType type) {
Listener listener = getListener(type);
SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
String transactionHash = get(listener.unconfirmedRemoved(this.account.getAddress()).take(1));
assertEquals(signedTransaction.getHash(), transactionHash);
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method getAllMultisigAddressesAndAliasesWhenMultisig.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAllMultisigAddressesAndAliasesWhenMultisig(RepositoryType type) {
final MultisigAccountInfo multisigAccountInfo = get(getRepositoryFactory(type).createMultisigRepository().getMultisigAccountInfo(this.multisigAccount.getAddress()));
Assertions.assertEquals(Arrays.asList(this.cosignatoryAccount.getAddress(), this.cosignatoryAccount2.getAddress()), multisigAccountInfo.getCosignatoryAddresses());
Set<NamespaceId> aliases = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Arrays.asList(multisigAccount.getAddress(), cosignatoryAccount.getAddress(), cosignatoryAccount2.getAddress()))).stream().flatMap(a -> a.getNames().stream().map(n -> n.getNamespaceId())).collect(Collectors.toSet());
Listener listener = getRepositoryFactory(type).createListener();
final Set<UnresolvedAddress> unresolvedAddresses = get(listener.getAllMultisigAddressesAndAliases(this.multisigAccount.getAddress()));
final Set<UnresolvedAddress> expectedAddresees = Sets.newSet(this.multisigAccount.getAddress(), this.cosignatoryAccount.getAddress(), this.cosignatoryAccount2.getAddress());
expectedAddresees.addAll(aliases);
Assertions.assertEquals(expectedAddresees, unresolvedAddresses);
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnTransactionStatusGivenAddedViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnTransactionStatusGivenAddedViaListener(RepositoryType type) {
Listener listener = getListener(type);
SignedTransaction signedTransaction = this.announceStandaloneTransferTransactionWithInsufficientBalance(type);
TransactionStatusError transactionHash = get(listener.status(this.account.getAddress(), signedTransaction.getHash()).take(1));
assertEquals(signedTransaction.getHash(), transactionHash.getHash());
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnFinalizedBlock.
@ParameterizedTest
@EnumSource(RepositoryType.class)
@Disabled
void shouldReturnFinalizedBlock(RepositoryType type) {
Listener listener = getListener(type);
FinalizedBlock finalizedBlock1 = get(listener.finalizedBlock().take(1));
FinalizedBlock finalizedBlock2 = get(getRepositoryFactory(type).createChainRepository().getChainInfo()).getLatestFinalizedBlock();
assertTrue(finalizedBlock1.getHeight().intValue() > 0);
assertEquals(finalizedBlock1, finalizedBlock2);
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnCosignatureAddedViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
@Disabled
void shouldReturnCosignatureAddedViaListener(RepositoryType type) {
Listener listener = getListener(type);
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
TransactionService transactionService = new TransactionServiceImpl(repositoryFactory);
Pair<SignedTransaction, SignedTransaction> pair = this.createAggregateBondedTransaction(type);
System.out.println("Announcing HashLock transaction " + pair.getRight().getHash());
get(transactionService.announce(listener, pair.getRight()));
SignedTransaction signedTransaction = pair.getLeft();
AggregateTransaction announcedTransaction = get(transactionService.announceAggregateBonded(listener, signedTransaction));
assertEquals(signedTransaction.getHash(), announcedTransaction.getTransactionInfo().get().getHash().get());
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(TransactionType.AGGREGATE_BONDED)).signerPublicKey(this.cosignatoryAccount.getPublicAccount().getPublicKey()))).getData();
AggregateTransaction transactionToCosign = (AggregateTransaction) transactions.get(0);
this.announceCosignatureTransaction(transactionToCosign, type);
CosignatureSignedTransaction cosignatureSignedTransaction = get(listener.cosignatureAdded(this.cosignatoryAccount.getAddress()).take(1));
assertEquals(cosignatureSignedTransaction.getSigner(), this.cosignatoryAccount2.getPublicAccount());
}
Aggregations