use of io.nem.symbol.sdk.model.mosaic.MosaicNonce 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.mosaic.MosaicNonce 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());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicNonce in project nem2-sdk-java by nemtech.
the class AccountRestrictionIntegrationTest method addAndRemoveMosaicRestriction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addAndRemoveMosaicRestriction(RepositoryType type) {
AccountMosaicRestrictionFlags restrictionFlags = AccountMosaicRestrictionFlags.ALLOW_INCOMING_MOSAIC;
MosaicNonce nonce = MosaicNonce.createRandom();
MosaicId mosaicId = MosaicId.createFromNonce(nonce, testAccount.getPublicAccount());
Assertions.assertNotNull(get(getRepositoryFactory(type).createAccountRepository().getAccountInfo(testAccount.getAddress())));
if (hasRestriction(type, testAccount, restrictionFlags, mosaicId)) {
System.out.println("Removing existing mosaic restriction!");
sendAccountRestrictionMosaic(type, mosaicId, false, restrictionFlags);
Assertions.assertFalse(hasRestriction(type, testAccount, restrictionFlags, mosaicId));
}
System.out.println("Adding mosaic restriction");
sendAccountRestrictionMosaic(type, mosaicId, true, restrictionFlags);
Assertions.assertTrue(hasRestriction(type, testAccount, restrictionFlags, mosaicId));
System.out.println("Removing mosaic restriction");
sendAccountRestrictionMosaic(type, mosaicId, false, restrictionFlags);
Assertions.assertFalse(hasRestriction(type, testAccount, restrictionFlags, mosaicId));
}
use of io.nem.symbol.sdk.model.mosaic.MosaicNonce 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());
}
Aggregations