Search in sources :

Example 6 with BlockDuration

use of io.nem.symbol.sdk.model.blockchain.BlockDuration in project nem2-sdk-java by nemtech.

the class MosaicDefinitionTransactionIntegrationTest method aggregateMosaicDefinitionTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateMosaicDefinitionTransaction(RepositoryType type) {
    MosaicNonce nonce = MosaicNonce.createRandom();
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, this.account.getPublicAccount());
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransactionFactory.create(getNetworkType(), getDeadline(), nonce, mosaicId, MosaicFlags.create(true, false, true), 4, new BlockDuration(100)).maxFee(maxFee).build();
    MosaicDefinitionTransaction processed = announceAggregateAndValidate(type, mosaicDefinitionTransaction, this.account).getLeft();
    Assertions.assertEquals(mosaicDefinitionTransaction.getMosaicNonce(), processed.getMosaicNonce());
    Assertions.assertEquals(mosaicId, processed.getMosaicId());
}
Also used : BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with BlockDuration

use of io.nem.symbol.sdk.model.blockchain.BlockDuration in project nem2-sdk-java by nemtech.

the class MosaicDefinitionTransactionTest method createAMosaicCreationTransactionViaStaticConstructor.

@Test
void createAMosaicCreationTransactionViaStaticConstructor() {
    Account owner = Account.generateNewAccount(NetworkType.MIJIN_TEST);
    Duration epochAdjustment = Duration.ofSeconds(100);
    int nonceNumber = 12345;
    MosaicNonce nonce = MosaicNonce.createFromInteger(nonceNumber);
    MosaicDefinitionTransaction mosaicCreationTx = MosaicDefinitionTransactionFactory.create(NetworkType.MIJIN_TEST, Deadline.create(epochAdjustment), nonce, MosaicId.createFromNonce(nonce, owner.getPublicAccount()), MosaicFlags.create(true, true, true), 4, new BlockDuration(222222)).build();
    System.out.println(ConvertUtils.toHex(BinarySerializationImpl.INSTANCE.serialize(mosaicCreationTx)));
    assertEquals(NetworkType.MIJIN_TEST, mosaicCreationTx.getNetworkType());
    assertEquals(1, (int) mosaicCreationTx.getVersion());
    assertTrue(LocalDateTime.now().isBefore(mosaicCreationTx.getDeadline().getLocalDateTime(epochAdjustment)));
    assertEquals(BigInteger.valueOf(0), mosaicCreationTx.getMaxFee());
    // assertEquals(new BigInteger("0"), mosaicCreationTx.getMosaicId().getId());
    assertTrue(mosaicCreationTx.getMosaicFlags().isSupplyMutable());
    assertTrue(mosaicCreationTx.getMosaicFlags().isTransferable());
    assertTrue(mosaicCreationTx.getMosaicFlags().isRestrictable());
    assertEquals(nonceNumber, mosaicCreationTx.getMosaicNonce().getNonceAsInt());
    assertEquals(4, mosaicCreationTx.getDivisibility());
    assertEquals(new BlockDuration(222222), mosaicCreationTx.getBlockDuration());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) Duration(java.time.Duration) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) Test(org.junit.jupiter.api.Test)

Aggregations

BlockDuration (io.nem.symbol.sdk.model.blockchain.BlockDuration)7 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)5 MosaicNonce (io.nem.symbol.sdk.model.mosaic.MosaicNonce)5 MosaicDefinitionTransaction (io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)4 Test (org.junit.jupiter.api.Test)4 BigInteger (java.math.BigInteger)3 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)2 DisplayName (org.junit.jupiter.api.DisplayName)2 Account (io.nem.symbol.sdk.model.account.Account)1 MosaicFlags (io.nem.symbol.sdk.model.mosaic.MosaicFlags)1 UnresolvedMosaicId (io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)1 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)1 NetworkType (io.nem.symbol.sdk.model.network.NetworkType)1 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)1 MosaicAliasTransaction (io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction)1 MosaicSupplyChangeTransaction (io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction)1 Duration (java.time.Duration)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1