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;
}
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;
}
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);
}
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);
}
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());
}
Aggregations