Search in sources :

Example 6 with TransactionAnnounceResponse

use of io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse in project nem2-sdk-java by nemtech.

the class TransactionRepositoryVertxImplTest method shouldAnnounce.

@Test
public void shouldAnnounce() throws Exception {
    SignedTransaction signedTransaction = getSignedTransaction();
    AnnounceTransactionInfoDTO announceTransactionInfoDTO = new AnnounceTransactionInfoDTO();
    announceTransactionInfoDTO.setMessage("SomeMessage");
    mockRemoteCall(announceTransactionInfoDTO);
    TransactionAnnounceResponse response = repository.announce(signedTransaction).toFuture().get();
    Assertions.assertNotNull(response);
    Assertions.assertEquals(announceTransactionInfoDTO.getMessage(), announceTransactionInfoDTO.getMessage());
}
Also used : AnnounceTransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO) TransactionAnnounceResponse(io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) Test(org.junit.jupiter.api.Test)

Example 7 with TransactionAnnounceResponse

use of io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse in project nem2-sdk-java by nemtech.

the class TransactionRepositoryVertxImplTest method shouldAnnounceAggregateBonded.

@Test
public void shouldAnnounceAggregateBonded() throws Exception {
    SignedTransaction signedTransaction = getSignedTransaction();
    AnnounceTransactionInfoDTO announceTransactionInfoDTO = new AnnounceTransactionInfoDTO();
    announceTransactionInfoDTO.setMessage("SomeMessage");
    mockRemoteCall(announceTransactionInfoDTO);
    TransactionAnnounceResponse response = repository.announceAggregateBonded(signedTransaction).toFuture().get();
    Assertions.assertNotNull(response);
    Assertions.assertEquals(announceTransactionInfoDTO.getMessage(), announceTransactionInfoDTO.getMessage());
}
Also used : AnnounceTransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO) TransactionAnnounceResponse(io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) Test(org.junit.jupiter.api.Test)

Example 8 with TransactionAnnounceResponse

use of io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse in project nem2-sdk-java by nemtech.

the class TransactionServiceTest method announceAggregateBonded.

@Test
void announceAggregateBonded() throws ExecutionException, InterruptedException {
    TransferTransaction transaction1 = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Address.generateRandom(networkType), Arrays.asList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100)))).message(new PlainMessage("Some Message")).signer(account.getPublicAccount()).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.create(TransactionType.AGGREGATE_BONDED, networkType, new Deadline(BigInteger.ONE), Collections.singletonList(transaction1), Collections.emptyList()).build();
    String generationHash = "abc";
    SignedTransaction aggregateSignedTransaction = aggregateTransaction.signWith(account, generationHash);
    TransactionAnnounceResponse aggregateTransactionAnnounceResponse = new TransactionAnnounceResponse("Aggregate Some Message");
    Mockito.when(transactionRepositoryMock.announceAggregateBonded(Mockito.eq(aggregateSignedTransaction))).thenReturn(Observable.just(aggregateTransactionAnnounceResponse));
    Mockito.when(listener.aggregateBondedAddedOrError(Mockito.eq(account.getAddress()), Mockito.eq(aggregateSignedTransaction.getHash()))).thenReturn(Observable.just(aggregateTransaction));
    Observable<AggregateTransaction> announcedTransaction = service.announceAggregateBonded(listener, aggregateSignedTransaction);
    Assertions.assertEquals(aggregateTransaction, announcedTransaction.toFuture().get());
}
Also used : PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) BigInteger(java.math.BigInteger) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionAnnounceResponse(io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) Test(org.junit.jupiter.api.Test)

Example 9 with TransactionAnnounceResponse

use of io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse in project nem2-sdk-java by nemtech.

the class TransactionServiceTest method announceHashLockAggregateBonded.

@Test
void announceHashLockAggregateBonded() throws ExecutionException, InterruptedException {
    TransferTransaction transaction1 = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Address.generateRandom(networkType), Collections.singletonList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100)))).message(new PlainMessage("Some Message")).signer(account.getPublicAccount()).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.create(TransactionType.AGGREGATE_BONDED, networkType, new Deadline(BigInteger.ONE), Collections.singletonList(transaction1), Collections.emptyList()).build();
    String generationHash = "abc";
    SignedTransaction aggregateSignedTransaction = aggregateTransaction.signWith(account, generationHash);
    HashLockTransaction hashLockTransaction = HashLockTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Currency.CAT_CURRENCY.createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), aggregateSignedTransaction.getHash()).build();
    SignedTransaction hashLockSignedTranscation = hashLockTransaction.signWith(account, generationHash);
    TransactionAnnounceResponse aggregateTransactionAnnounceResponse = new TransactionAnnounceResponse("Aggregate Some Message");
    TransactionAnnounceResponse hashTransactionAnnounceResponse = new TransactionAnnounceResponse("Hash Some Message");
    Mockito.when(transactionRepositoryMock.announceAggregateBonded(Mockito.eq(aggregateSignedTransaction))).thenReturn(Observable.just(aggregateTransactionAnnounceResponse));
    Mockito.when(transactionRepositoryMock.announce(Mockito.eq(hashLockSignedTranscation))).thenReturn(Observable.just(hashTransactionAnnounceResponse));
    Mockito.when(listener.confirmedOrError(Mockito.eq(account.getAddress()), Mockito.eq(hashLockSignedTranscation.getHash()))).thenReturn(Observable.just(hashLockTransaction));
    Mockito.when(listener.aggregateBondedAddedOrError(Mockito.eq(account.getAddress()), Mockito.eq(aggregateSignedTransaction.getHash()))).thenReturn(Observable.just(aggregateTransaction));
    Observable<AggregateTransaction> announcedTransaction = service.announceHashLockAggregateBonded(listener, hashLockSignedTranscation, aggregateSignedTransaction);
    Assertions.assertEquals(aggregateTransaction, announcedTransaction.toFuture().get());
}
Also used : HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) BigInteger(java.math.BigInteger) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionAnnounceResponse(io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionAnnounceResponse (io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse)9 Test (org.junit.jupiter.api.Test)9 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)7 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)6 BigInteger (java.math.BigInteger)4 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)3 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)3 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)3 AnnounceTransactionInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.AnnounceTransactionInfoDTO)3 AnnounceTransactionInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO)3 Account (io.nem.symbol.sdk.model.account.Account)2 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)2 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)2 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)2 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)2 AggregateTransactionCosignature (io.nem.symbol.sdk.model.transaction.AggregateTransactionCosignature)2 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)2 AccountAddressRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction)1 AccountMosaicRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction)1 MosaicAddressRestrictionTransaction (io.nem.symbol.sdk.model.transaction.MosaicAddressRestrictionTransaction)1