use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class MosaicRepositoryOkHttpImplTest method shouldGetMosaicsFromAccount.
@Test
public void shouldGetMosaicsFromAccount() throws Exception {
PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
MosaicId mosaicId = MapperUtils.toMosaicId("481110499AAA");
Address ownerAddress = Account.generateNewAccount(networkType).getAddress();
MosaicDTO mosaicDto = new MosaicDTO();
mosaicDto.setOwnerAddress(ownerAddress.encoded());
mosaicDto.setId("481110499AAA");
mosaicDto.setRevision(123L);
mosaicDto.setFlags(5);
mosaicDto.setDivisibility(6);
mosaicDto.setDuration(BigInteger.valueOf(7));
mosaicDto.supply(BigInteger.valueOf(1000));
mosaicDto.startHeight(BigInteger.valueOf(100));
mosaicDto.setVersion(1);
mockRemoteCall(toPage(new MosaicInfoDTO().mosaic(mosaicDto).id("ABC")));
List<MosaicInfo> resolvedList = repository.search(new MosaicSearchCriteria().ownerAddress(publicAccount.getAddress())).toFuture().get().getData();
Assertions.assertEquals(1, resolvedList.size());
MosaicInfo mosaicInfo = resolvedList.get(0);
Assertions.assertEquals(mosaicId, mosaicInfo.getMosaicId());
Assertions.assertEquals(mosaicDto.getRevision(), mosaicInfo.getRevision());
Assertions.assertEquals(mosaicDto.getOwnerAddress(), mosaicInfo.getOwnerAddress().encoded(networkType));
Assertions.assertFalse(mosaicInfo.isTransferable());
Assertions.assertEquals(6, mosaicInfo.getDivisibility());
Assertions.assertEquals(BigInteger.valueOf(7), mosaicInfo.getDuration());
Assertions.assertEquals(mosaicDto.getStartHeight(), mosaicInfo.getStartHeight());
Assertions.assertEquals(mosaicDto.getSupply(), mosaicInfo.getSupply());
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method unconfirmedTransactions.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void unconfirmedTransactions(RepositoryType type) {
Account testAccount = this.config().getDefaultAccount();
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
PublicAccount publicAccount = this.helper().getTestAccount(type).getLeft().getPublicAccount();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.UNCONFIRMED).signerPublicKey(publicAccount.getPublicKey()))).getData();
System.out.println(transactions.size());
transactions.forEach(transaction -> assertTransaction(transaction, testAccount.getAddress()));
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class TransactionRepositoryVertxImplTest method searchTransactionsPartial.
@Test
public void searchTransactionsPartial() throws Exception {
TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json");
PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
mockRemoteCall(toPage(transferTransactionDTO));
Page<Transaction> transactions = repository.search(new TransactionSearchCriteria(TransactionGroup.PARTIAL).signerPublicKey(publicAccount.getPublicKey())).toFuture().get();
Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
Assertions.assertEquals(TransactionGroup.PARTIAL, transactions.getData().get(0).getGroup().get());
Assertions.assertEquals(1, transactions.getData().size());
Assertions.assertEquals(1, transactions.getPageNumber());
Assertions.assertEquals(2, transactions.getPageSize());
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class VertxAggregateTransactionTest method createAAggregateTransactionViaStaticConstructor.
@Test
void createAAggregateTransactionViaStaticConstructor() {
Duration epochAdjustment = Duration.ofSeconds(100);
Address recipient = Address.generateRandom(networkType);
Deadline deadline = Deadline.create(epochAdjustment);
TransferTransaction transferTx = TransferTransactionFactory.create(networkType, deadline, recipient, Collections.emptyList()).message(new PlainMessage("")).build();
AggregateTransaction aggregateTx = AggregateTransactionFactory.createComplete(networkType, deadline, Collections.singletonList(transferTx.toAggregate(new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", networkType)))).build();
assertEquals(networkType, aggregateTx.getNetworkType());
assertEquals(1, (int) aggregateTx.getVersion());
assertTrue(LocalDateTime.now().isBefore(aggregateTx.getDeadline().getLocalDateTime(epochAdjustment)));
assertEquals(BigInteger.valueOf(0), aggregateTx.getMaxFee());
assertEquals(1, aggregateTx.getInnerTransactions().size());
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class SecretProofTransactionTest method toAggregate.
@Test
@DisplayName("To aggregate")
void toAggregate() {
String expected = "6F000000000000009A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B2400000000019052429022D04812D05000F96C283657B0C17990932BC84926CDE63FC8BA10229AB5778D05D9C4B7F56676A88BF9295C185ACFC0F961DB5408CAFE0400009A493664";
String secret = "3fc8ba10229ab5778d05d9c4b7f56676a88bf9295c185acfc0f961db5408cafe";
String proof = "9a493664";
SecretProofTransaction transaction = SecretProofTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), LockHashAlgorithm.SHA3_256, recipient, secret, proof).build();
transaction.toAggregate(new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", NetworkType.MIJIN_TEST));
assertEmbeddedSerialization(expected, transaction);
}
Aggregations