Search in sources :

Example 41 with Deadline

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

the class TransactionServiceTest method mosaicGlobalRestrictionTransactionResolveAlias.

@Test
void mosaicGlobalRestrictionTransactionResolveAlias() throws ExecutionException, InterruptedException {
    String transactionHash = "aaaa";
    MosaicGlobalRestrictionTransactionFactory mosaicGlobalRestrictionTransactionFactory = MosaicGlobalRestrictionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), mosaicNamespace2, BigInteger.TEN, BigInteger.ONE, MosaicRestrictionType.GT);
    mosaicGlobalRestrictionTransactionFactory.referenceMosaicId(mosaicNamespace3);
    mosaicGlobalRestrictionTransactionFactory.previousRestrictionType(MosaicRestrictionType.EQ);
    mosaicGlobalRestrictionTransactionFactory.previousRestrictionValue(BigInteger.valueOf(3));
    TransactionFactory<MosaicGlobalRestrictionTransaction> factory = mosaicGlobalRestrictionTransactionFactory.transactionInfo(TransactionInfo.create(height, 0, "ABC", transactionHash, ""));
    MosaicGlobalRestrictionTransaction transaction = factory.build();
    simulateStatement(height, 1, 0);
    List<String> hashes = Collections.singletonList(transactionHash);
    Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
    MosaicGlobalRestrictionTransaction resolvedTransaction = (MosaicGlobalRestrictionTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
    Assertions.assertEquals(mosaicId2, resolvedTransaction.getMosaicId());
    Assertions.assertEquals(mosaicId3, resolvedTransaction.getReferenceMosaicId());
}
Also used : MosaicGlobalRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransactionFactory) MosaicGlobalRestrictionTransaction(io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransaction) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) Test(org.junit.jupiter.api.Test)

Example 42 with Deadline

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

the class TransactionServiceTest method accountAddressRestrictionTransactionResolveAlias.

@Test
void accountAddressRestrictionTransactionResolveAlias() throws ExecutionException, InterruptedException {
    String transactionHash = "aaaa";
    TransactionFactory<AccountAddressRestrictionTransaction> factory = AccountAddressRestrictionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), AccountAddressRestrictionFlags.ALLOW_INCOMING_ADDRESS, Arrays.asList(addressNamespace1, address2, addressNamespace2), Arrays.asList(addressNamespace2, addressNamespace3, address3)).transactionInfo(TransactionInfo.create(height, 4, "ABC", transactionHash, ""));
    AccountAddressRestrictionTransaction transaction = factory.build();
    simulateStatement(height, 5, 0);
    List<String> hashes = Collections.singletonList(transactionHash);
    Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
    AccountAddressRestrictionTransaction resolvedTransaction = (AccountAddressRestrictionTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
    Assertions.assertEquals(Arrays.asList(address1, address2, address2), resolvedTransaction.getRestrictionAdditions());
    Assertions.assertEquals(Arrays.asList(address2, address3, address3), resolvedTransaction.getRestrictionDeletions());
}
Also used : Deadline(io.nem.symbol.sdk.model.transaction.Deadline) AccountAddressRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction) Test(org.junit.jupiter.api.Test)

Example 43 with Deadline

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

the class TransactionServiceTest method secretLockTransactionResolveAlias.

@Test
void secretLockTransactionResolveAlias() throws ExecutionException, InterruptedException {
    Mosaic unresolvedMosaicId = new Mosaic(mosaicNamespace2, BigInteger.valueOf(2));
    UnresolvedAddress recipient = addressNamespace1;
    String transactionHash = "aaaa";
    String secret = "3fc8ba10229ab5778d05d9c4b7f56676a88bf9295c185acfc0f961db5408cafe";
    TransactionFactory<SecretLockTransaction> factory = SecretLockTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), unresolvedMosaicId, BigInteger.TEN, LockHashAlgorithm.SHA3_256, secret, recipient).transactionInfo(TransactionInfo.create(height, 0, "ABC", transactionHash, ""));
    simulateStatement(height, 1, 0);
    SecretLockTransaction transaction = factory.build();
    List<String> hashes = Collections.singletonList(transactionHash);
    Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
    SecretLockTransaction resolvedTransaction = (SecretLockTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
    Assertions.assertEquals(mosaicId2, resolvedTransaction.getMosaic().getId());
    Assertions.assertEquals(address1, resolvedTransaction.getRecipient());
}
Also used : UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) Test(org.junit.jupiter.api.Test)

Example 44 with Deadline

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

the class TransactionServiceTest method mosaicSupplyChangeTransactionResolveAlias.

@Test
void mosaicSupplyChangeTransactionResolveAlias() throws ExecutionException, InterruptedException {
    String transactionHash = "aaaa";
    TransactionFactory<MosaicSupplyChangeTransaction> factory = MosaicSupplyChangeTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), mosaicNamespace2, MosaicSupplyChangeActionType.INCREASE, BigInteger.ONE).transactionInfo(TransactionInfo.create(height, 4, "ABC", transactionHash, ""));
    MosaicSupplyChangeTransaction transaction = factory.build();
    simulateStatement(height, 5, 0);
    List<String> hashes = Collections.singletonList(transactionHash);
    Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
    MosaicSupplyChangeTransaction resolvedTransaction = (MosaicSupplyChangeTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
    Assertions.assertEquals(mosaicId2, resolvedTransaction.getMosaicId());
}
Also used : MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) Test(org.junit.jupiter.api.Test)

Example 45 with Deadline

use of io.nem.symbol.sdk.model.transaction.Deadline 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)

Aggregations

Deadline (io.nem.symbol.sdk.model.transaction.Deadline)49 Test (org.junit.jupiter.api.Test)38 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)28 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)23 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)22 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)19 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)14 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)9 NetworkType (io.nem.symbol.sdk.model.network.NetworkType)9 BigInteger (java.math.BigInteger)8 ArrayList (java.util.ArrayList)6 Address (io.nem.symbol.sdk.model.account.Address)5 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)5 Account (io.nem.symbol.sdk.model.account.Account)4 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)4 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)4 Duration (java.time.Duration)4 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)3 TransactionAnnounceResponse (io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse)3 BinarySerialization (io.nem.symbol.sdk.api.BinarySerialization)2