use of io.nem.symbol.sdk.model.message.PlainMessage 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.model.message.PlainMessage in project nem2-sdk-java by nemtech.
the class OkHttpAggregateTransactionTest method shouldCreateAggregateTransactionAndSignWithMultipleCosignatories.
@Test
void shouldCreateAggregateTransactionAndSignWithMultipleCosignatories() {
Address address = Address.generateRandom(networkType);
TransferTransaction transferTx = TransferTransactionFactory.create(networkType, deadline, address, Collections.emptyList()).message(new PlainMessage("test-message")).build();
AggregateTransaction aggregateTx = AggregateTransactionFactory.createComplete(networkType, deadline, Collections.singletonList(transferTx.toAggregate(new PublicAccount("B694186EE4AB0558CA4AFCFDD43B42114AE71094F5A1FC4A913FE9971CACD21D", networkType)))).build();
Account cosignatoryAccount = Account.generateNewAccount(this.networkType);
Account cosignatoryAccount2 = Account.generateNewAccount(this.networkType);
Account cosignatoryAccount3 = Account.generateNewAccount(this.networkType);
SignedTransaction signedTransaction = cosignatoryAccount.signTransactionWithCosignatories(aggregateTx, Arrays.asList(cosignatoryAccount2, cosignatoryAccount3), generationHash);
BinarySerialization serialization = BinarySerializationImpl.INSTANCE;
AggregateTransaction deserialized = (AggregateTransaction) serialization.deserialize(ConvertUtils.fromHexToBytes(signedTransaction.getPayload()));
Assertions.assertEquals(2, deserialized.getCosignatures().size());
Assertions.assertEquals(cosignatoryAccount2.getPublicAccount(), deserialized.getCosignatures().get(0).getSigner());
Assertions.assertEquals(cosignatoryAccount3.getPublicAccount(), deserialized.getCosignatures().get(1).getSigner());
}
use of io.nem.symbol.sdk.model.message.PlainMessage in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceIntegrationTest method isTransferFromMultisigNotComplete.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void isTransferFromMultisigNotComplete(RepositoryType type) {
Account multisigAccount = helper().getMultisigAccount(type).getLeft();
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), getRecipient(), Collections.emptyList()).message(new PlainMessage("")).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(transferTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Collections.singletonList(config().getTestAccount()), getGenerationHash());
AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
Assertions.assertFalse(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
use of io.nem.symbol.sdk.model.message.PlainMessage in project nem2-sdk-java by nemtech.
the class HashLockTransactionIntegrationTest method standaloneLockFundsTransaction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void standaloneLockFundsTransaction(RepositoryType type) {
BigInteger duration = BigInteger.valueOf(10000);
TransferTransactionFactory factory = TransferTransactionFactory.create(getNetworkType(), getDeadline(), account.getAddress(), Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("E2ETest:standaloneLockFundsTransaction"));
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createBonded(getNetworkType(), getDeadline(), Collections.singletonList(factory.build().toAggregate(account.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedTransaction = this.account.sign(aggregateTransaction, getGenerationHash());
HashLockTransaction hashLockTransaction = HashLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.valueOf(10)), duration, signedTransaction).maxFee(maxFee).build();
announceAndValidate(type, this.account, hashLockTransaction);
announceAndValidate(type, this.account, aggregateTransaction);
}
use of io.nem.symbol.sdk.model.message.PlainMessage in project nem2-sdk-java by nemtech.
the class HashLockTransactionIntegrationTest method aggregateLockFundsTransaction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateLockFundsTransaction(RepositoryType type) {
BigInteger duration = BigInteger.valueOf(1000);
TransferTransactionFactory factory = TransferTransactionFactory.create(getNetworkType(), getDeadline(), this.account.getAddress(), Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("E2ETest:standaloneLockFundsTransaction"));
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createBonded(getNetworkType(), getDeadline(), Collections.singletonList(factory.build().toAggregate(account.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedTransaction = this.account.sign(aggregateTransaction, getGenerationHash());
HashLockTransaction hashLockTransaction = HashLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.valueOf(10)), duration, signedTransaction).maxFee(maxFee).build();
announceAggregateAndValidate(type, hashLockTransaction, this.account);
announceAndValidate(type, this.account, aggregateTransaction);
}
Aggregations