use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class SecretLockTransactionTest method serialize.
@Test
@DisplayName("Serialize")
void serialize() {
PublicAccount publicAccount = new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", NetworkType.MIJIN_TEST);
String secret = "3fc8ba10229ab5778d05d9c4b7f56676a88bf9295c185acfc0f961db5408cafe";
SecretLockTransaction transaction = SecretLockTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), Currency.CAT_CURRENCY.createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), LockHashAlgorithm.SHA3_256, secret, Address.createFromRawAddress("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ")).signer(publicAccount).build();
String expected = "D100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B2400000000019052410000000000000000010000000000000090F36CA680C35D630662A0C38DC89D4978D10B511B3D241A3FC8BA10229AB5778D05D9C4B7F56676A88BF9295C185ACFC0F961DB5408CAFE44B262C46CEABB858096980000000000640000000000000000";
assertSerialization(expected, transaction);
String expectedEmbbeded = "81000000000000009A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24000000000190524190F36CA680C35D630662A0C38DC89D4978D10B511B3D241A3FC8BA10229AB5778D05D9C4B7F56676A88BF9295C185ACFC0F961DB5408CAFE44B262C46CEABB858096980000000000640000000000000000";
assertEmbeddedSerialization(expectedEmbbeded, transaction);
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class MosaicIdTest method hashCodeAndEquals.
@Test
void hashCodeAndEquals() {
PublicAccount owner = PublicAccount.createFromPublicKey(publicKey, NetworkType.MIJIN_TEST);
MosaicNonce nonce = MosaicNonce.createFromInteger(0);
MosaicId mosaicId = MosaicId.createFromNonce(nonce, owner);
MosaicId mosaicId2 = new MosaicId(new BigInteger("5331590414131997017"));
MosaicId mosaicId3 = MosaicId.createFromNonce(nonce, owner.getAddress());
assertEquals(mosaicId, mosaicId);
assertNotEquals("", mosaicId);
assertNotEquals(mosaicId, "");
assertEquals(mosaicId, mosaicId2);
assertEquals(mosaicId.hashCode(), mosaicId2.hashCode());
assertEquals(mosaicId, mosaicId3);
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class MosaicIdTest method createAMosaicIdFromNonceAndOwner.
@Test
void createAMosaicIdFromNonceAndOwner() {
PublicAccount owner = PublicAccount.createFromPublicKey(publicKey, NetworkType.MIJIN_TEST);
MosaicNonce nonce = MosaicNonce.createFromInteger(0);
MosaicId mosaicId = MosaicId.createFromNonce(nonce, owner);
MosaicId mosaicId2 = new MosaicId(new BigInteger("5331590414131997017"));
MosaicId mosaicId3 = MosaicId.createFromNonce(nonce, owner.getAddress());
assertEquals(mosaicId, mosaicId);
assertEquals(mosaicId, mosaicId2);
assertEquals(mosaicId, mosaicId3);
assertEquals(5331590414131997017L, mosaicId2.getIdAsLong());
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class MosaicIdTest method createAMosaicIdFromNonceAndOwnerTwiceTheSame.
@Test
void createAMosaicIdFromNonceAndOwnerTwiceTheSame() {
PublicAccount owner = PublicAccount.createFromPublicKey(publicKey, NetworkType.MIJIN_TEST);
MosaicNonce nonce = MosaicNonce.createFromInteger(0);
MosaicId mosaicId1 = MosaicId.createFromNonce(nonce, owner);
MosaicId mosaicId2 = MosaicId.createFromNonce(nonce, owner);
assertEquals(mosaicId1, mosaicId2);
assertEquals(mosaicId1.hashCode(), mosaicId2.hashCode());
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class AddressAliasTransactionTest method shouldSerialize.
@Test
void shouldSerialize() {
NetworkType networkType = NetworkType.MIJIN_TEST;
BigInteger fee = BigInteger.ONE;
NamespaceId namespaceId = NamespaceId.createFromId(new BigInteger("-8884663987180930485"));
PublicAccount signature = PublicAccount.createFromPublicKey("68b3fbb18729c1fde225c57f8ce080fa828f0067e451a3fd81fa628842b0b763", NetworkType.MIJIN_TEST);
TransactionInfo transactionInfo = TransactionInfo.createAggregate(new BigInteger("121855"), 1, "5A3D23889CD1E800015929A9", "3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006", "5A0069D83F17CF0001777E55");
String signatureHex = createRandomSignature();
AddressAliasTransaction transaction = AddressAliasTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), AliasAction.LINK, namespaceId, signature.getAddress()).signer(signature).transactionInfo(transactionInfo).signature(signatureHex).maxFee(fee).build();
String expectedHash = "A100000000000000" + signatureHex + "68B3FBB18729C1FDE225C57F8CE080FA828F0067E451A3FD81FA628842B0B7630000000001904E42010000000000000001000000000000004BFA5F372D55B3849049E14BEBCA93758EB36805BAE760A57239976F009A545C01";
assertSerialization(expectedHash, transaction);
String expectedEmbeddedHash = "510000000000000068B3FBB18729C1FDE225C57F8CE080FA828F0067E451A3FD81FA628842B0B7630000000001904E424BFA5F372D55B3849049E14BEBCA93758EB36805BAE760A57239976F009A545C01";
assertEmbeddedSerialization(expectedEmbeddedHash, transaction);
}
Aggregations