use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnConfirmedTransactionAddressSignerViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnConfirmedTransactionAddressSignerViaListener(RepositoryType type) {
Listener listener = getListener(type);
SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
Observable<Transaction> confirmed = listener.confirmed(this.account.getAddress(), signedTransaction.getHash());
Transaction transaction = get(confirmed.take(1));
assertEquals(signedTransaction.getHash(), transaction.getTransactionInfo().get().getHash().get());
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldConnectToWebSocket.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldConnectToWebSocket(RepositoryType type) throws ExecutionException, InterruptedException {
Listener listener = getRepositoryFactory(type).createListener();
CompletableFuture<Void> connected = listener.open();
connected.get();
assertTrue(connected.isDone());
assertNotNull(listener.getUid());
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerForTests method run.
private void run() throws ExecutionException, InterruptedException {
Listener listener = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE).createListener();
listener.open().get();
listener.newBlock().subscribe(b -> {
System.out.println("New BLOCK!! " + b.getHeight());
});
listener.finalizedBlock().subscribe(b -> {
System.out.println("New Finalized Block!! " + b.getHeight());
});
listenToAccount("Test Account 1", config().getTestAccount().getAddress(), listener);
listenToAccount("Test Account 2", config().getTestAccount2().getAddress(), listener);
listenToAccount("Cosignatory Account", config().getCosignatoryAccount().getAddress(), listener);
listenToAccount("Cosignatory Account 2", config().getCosignatory2Account().getAddress(), listener);
listenToAccount("Multisign Account 2", config().getMultisigAccount().getAddress(), listener);
config().getNemesisAccounts().forEach(account -> listenToAccount("Nemesis Account", account.getAddress(), listener));
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerStatusIntegrationTest method sendTransactionsReusingListener.
@Test
void sendTransactionsReusingListener() throws ExecutionException, InterruptedException {
RepositoryType type = DEFAULT_REPOSITORY_TYPE;
Account account1 = config().getNemesisAccount1();
Account account2 = Account.generateNewAccount(getNetworkType());
Account account3 = Account.generateNewAccount(getNetworkType());
Listener listener = createListener(type);
listener.unconfirmedRemoved(account1.getAddress()).subscribe(a -> {
System.out.println(">>>> account 1 " + a);
});
listener.unconfirmedRemoved(account2.getAddress()).subscribe(a -> {
System.out.println(">>>> account 2 " + a);
});
listener.unconfirmedRemoved(account3.getAddress()).subscribe(a -> {
System.out.println(">>>> account 3 " + a);
});
// IT PRINTS:
// >>>> account 1
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 2
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 3
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 1
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 2
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 3
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), account2.getAddress(), Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("test-message")).maxFee(maxFee).build();
announceAndValidate(type, account1, transferTransaction);
sleep(1000);
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnAggregateBondedAddedTransactionViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnAggregateBondedAddedTransactionViaListener(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();
System.out.println("Announcing Aggregate transaction " + signedTransaction.getHash());
AggregateTransaction aggregateTransaction = get(transactionService.announceAggregateBonded(listener, signedTransaction).take(1));
assertEquals(signedTransaction.getHash(), aggregateTransaction.getTransactionInfo().get().getHash().get());
}
Aggregations