Search in sources :

Example 6 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicVectorTester method testMosaics.

@ParameterizedTest
@MethodSource("testMosaics")
void testMosaics(NetworkType networkType, long mosaicNonce, String plain, String mosaicHex) {
    Address address = Address.createFromRawAddress(plain);
    Assertions.assertEquals(networkType, address.getNetworkType());
    MosaicNonce nonce = MosaicNonce.createFromBigInteger(BigInteger.valueOf(mosaicNonce));
    MosaicNonce nonce2 = MosaicNonce.createFromInteger((int) mosaicNonce);
    Assertions.assertEquals(mosaicNonce, nonce.getNonceAsLong());
    Assertions.assertEquals(mosaicNonce, nonce2.getNonceAsLong());
    Assertions.assertEquals(nonce2, nonce);
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, address);
    Assertions.assertEquals(mosaicHex, mosaicId.getIdAsHex());
}
Also used : MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 7 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class ResolutionStatementTest method setup.

@BeforeAll
public static void setup() {
    address = new Address("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ", networkType);
    mosaicId = new MosaicId("85BBEA6CC462B244");
    namespaceId = NamespaceId.createFromName("money");
    receiptSource = new ReceiptSource(1, 1);
    addressResolutionEntry = new ResolutionEntry<>(address, receiptSource, ReceiptType.ADDRESS_ALIAS_RESOLUTION);
    mosaicResolutionEntry = new ResolutionEntry<>(mosaicId, receiptSource, ReceiptType.MOSAIC_ALIAS_RESOLUTION);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class NamespaceInfoTest method createANamespaceInfoViaConstructor.

@Test
void createANamespaceInfoViaConstructor() {
    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 MosaicAlias(new MosaicId(new BigInteger("100"))));
    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.MOSAIC, namespaceInfo.getAlias().getType());
    assertEquals(new BigInteger("100"), ((MosaicId) namespaceInfo.getAlias().getAliasValue()).getId());
    byte[] serialize = namespaceInfo.serialize(Arrays.asList(createSubNamespaceInfo(namespaceId)));
    assertEquals("01004BFA5F372D55B38490EEAEB70253A409E9A243F08261BDFB7B7255A2CF4080390100000000000000FFFFFFFFFFFFFFFF01640000000000000001000000000000000129CF2728A91AE7F0016400000000000000", ConvertUtils.toHex(serialize));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BigInteger(java.math.BigInteger) Test(org.junit.jupiter.api.Test)

Example 9 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class NamespaceInfoTest method createSubNamespaceInfo.

NamespaceInfo createSubNamespaceInfo(NamespaceId parentId) {
    NamespaceId level0 = NamespaceId.createFromId(new BigInteger("17358872602548358953"));
    NamespaceId level1 = NamespaceId.createFromId(new BigInteger("-1087871471161192663"));
    return new NamespaceInfo("bcd", 1, true, 0, NamespaceRegistrationType.SUB_NAMESPACE, 1, Arrays.asList(level0, level1), parentId, new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST).getAddress(), new BigInteger("1"), new BigInteger("-1"), new MosaicAlias(new MosaicId(new BigInteger("100"))));
}
Also used : MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) BigInteger(java.math.BigInteger)

Example 10 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class ArtifactExpiryReceiptTest method shouldThrowIllegalArgumentExceptionWithWrongReceiptType.

@Test
void shouldThrowIllegalArgumentExceptionWithWrongReceiptType() {
    assertThrows(IllegalArgumentException.class, () -> {
        MosaicId mosaicId = new MosaicId("85BBEA6CC462B244");
        new ArtifactExpiryReceipt<>(mosaicId, ReceiptType.LOCK_HASH_COMPLETED, ReceiptVersion.ARTIFACT_EXPIRY, null);
    });
}
Also used : MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Test(org.junit.jupiter.api.Test)

Aggregations

MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)138 Test (org.junit.jupiter.api.Test)92 Address (io.nem.symbol.sdk.model.account.Address)53 BigInteger (java.math.BigInteger)53 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 EnumSource (org.junit.jupiter.params.provider.EnumSource)23 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)19 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)18 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)17 Account (io.nem.symbol.sdk.model.account.Account)16 MosaicInfo (io.nem.symbol.sdk.model.mosaic.MosaicInfo)15 ArrayList (java.util.ArrayList)13 MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)12 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)10 MosaicGlobalRestrictionTransaction (io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransaction)10 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)10 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)7 Currency (io.nem.symbol.sdk.model.mosaic.Currency)7 MosaicNames (io.nem.symbol.sdk.model.mosaic.MosaicNames)7 MosaicNonce (io.nem.symbol.sdk.model.mosaic.MosaicNonce)7