Search in sources :

Example 31 with NetworkType

use of io.nem.symbol.sdk.model.network.NetworkType 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);
}
Also used : NetworkType(io.nem.symbol.sdk.model.network.NetworkType) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) BigInteger(java.math.BigInteger) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Aggregations

NetworkType (io.nem.symbol.sdk.model.network.NetworkType)31 Test (org.junit.jupiter.api.Test)13 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)11 BigInteger (java.math.BigInteger)10 Address (io.nem.symbol.sdk.model.account.Address)9 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)7 Account (io.nem.symbol.sdk.model.account.Account)5 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)5 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)5 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)5 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)5 Duration (java.time.Duration)5 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 BinarySerializationImpl (io.nem.symbol.sdk.infrastructure.BinarySerializationImpl)3 UnresolvedMosaicId (io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)3 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)3 Optional (java.util.Optional)3 ConvertUtils (io.nem.symbol.core.utils.ConvertUtils)2