use of io.nem.symbol.sdk.model.transaction.SecretLockTransaction in project nem2-sdk-java by nemtech.
the class SecretLockSecretProofTransactionIntegrationTest method standaloneSecretLockTransaction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void standaloneSecretLockTransaction(RepositoryType type) {
byte[] secretBytes = RandomUtils.generateRandomBytes(20);
byte[] result = Hashes.sha3_256(secretBytes);
String secret = ConvertUtils.toHex(result);
Address recipient = config().getTestAccount2().getAddress();
SecretLockTransaction secretLockTransaction = SecretLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), LockHashAlgorithm.SHA3_256, secret, recipient).maxFee(maxFee).build();
announceAndValidate(type, account, secretLockTransaction);
}
use of io.nem.symbol.sdk.model.transaction.SecretLockTransaction in project nem2-sdk-java by nemtech.
the class SecretLockSecretProofTransactionIntegrationTest method aggregateSecretProofTransaction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateSecretProofTransaction(RepositoryType type) {
byte[] secretBytes = RandomUtils.generateRandomBytes(20);
byte[] result = Hashes.sha3_256(secretBytes);
String secret = ConvertUtils.toHex(result);
String proof = ConvertUtils.toHex(secretBytes);
Address recipient = config().getTestAccount2().getAddress();
SecretLockTransaction secretLockTransaction = SecretLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), LockHashAlgorithm.SHA3_256, secret, recipient).maxFee(maxFee).build();
announceAndValidate(type, account, secretLockTransaction);
SecretProofTransaction secretProofTransaction = SecretProofTransactionFactory.create(getNetworkType(), getDeadline(), LockHashAlgorithm.SHA3_256, recipient, secret, proof).maxFee(maxFee).build();
announceAggregateAndValidate(type, secretProofTransaction, account);
}
use of io.nem.symbol.sdk.model.transaction.SecretLockTransaction in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method secretLockTransactionResolveAlias.
@Test
void secretLockTransactionResolveAlias() throws ExecutionException, InterruptedException {
Mosaic unresolvedMosaicId = new Mosaic(mosaicNamespace2, BigInteger.valueOf(2));
UnresolvedAddress recipient = addressNamespace1;
String transactionHash = "aaaa";
String secret = "3fc8ba10229ab5778d05d9c4b7f56676a88bf9295c185acfc0f961db5408cafe";
TransactionFactory<SecretLockTransaction> factory = SecretLockTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), unresolvedMosaicId, BigInteger.TEN, LockHashAlgorithm.SHA3_256, secret, recipient).transactionInfo(TransactionInfo.create(height, 0, "ABC", transactionHash, ""));
simulateStatement(height, 1, 0);
SecretLockTransaction transaction = factory.build();
List<String> hashes = Collections.singletonList(transactionHash);
Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
SecretLockTransaction resolvedTransaction = (SecretLockTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
Assertions.assertEquals(mosaicId2, resolvedTransaction.getMosaic().getId());
Assertions.assertEquals(address1, resolvedTransaction.getRecipient());
}
Aggregations