Search in sources :

Example 1 with BlockDuration

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

the class MosaicDefinitionTransactionIntegrationTest method createMosaic.

private MosaicId createMosaic(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, true, true), 4, new BlockDuration(100)).maxFee(maxFee).build();
    MosaicDefinitionTransaction processed = announceAndValidate(type, this.account, mosaicDefinitionTransaction);
    Assertions.assertEquals(mosaicId, processed.getMosaicId());
    Assertions.assertEquals(mosaicDefinitionTransaction.getMosaicNonce(), processed.getMosaicNonce());
    return mosaicId;
}
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)

Example 2 with BlockDuration

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

the class TestHelper method createMosaic.

protected MosaicId createMosaic(Account account, RepositoryType type, BigInteger initialSupply, String alias) {
    MosaicNonce nonce = MosaicNonce.createRandom();
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, account.getPublicAccount());
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransactionFactory.create(getNetworkType(), getDeadline(), nonce, mosaicId, MosaicFlags.create(true, true, true), 4, new BlockDuration(100)).maxFee(maxFee).build();
    MosaicDefinitionTransaction validateTransaction = announceAndValidate(type, account, mosaicDefinitionTransaction);
    Assertions.assertEquals(mosaicId, validateTransaction.getMosaicId());
    UnresolvedMosaicId unresolvedMosaicId = mosaicId;
    if (alias != null) {
        NamespaceId rootNamespaceId = createRootNamespace(type, account, alias);
        unresolvedMosaicId = rootNamespaceId;
        MosaicAliasTransaction addressAliasTransaction = MosaicAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, mosaicId).maxFee(maxFee).build();
        announceAggregateAndValidate(type, addressAliasTransaction, account);
    }
    if (initialSupply != null && initialSupply.longValue() > 0) {
        MosaicSupplyChangeTransaction mosaicSupplyChangeTransaction = MosaicSupplyChangeTransactionFactory.create(getNetworkType(), getDeadline(), unresolvedMosaicId, MosaicSupplyChangeActionType.INCREASE, initialSupply).maxFee(maxFee).build();
        announceAndValidate(type, account, mosaicSupplyChangeTransaction);
    }
    return mosaicId;
}
Also used : MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Example 3 with BlockDuration

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

the class MosaicDefinitionTransactionTest method shouldGenerateEmbeddedBytes.

@Test
@DisplayName("SerializationEmbeddedBytes")
void shouldGenerateEmbeddedBytes() {
    String expected = "460000000000000068b3fbb18729c1fde225c57f8ce080fa828f0067e451a3fd81fa628842b0b7630000000001904d4100000000000000000a00000000000000000000000203";
    NetworkType networkType = NetworkType.MIJIN_TEST;
    MosaicId mosaicId = new MosaicId(new BigInteger("0"));
    BigInteger fee = BigInteger.ONE;
    MosaicNonce mosaicNonce = MosaicNonce.createFromBigInteger(new BigInteger("0"));
    MosaicFlags mosaicFlags = MosaicFlags.create(false, true, false);
    PublicAccount signature = PublicAccount.createFromPublicKey("68b3fbb18729c1fde225c57f8ce080fa828f0067e451a3fd81fa628842b0b763", NetworkType.MIJIN_TEST);
    TransactionInfo transactionInfo = TransactionInfo.createAggregate(new BigInteger("121855"), 1, "5A3D23889CD1E800015929A9", "3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006", "5A0069D83F17CF0001777E55");
    MosaicDefinitionTransaction transaction = MosaicDefinitionTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), mosaicNonce, mosaicId, mosaicFlags, 3, new BlockDuration(10)).maxFee(fee).signature("theSigner").signer(signature).transactionInfo(transactionInfo).build();
    assertEmbeddedSerialization(expected, transaction);
}
Also used : MosaicFlags(io.nem.symbol.sdk.model.mosaic.MosaicFlags) BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) BigInteger(java.math.BigInteger) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with BlockDuration

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

the class MosaicDefinitionTransactionTest method serialization.

@Test
@DisplayName("Serialization")
void serialization() {
    String expected = "96000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001904d410000000000000000010000000000000000000000000000001027000000000000000000000504";
    MosaicDefinitionTransaction transaction = MosaicDefinitionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), MosaicNonce.createFromBigInteger(new BigInteger("0")), new MosaicId(new BigInteger("0")), MosaicFlags.create(true, false, true), 4, new BlockDuration(10000)).build();
    assertSerialization(expected, transaction);
}
Also used : BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BigInteger(java.math.BigInteger) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with BlockDuration

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

the class TransactionServiceTest method mosaicDefinitionTransactionResolveAlias.

@Test
void mosaicDefinitionTransactionResolveAlias() throws ExecutionException, InterruptedException {
    String transactionHash = "aaaa";
    TransactionFactory<MosaicDefinitionTransaction> factory = MosaicDefinitionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), MosaicNonce.createFromBigInteger(new BigInteger("0")), mosaicId2, MosaicFlags.create(true, true, true), 4, new BlockDuration(10000)).transactionInfo(TransactionInfo.create(height, 4, "ABC", transactionHash, ""));
    MosaicDefinitionTransaction transaction = factory.build();
    simulateStatement(height, 5, 0);
    List<String> hashes = Collections.singletonList(transactionHash);
    Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
    MosaicDefinitionTransaction resolvedTransaction = (MosaicDefinitionTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
    Assertions.assertEquals(mosaicId2, resolvedTransaction.getMosaicId());
}
Also used : BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) BigInteger(java.math.BigInteger) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) 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