use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicAddressRestrictionTransactionTest method serialize.
@Test
void serialize() {
MosaicAddressRestrictionTransaction transaction = MosaicAddressRestrictionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), // restricted
new MosaicId(new BigInteger("1")), // restrictionKey
BigInteger.valueOf(1), // targetAddress
account.getAddress(), // newRestrictionValue
BigInteger.valueOf(8)).previousRestrictionValue(BigInteger.valueOf(9)).signer(account.getPublicAccount()).build();
String expected = "B800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009801508C58666C746F471538E43002B85B1CD542F9874B2861183919BA8787B6000000000190514200000000000000000100000000000000010000000000000001000000000000000900000000000000080000000000000090D66C33420E5411995BACFCA2B28CF1C9F5DD7AB1204EA4";
assertSerialization(expected, transaction);
String expectedEmbeddedHash = "68000000000000009801508C58666C746F471538E43002B85B1CD542F9874B2861183919BA8787B60000000001905142010000000000000001000000000000000900000000000000080000000000000090D66C33420E5411995BACFCA2B28CF1C9F5DD7AB1204EA4";
assertEmbeddedSerialization(expectedEmbeddedHash, transaction);
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicAddressRestrictionTransactionTest method serializeAndSignTransaction.
@Test
void serializeAndSignTransaction() {
MosaicAddressRestrictionTransaction transaction = MosaicAddressRestrictionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), // restricted
new MosaicId(new BigInteger("1")), // restrictionKey
BigInteger.valueOf(1), // targetAddress
account.getAddress(), // newRestrictionValue
BigInteger.valueOf(8)).previousRestrictionValue(BigInteger.valueOf(9)).build();
SignedTransaction signedTransaction = transaction.signWith(account, generationHash);
assertEquals("B8000000000000006EFCD6CE2F8C961035F6BBA96EB2A8BA6B3C652A71A735E1E5ED7145B2947F2F1A9A0FDFC1BFA067744D8A3E8CB0B35394C16B37B24DE337A4B26173609DB2049801508C58666C746F471538E43002B85B1CD542F9874B2861183919BA8787B6000000000190514200000000000000000100000000000000010000000000000001000000000000000900000000000000080000000000000090D66C33420E5411995BACFCA2B28CF1C9F5DD7AB1204EA4", signedTransaction.getPayload());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicAliasTransactionTest method serialize.
@Test
void serialize() {
MosaicId mosaicId = new MosaicId(BigInteger.TEN);
NamespaceId namespaceId = NamespaceId.createFromName("anamespaced");
MosaicAliasTransaction transaction = MosaicAliasTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), AliasAction.LINK, namespaceId, mosaicId).signer(account.getPublicAccount()).build();
String expectedHash = "910000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f6503f78fbf99544b906872ddb392f4be707180d285e7919dbacef2e9573b1e60000000001904e4300000000000000000100000000000000a487791451fdf1b60a0000000000000001";
assertSerialization(expectedHash, transaction);
String expectedEmbeddedHash = "4100000000000000f6503f78fbf99544b906872ddb392f4be707180d285e7919dbacef2e9573b1e60000000001904e43a487791451fdf1b60a0000000000000001";
assertEmbeddedSerialization(expectedEmbeddedHash, transaction);
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicGlobalRestrictionTransactionTest method createAMosaicGlobalRestrictionTransactionViaStaticConstructor.
@Test
void createAMosaicGlobalRestrictionTransactionViaStaticConstructor() {
MosaicGlobalRestrictionTransaction transaction = MosaicGlobalRestrictionTransactionFactory.create(networkType, Deadline.create(epochAdjustment), // restrictedMosaicId
new MosaicId(new BigInteger("1")), // restrictionKey
BigInteger.valueOf(1), // newRestrictionValue
BigInteger.valueOf(8), // newRestrictionType
MosaicRestrictionType.GE).referenceMosaicId(new MosaicId(new BigInteger("2"))).previousRestrictionValue(BigInteger.valueOf(9)).previousRestrictionType(MosaicRestrictionType.EQ).build();
assertEquals(networkType, transaction.getNetworkType());
assertTrue(1 == transaction.getVersion());
assertTrue(LocalDateTime.now().isBefore(transaction.getDeadline().getLocalDateTime(epochAdjustment)));
assertEquals(BigInteger.valueOf(0), transaction.getMaxFee());
assertEquals(new BigInteger("1"), transaction.getMosaicId().getId());
assertEquals(new BigInteger("2"), transaction.getReferenceMosaicId().getId());
assertEquals(BigInteger.valueOf(1), transaction.getRestrictionKey());
assertEquals(BigInteger.valueOf(9), transaction.getPreviousRestrictionValue());
assertEquals(MosaicRestrictionType.EQ, transaction.getPreviousRestrictionType());
assertEquals(BigInteger.valueOf(8), transaction.getNewRestrictionValue());
assertEquals(MosaicRestrictionType.GE, transaction.getNewRestrictionType());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class SecretLockInfoTest method constructor.
@Test
void constructor() {
Optional<String> recordId = Optional.of("abc");
Address ownerAddress = Address.createFromRawAddress("SDY3NFHBQAPO7ZBII3USHG2UZHJYD7G7FICKIII");
Address recipientAddress = Address.createFromRawAddress("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ");
MosaicId mosaicId = MosaicId.createFromNonce(new MosaicNonce(1), ownerAddress);
BigInteger amount = BigInteger.ONE;
BigInteger endHeight = BigInteger.TEN;
LockStatus status = LockStatus.USED;
String hash = "ABC";
LockHashAlgorithm hashAlgorithm = LockHashAlgorithm.HASH_256;
String secret = "DD9EC2AC9AB11FC7E942E5FA39AF8811180F236E29BCD40DB812392295512AAA";
SecretLockInfo info = new SecretLockInfo(recordId.get(), 1, ownerAddress, mosaicId, amount, endHeight, status, hashAlgorithm, secret, recipientAddress, hash);
Assertions.assertEquals(recordId, info.getRecordId());
Assertions.assertEquals(ownerAddress, info.getOwnerAddress());
Assertions.assertEquals(mosaicId, info.getMosaicId());
Assertions.assertEquals(amount, info.getAmount());
Assertions.assertEquals(endHeight, info.getEndHeight());
Assertions.assertEquals(status, info.getStatus());
Assertions.assertEquals(hash, info.getCompositeHash());
Assertions.assertEquals(hashAlgorithm, info.getHashAlgorithm());
Assertions.assertEquals(recipientAddress, info.getRecipientAddress());
byte[] serializedState = info.serialize();
String expectedHex = "010090F1B694E1801EEFE42846E9239B54C9D381FCDF2A04A421E9F49B9E5199FC7601000000000000000A000000000000000102DD9EC2AC9AB11FC7E942E5FA39AF8811180F236E29BCD40DB812392295512AAA90F36CA680C35D630662A0C38DC89D4978D10B511B3D241A";
Assertions.assertEquals(expectedHex, ConvertUtils.toHex(serializedState));
SecretLockInfoBuilder builder = SecretLockInfoBuilder.loadFromBinary(SerializationUtils.toDataInput(serializedState));
Assertions.assertEquals(expectedHex, ConvertUtils.toHex(builder.serialize()));
}
Aggregations