Search in sources :

Example 6 with SecretLockTransaction

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);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with 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);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with SecretLockTransaction

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());
}
Also used : UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) Test(org.junit.jupiter.api.Test)

Aggregations

SecretLockTransaction (io.nem.symbol.sdk.model.transaction.SecretLockTransaction)8 SecretProofTransaction (io.nem.symbol.sdk.model.transaction.SecretProofTransaction)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 Address (io.nem.symbol.sdk.model.account.Address)4 EnumSource (org.junit.jupiter.params.provider.EnumSource)4 Test (org.junit.jupiter.api.Test)3 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)2 AccountAddressRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction)2 AccountKeyLinkTransaction (io.nem.symbol.sdk.model.transaction.AccountKeyLinkTransaction)2 AccountMetadataTransaction (io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction)2 AccountMosaicRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction)2 AccountOperationRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)2 AddressAliasTransaction (io.nem.symbol.sdk.model.transaction.AddressAliasTransaction)2 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)2 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)2 MosaicAliasTransaction (io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction)2 MosaicDefinitionTransaction (io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)2 MosaicMetadataTransaction (io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction)2 MosaicSupplyChangeTransaction (io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction)2 MultisigAccountModificationTransaction (io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction)2