use of io.nem.symbol.sdk.model.account.PublicAccount 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.account.PublicAccount in project nem2-sdk-java by nemtech.
the class HashLockTransactionTest method toAggregate.
@Test
@DisplayName("To aggregate")
void toAggregate() {
String expected = "68000000000000009a49366406aca952b88badf5f1e9be6ce4968141035a60be503273ea65456b24000000000190484144b262c46ceabb85809698000000000064000000000000008498b38d89c1dc8a448ea5824938ff828926cd9f7747b1844b59b4b6807e878b";
HashLockTransaction transaction = HashLockTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Currency.CAT_CURRENCY.createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B").build();
transaction.toAggregate(new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", networkType));
assertEmbeddedSerialization(expected, transaction);
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class TransactionRepositoryVertxImplTest method searchTransactions.
@Test
public void searchTransactions() throws Exception {
TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json");
PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
mockRemoteCall(toPage(transferTransactionDTO));
Page<Transaction> transactions = repository.search(new TransactionSearchCriteria(TransactionGroup.UNCONFIRMED).signerPublicKey(publicAccount.getPublicKey())).toFuture().get();
Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
Assertions.assertEquals(TransactionGroup.UNCONFIRMED, transactions.getData().get(0).getGroup().get());
Assertions.assertEquals(1, transactions.getData().size());
Assertions.assertEquals(1, transactions.getPageNumber());
Assertions.assertEquals(2, transactions.getPageSize());
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class VertxAggregateTransactionTest method shouldCreateAggregateTransactionAndSignWithMultipleCosignatories.
@Test
void shouldCreateAggregateTransactionAndSignWithMultipleCosignatories() {
Address address = Address.generateRandom(networkType);
TransferTransaction transferTx = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), address, Collections.emptyList()).message(new PlainMessage("test-message")).build();
AggregateTransaction aggregateTx = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Collections.singletonList(transferTx.toAggregate(new PublicAccount("B694186EE4AB0558CA4AFCFDD43B42114AE71094F5A1FC4A913FE9971CACD21D", networkType)))).build();
Account cosignatoryAccount = Account.generateNewAccount(this.networkType);
Account cosignatoryAccount2 = Account.generateNewAccount(this.networkType);
Account cosignatoryAccount3 = Account.generateNewAccount(this.networkType);
SignedTransaction signedTransaction = cosignatoryAccount.signTransactionWithCosignatories(aggregateTx, Arrays.asList(cosignatoryAccount2, cosignatoryAccount3), generationHash);
BinarySerialization serialization = BinarySerializationImpl.INSTANCE;
AggregateTransaction deserialized = (AggregateTransaction) serialization.deserialize(ConvertUtils.fromHexToBytes(signedTransaction.getPayload()));
Assertions.assertEquals(2, deserialized.getCosignatures().size());
Assertions.assertEquals(cosignatoryAccount2.getPublicAccount(), deserialized.getCosignatures().get(0).getSigner());
Assertions.assertEquals(cosignatoryAccount3.getPublicAccount(), deserialized.getCosignatures().get(1).getSigner());
}
use of io.nem.symbol.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class VertxAggregateTransactionTest method serialization.
@Test
@DisplayName("Serialization")
void serialization() {
Address address = Address.generateRandom(networkType);
TransferTransaction transferTx = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), address, Collections.singletonList(createAbsolute(BigInteger.valueOf(10000000)))).message(new PlainMessage("")).build();
PublicAccount signer = Account.generateNewAccount(networkType).getPublicAccount();
AggregateTransaction aggregateTx = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Collections.singletonList(transferTx.toAggregate(signer))).build();
byte[] actual = aggregateTx.serialize();
BinarySerialization serialization = BinarySerializationImpl.INSTANCE;
AggregateTransaction deserialized = (AggregateTransaction) serialization.deserialize(actual);
assertEquals(signer, deserialized.getInnerTransactions().get(0).getSigner().get());
}
Aggregations