Search in sources :

Example 11 with Address

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

the class NamespaceInfoTest method createANamespaceInfoViaConstructorEmptyAlias.

@Test
void createANamespaceInfoViaConstructorEmptyAlias() {
    NamespaceId namespaceId = NamespaceId.createFromId(new BigInteger("-8884663987180930485"));
    Address address = Address.createFromRawAddress("SDXK5NYCKOSAT2NCIPYIEYN57N5XEVNCZ5AIAOI");
    NamespaceInfo namespaceInfo = new NamespaceInfo("abc", 1, true, 0, NamespaceRegistrationType.ROOT_NAMESPACE, 1, Arrays.asList(namespaceId), NamespaceId.createFromId(new BigInteger("0")), address, new BigInteger("1"), new BigInteger("-1"), new EmptyAlias());
    assertEquals("abc", namespaceInfo.getRecordId().get());
    assertTrue(namespaceInfo.isActive());
    assertEquals(0, (int) namespaceInfo.getIndex());
    assertSame(namespaceInfo.getRegistrationType(), NamespaceRegistrationType.ROOT_NAMESPACE);
    assertEquals(1, (int) namespaceInfo.getDepth());
    assertEquals(namespaceId, namespaceInfo.getLevels().get(0));
    Assertions.assertEquals(address, namespaceInfo.getOwnerAddress());
    assertEquals(new BigInteger("1"), namespaceInfo.getStartHeight());
    assertEquals(new BigInteger("-1"), namespaceInfo.getEndHeight());
    assertEquals(AliasType.NONE, namespaceInfo.getAlias().getType());
    byte[] serialize = namespaceInfo.serialize(Arrays.asList(createSubNamespaceInfo(namespaceId)));
    assertEquals("01004BFA5F372D55B38490EEAEB70253A409E9A243F08261BDFB7B7255A2CF4080390100000000000000FFFFFFFFFFFFFFFF0001000000000000000129CF2728A91AE7F0016400000000000000", ConvertUtils.toHex(serialize));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) BigInteger(java.math.BigInteger) Test(org.junit.jupiter.api.Test)

Example 12 with Address

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

the class BalanceTransferReceiptTest method shouldSerializeTheSameAsTypescript.

@Test
void shouldSerializeTheSameAsTypescript() {
    Address sender = Address.generateRandom(networkType);
    Address recipient = Address.generateRandom(networkType);
    BalanceTransferReceipt balanceTransferReceipt = new BalanceTransferReceipt(sender, recipient, new MosaicId("941299B2B7E1291C"), BigInteger.valueOf(1000), ReceiptType.MOSAIC_RENTAL_FEE, ReceiptVersion.BALANCE_TRANSFER);
    String hex = ConvertUtils.toHex(balanceTransferReceipt.serialize());
    Assertions.assertEquals("01004D121C29E1B7B2991294E803000000000000" + sender.encoded() + recipient.encoded(), hex.toUpperCase());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Test(org.junit.jupiter.api.Test)

Example 13 with Address

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

the class MosaicIdTest method testCurrency.

@Test
void testCurrency() {
    String nemesisSignerPublicKey = "E0AC0720AA389B8DBF9DB9D2672991CDA7DEC284737984702CE7FD7C6E07A5E2";
    Address nemesisAddress = Address.createFromPublicKey(nemesisSignerPublicKey, NetworkType.TEST_NET);
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createFromInteger(0), nemesisAddress);
    assertEquals("61B0856247BD3A71", mosaicId.getIdAsHex());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) Test(org.junit.jupiter.api.Test)

Example 14 with Address

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

the class MosaicIdTest method testHarvestCurrency.

@Test
void testHarvestCurrency() {
    String nemesisSignerPublicKey = "AA4174DBA4C6CABFF16DEDA628ACE549701FD1618BC6CE89E10BEFE33459CD12";
    Address nemesisAddress = Address.createFromPublicKey(nemesisSignerPublicKey, NetworkType.TEST_NET);
    MosaicNonce nonce = MosaicNonce.createFromInteger(1);
    Assertions.assertEquals(1, nonce.getNonceAsLong());
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, nemesisAddress);
    assertEquals("1646351CC29EBDCB", mosaicId.getIdAsHex());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) Test(org.junit.jupiter.api.Test)

Example 15 with Address

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

the class MosaicIdTest method testCurrencyTestnet.

@Test
void testCurrencyTestnet() {
    String nemesisSignerPublicKey = "871B2F2F9D825252FFF43543066EE8D9141A3373F2F013BB449C6425A03362D8";
    Address nemesisAddress = Address.createFromPublicKey(nemesisSignerPublicKey, NetworkType.TEST_NET);
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createFromInteger(0), nemesisAddress);
    assertEquals("5E62990DCAC5BE8A", mosaicId.getIdAsHex());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) Test(org.junit.jupiter.api.Test)

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