use of io.nem.symbol.sdk.model.message.PlainMessage 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);
}
use of io.nem.symbol.sdk.model.message.PlainMessage 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);
}
use of io.nem.symbol.sdk.model.message.PlainMessage 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());
}
use of io.nem.symbol.sdk.model.message.PlainMessage 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);
}
use of io.nem.symbol.sdk.model.message.PlainMessage in project nem2-sdk-java by nemtech.
the class TransferTransactionTest method mosaicArrayToBeSorted.
@Test
void mosaicArrayToBeSorted() {
ArrayList<Mosaic> mosaics = new ArrayList<>();
mosaics.add(new Mosaic(new MosaicId(new BigInteger("200")), BigInteger.valueOf(1)));
mosaics.add(new Mosaic(new MosaicId(new BigInteger("100")), BigInteger.valueOf(2)));
TransferTransaction transaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), new Address("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ", networkType), mosaics).message(new PlainMessage("")).build();
assertEquals(mosaics.get(0).getId().getIdAsLong(), new BigInteger("200").longValue());
assertEquals(mosaics.get(1).getId().getIdAsLong(), new BigInteger("100").longValue());
TransferTransaction deserialized = (TransferTransaction) new BinarySerializationImpl().deserialize(transaction.serialize());
assertEquals(mosaics.get(1).getId(), deserialized.getMosaics().get(0).getId());
assertEquals(mosaics.get(0).getId(), deserialized.getMosaics().get(1).getId());
}
Aggregations