Search in sources :

Example 1 with MosaicEntryBuilder

use of io.nem.symbol.catapult.builders.MosaicEntryBuilder in project nem2-sdk-java by nemtech.

the class MosaicInfoTest method createAMosaicInfoViaConstructor.

@Test
void createAMosaicInfoViaConstructor() {
    MosaicFlags mosaicFlags = MosaicFlags.create(true, true, true);
    MosaicId mosaicId = new MosaicId(new BigInteger("-3087871471161192663"));
    Address address = Address.createFromRawAddress("SDY3NFHBQAPO7ZBII3USHG2UZHJYD7G7FICKIII");
    MosaicInfo info = new MosaicInfo("abc", 1, mosaicId, new BigInteger("100"), new BigInteger("200"), address, 1L, mosaicFlags, 3, BigInteger.valueOf(10));
    assertEquals(mosaicId, info.getMosaicId());
    assertEquals(new BigInteger("100"), info.getSupply());
    assertEquals(new BigInteger("200"), info.getStartHeight());
    assertEquals(address, info.getOwnerAddress());
    assertTrue(info.isSupplyMutable());
    assertTrue(info.isTransferable());
    assertTrue(info.isTransferable());
    assertEquals(1L, info.getRevision());
    assertEquals(3, info.getDivisibility());
    assertEquals(BigInteger.valueOf(10), info.getDuration());
    assertEquals("abc", info.getRecordId().get());
    byte[] serializedState = info.serialize();
    String expectedHex = "010029CF5FD941AD25D56400000000000000C80000000000000090F1B694E1801EEFE42846E9239B54C9D381FCDF2A04A4210100000007030A00000000000000";
    Assertions.assertEquals(expectedHex, ConvertUtils.toHex(serializedState));
    MosaicEntryBuilder builder = MosaicEntryBuilder.loadFromBinary(SerializationUtils.toDataInput(serializedState));
    Assertions.assertEquals(expectedHex, ConvertUtils.toHex(builder.serialize()));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicEntryBuilder(io.nem.symbol.catapult.builders.MosaicEntryBuilder) BigInteger(java.math.BigInteger) Test(org.junit.jupiter.api.Test)

Aggregations

MosaicEntryBuilder (io.nem.symbol.catapult.builders.MosaicEntryBuilder)1 Address (io.nem.symbol.sdk.model.account.Address)1 BigInteger (java.math.BigInteger)1 Test (org.junit.jupiter.api.Test)1