Search in sources :

Example 1 with MosaicProperties

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

the class MosaicDefinitionTransactionTest method createAMosaicCreationTransactionViaStaticConstructor.

@Test
void createAMosaicCreationTransactionViaStaticConstructor() {
    MosaicDefinitionTransaction mosaicCreationTx = MosaicDefinitionTransaction.create(new Deadline(2, ChronoUnit.HOURS), "mosaicname", "namespacename", new MosaicProperties(true, true, true, 3, BigInteger.valueOf(10)), NetworkType.MIJIN_TEST);
    assertEquals(NetworkType.MIJIN_TEST, mosaicCreationTx.getNetworkType());
    assertTrue(2 == mosaicCreationTx.getVersion());
    assertEquals("mosaicname", mosaicCreationTx.getMosaicName());
    assertTrue(LocalDateTime.now().isBefore(mosaicCreationTx.getDeadline().getLocalDateTime()));
    assertEquals(BigInteger.valueOf(0), mosaicCreationTx.getFee());
    assertEquals(new BigInteger("6396233739721801544"), mosaicCreationTx.getNamespaceId().getId());
    assertEquals(new BigInteger("-5158169874280477899"), mosaicCreationTx.getMosaicId().getId());
    assertEquals(true, mosaicCreationTx.getMosaicProperties().isSupplyMutable());
    assertEquals(true, mosaicCreationTx.getMosaicProperties().isTransferable());
    assertEquals(true, mosaicCreationTx.getMosaicProperties().isLevyMutable());
    assertEquals(3, mosaicCreationTx.getMosaicProperties().getDivisibility());
    assertEquals(BigInteger.valueOf(10), mosaicCreationTx.getMosaicProperties().getDuration());
}
Also used : BigInteger(java.math.BigInteger) MosaicProperties(io.nem.sdk.model.mosaic.MosaicProperties) Test(org.junit.jupiter.api.Test)

Example 2 with MosaicProperties

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

the class MosaicDefinitionTransactionTest method serialization.

@Test
@DisplayName("Serialization")
void serialization() {
    byte[] expected = new byte[] { (byte) 156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, (byte) 144, 77, 65, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, (byte) 155, (byte) 138, 22, 28, (byte) 245, 9, 35, (byte) 144, 21, (byte) 153, 17, (byte) 174, (byte) 167, 46, (byte) 189, 60, 7, 1, 7, 4, 109, 111, 115, 97, 105, 99, 115, 2, 16, 39, 0, 0, 0, 0, 0, 0 };
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransaction.create(new FakeDeadline(), "mosaics", "sname", new MosaicProperties(true, true, true, 4, BigInteger.valueOf(10000)), NetworkType.MIJIN_TEST);
    byte[] actual = mosaicDefinitionTransaction.generateBytes();
    assertArrayEquals(expected, actual);
}
Also used : MosaicProperties(io.nem.sdk.model.mosaic.MosaicProperties) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with MosaicProperties

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

the class E2ETest method standaloneMosaicDefinitionTransaction.

@Test
void standaloneMosaicDefinitionTransaction() throws ExecutionException, InterruptedException {
    String mosaicName = "test-mosaic-" + new Double(Math.floor(Math.random() * 10000)).intValue();
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransaction.create(new Deadline(2, HOURS), mosaicName, this.namespaceName, new MosaicProperties(true, true, true, 4, BigInteger.valueOf(100)), NetworkType.MIJIN_TEST);
    SignedTransaction signedTransaction = this.account.sign(mosaicDefinitionTransaction);
    transactionHttp.announce(signedTransaction).toFuture().get();
    this.validateTransactionAnnounceCorrectly(this.account.getAddress(), signedTransaction.getHash());
}
Also used : MosaicProperties(io.nem.sdk.model.mosaic.MosaicProperties) Test(org.junit.jupiter.api.Test)

Example 4 with MosaicProperties

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

the class E2ETest method aggregateMosaicDefinitionTransaction.

@Test
void aggregateMosaicDefinitionTransaction() throws ExecutionException, InterruptedException {
    String mosaicName = "test-mosaic-" + new Double(Math.floor(Math.random() * 10000)).intValue();
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransaction.create(new Deadline(2, HOURS), mosaicName, this.namespaceName, new MosaicProperties(true, false, false, 4, BigInteger.valueOf(100)), NetworkType.MIJIN_TEST);
    AggregateTransaction aggregateTransaction = AggregateTransaction.createComplete(new Deadline(2, HOURS), Collections.singletonList(mosaicDefinitionTransaction.toAggregate(this.account.getPublicAccount())), NetworkType.MIJIN_TEST);
    SignedTransaction signedTransaction = this.account.sign(aggregateTransaction);
    transactionHttp.announce(signedTransaction).toFuture().get();
    this.validateTransactionAnnounceCorrectly(this.account.getAddress(), signedTransaction.getHash());
}
Also used : MosaicProperties(io.nem.sdk.model.mosaic.MosaicProperties) Test(org.junit.jupiter.api.Test)

Aggregations

MosaicProperties (io.nem.sdk.model.mosaic.MosaicProperties)4 Test (org.junit.jupiter.api.Test)4 BigInteger (java.math.BigInteger)1 DisplayName (org.junit.jupiter.api.DisplayName)1