Search in sources :

Example 16 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class TransactionTest method generateHashFromTransferTransactionPayload.

@Test
void generateHashFromTransferTransactionPayload() {
    TransferTransactionFactory factory = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), new Address("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ", networkType), Collections.emptyList()).message(new PlainMessage(""));
    TransferTransaction transaction = factory.build();
    String hash = transaction.createTransactionHash("C7000000D0B190DFEEAB0378F943F79CDB7BC44453491890FAA70F5AA95B909E67487408407956BDE32AC977D035FBBA575C11AA034B23402066C16FD6126893F3661B099A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24039054410000000000000000A76541BE0C00000090E8FEBD671DD41BEE94EC3BA5831CB608A312C2F203BA84AC03000300303064000000000000006400000000000000002F00FA0DEDD9086400000000000000443F6D806C05543A6400000000000000", generationHash.getBytes());
    assertEquals("820C535E7998AEE4255677A9C53566190225C02D99558AC48192171EC8144B43", hash);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Test(org.junit.jupiter.api.Test)

Example 17 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class TransferTransactionTest method shouldGenerateBytes.

@Test
void shouldGenerateBytes() {
    String expected = "B10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000019054410000000000000000010000000000000090F36CA680C35D630662A0C38DC89D4978D10B511B3D241A0100010000000000672B0000CE560000640000000000000000";
    TransferTransaction transaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), new Address("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ", networkType), Collections.singletonList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100)))).message(new PlainMessage("")).build();
    assertSerialization(expected, transaction);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BigInteger(java.math.BigInteger) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) Test(org.junit.jupiter.api.Test)

Example 18 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class TransferTransactionTest method createATransferTransactionViaStaticConstructor.

@Test
void createATransferTransactionViaStaticConstructor() {
    Duration epochAdjustment = Duration.ofSeconds(100);
    Address address = Address.generateRandom(networkType);
    Deadline originalDeadline = new Deadline(BigInteger.ONE);
    TransferTransactionFactory factory = TransferTransactionFactory.create(networkType, originalDeadline, address, Collections.emptyList()).message(new PlainMessage(""));
    Assertions.assertEquals(originalDeadline, factory.getDeadline());
    Deadline updatedDeadline = Deadline.create(epochAdjustment);
    factory.deadline(updatedDeadline);
    Assertions.assertEquals(updatedDeadline, factory.getDeadline());
    TransferTransaction transaction = factory.build();
    assertEquals(networkType, transaction.getNetworkType());
    assertEquals(1, (int) transaction.getVersion());
    assertTrue(LocalDateTime.now().isBefore(transaction.getDeadline().getLocalDateTime(epochAdjustment)));
    assertEquals(BigInteger.valueOf(0), transaction.getMaxFee());
    assertEquals(address, transaction.getRecipient());
    assertEquals(0, transaction.getMosaics().size());
    assertNotNull(transaction.getMessage());
    assertEquals(161, factory.getSize());
    assertEquals(transaction.getSize(), factory.getSize());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Duration(java.time.Duration) Test(org.junit.jupiter.api.Test)

Example 19 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class TransferTransactionTest method shouldGenerateBytesNoMessage.

@Test
void shouldGenerateBytesNoMessage() {
    String expected = "B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000019054410000000000000000010000000000000090F36CA680C35D630662A0C38DC89D4978D10B511B3D241A0000010000000000672B0000CE5600006400000000000000";
    TransferTransaction transaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), new Address("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ", networkType), Collections.singletonList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100)))).build();
    assertSerialization(expected, transaction);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BigInteger(java.math.BigInteger) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) Test(org.junit.jupiter.api.Test)

Example 20 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class TransferTransactionTest method toAggregate.

@Test
@DisplayName("To aggregate")
void toAggregate() {
    String expected = "61000000000000009A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24000000000190544190F36CA680C35D630662A0C38DC89D4978D10B511B3D241A0100010000000000672B0000CE560000640000000000000000";
    TransferTransaction transaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), new Address("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ", networkType), Collections.singletonList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100)))).message(new PlainMessage("")).build();
    Transaction aggregateTransaction = transaction.toAggregate(new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", networkType));
    assertEmbeddedSerialization(expected, aggregateTransaction);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) BigInteger(java.math.BigInteger) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Address (io.nem.symbol.sdk.model.account.Address)172 Test (org.junit.jupiter.api.Test)124 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)53 BigInteger (java.math.BigInteger)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 ArrayList (java.util.ArrayList)28 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)27 EnumSource (org.junit.jupiter.params.provider.EnumSource)26 Account (io.nem.symbol.sdk.model.account.Account)20 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)19 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)19 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)16 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)16 ListenerSubscribeMessage (io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage)15 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)14 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)13 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)13 Observable (io.reactivex.Observable)13 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)12 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)10