Search in sources :

Example 1 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.

the class MultisignIntegrationTest method shouldReturnCosignatureAddedViaListener2.

@Disabled
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnCosignatureAddedViaListener2(RepositoryType type) {
    Listener listener = getListener(type);
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    TransactionRepository transactionRepository = repositoryFactory.createTransactionRepository();
    SignedTransaction signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, cosignAccount1, account2.getAddress());
    Object finalObject = get(createHashLockTransactionAndAnnounce(type, signedAggregatedTx, cosignAccount1).flatMap(t -> {
        System.out.println("hash lock finished");
        TransactionServiceImpl transactionService = new TransactionServiceImpl(getRepositoryFactory(type));
        return transactionService.announceAggregateBonded(listener, signedAggregatedTx).flatMap(a -> {
            System.out.println("Aggregate bonded finished");
            return repositoryFactory.createTransactionRepository().search(new TransactionSearchCriteria(TransactionGroup.PARTIAL).signerPublicKey(cosignAccount1.getPublicAccount().getPublicKey())).flatMap((page) -> {
                List<Transaction> transactions = page.getData();
                System.out.println("partialTransactions " + transactions.size());
                AggregateTransaction transactionToCosign = (AggregateTransaction) transactions.get(0);
                CosignatureTransaction cosignatureTransaction = CosignatureTransaction.create(transactionToCosign);
                CosignatureSignedTransaction cosignatureSignedTransaction = cosignAccount2.signCosignatureTransaction(cosignatureTransaction);
                return transactionRepository.announceAggregateBondedCosignature(cosignatureSignedTransaction).flatMap(r -> {
                    System.out.println("announceAggregateBondedCosignature " + r);
                    return listener.cosignatureAdded(cosignAccount1.getAddress());
                });
            });
        });
    }));
    System.out.println(finalObject.getClass());
    Assertions.assertNull(finalObject);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) Arrays(java.util.Arrays) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) HashLockTransactionFactory(io.nem.symbol.sdk.model.transaction.HashLockTransactionFactory) Account(io.nem.symbol.sdk.model.account.Account) EnumSource(org.junit.jupiter.params.provider.EnumSource) Disabled(org.junit.jupiter.api.Disabled) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) TestInstance(org.junit.jupiter.api.TestInstance) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) Listener(io.nem.symbol.sdk.api.Listener) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) MultisigAccountModificationTransactionFactory(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransactionFactory) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionGroup(io.nem.symbol.sdk.model.transaction.TransactionGroup) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) Assertions(org.junit.jupiter.api.Assertions) AggregateTransactionFactory(io.nem.symbol.sdk.model.transaction.AggregateTransactionFactory) Address(io.nem.symbol.sdk.model.account.Address) Collections(java.util.Collections) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) Listener(io.nem.symbol.sdk.api.Listener) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) List(java.util.List) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Disabled(org.junit.jupiter.api.Disabled)

Example 2 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.

the class NamespaceMetadataServiceIntegrationTest method setAndUpdateNamespaceMetadata.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void setAndUpdateNamespaceMetadata(RepositoryType type) {
    // TODO try target != signer
    Account signerAccount = config().getDefaultAccount();
    Account targetAccount = config().getDefaultAccount();
    String namespaceName = "namespace-id-metadata-service-integration-test-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
    NamespaceId targetNamespaceId = super.createRootNamespace(type, signerAccount, namespaceName);
    BigInteger key = BigInteger.valueOf(RandomUtils.generateRandomInt(100000));
    String originalMessage = "The original message";
    String newMessage = "The new Message";
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    MetadataRepository metadataRepository = repositoryFactory.createMetadataRepository();
    MetadataTransactionService service = new MetadataTransactionServiceImpl(repositoryFactory);
    NamespaceMetadataTransaction originalTransaction = get(service.createNamespaceMetadataTransactionFactory(targetAccount.getAddress(), key, originalMessage, signerAccount.getAddress(), targetNamespaceId)).maxFee(maxFee).build();
    announceAggregateAndValidate(type, originalTransaction, signerAccount);
    assertMetadata(targetNamespaceId, key, originalMessage, metadataRepository, signerAccount);
    NamespaceMetadataTransaction updateTransaction = get(service.createNamespaceMetadataTransactionFactory(targetAccount.getAddress(), key, newMessage, signerAccount.getAddress(), targetNamespaceId)).maxFee(maxFee).build();
    announceAggregateAndValidate(type, updateTransaction, signerAccount);
    assertMetadata(targetNamespaceId, key, newMessage, metadataRepository, signerAccount);
}
Also used : MetadataTransactionService(io.nem.symbol.sdk.api.MetadataTransactionService) NamespaceMetadataTransaction(io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransaction) Account(io.nem.symbol.sdk.model.account.Account) MetadataRepository(io.nem.symbol.sdk.api.MetadataRepository) BigInteger(java.math.BigInteger) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.

the class TestnetTester method main.

public static void main(String[] args) throws Exception {
    String baseUrl = "http://api-01.us-west-2.0.10.0.x.symboldev.network:3000";
    // String baseUrl = "http://api-01.us-west-1.0.10.0.x.symboldev.network:3000";
    // String baseUrl = "http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000";
    RepositoryFactory repositoryFactory = new RepositoryFactoryOkHttpImpl(baseUrl);
    sendVotingKey2(repositoryFactory);
}
Also used : RepositoryFactoryOkHttpImpl(io.nem.symbol.sdk.infrastructure.okhttp.RepositoryFactoryOkHttpImpl) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory)

Example 4 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.

the class MerkleLoaderIntegrationTest method metadatas.

public List<Arguments> metadatas() {
    RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
    MetadataRepository repository = repositoryFactory.createMetadataRepository();
    return getArguments(repository, new MetadataSearchCriteria().order(ORDER_BY));
}
Also used : MetadataRepository(io.nem.symbol.sdk.api.MetadataRepository) MetadataSearchCriteria(io.nem.symbol.sdk.api.MetadataSearchCriteria) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory)

Example 5 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.

the class MerkleLoaderIntegrationTest method namespacesMerkles.

@ParameterizedTest
@MethodSource("namespaces")
void namespacesMerkles(NamespaceInfo state, RepositoryType repositoryType) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(repositoryType);
    StateProofServiceImpl service = new StateProofServiceImpl(repositoryFactory);
    StateMerkleProof<NamespaceInfo> proof = get(service.namespace(state));
    Assertions.assertTrue(proof.isValid(), "Invalid proof " + proof.getState().getId().getIdAsHex());
}
Also used : RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)44 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 EnumSource (org.junit.jupiter.params.provider.EnumSource)16 Test (org.junit.jupiter.api.Test)11 BeforeEach (org.junit.jupiter.api.BeforeEach)7 RepositoryFactoryConfiguration (io.nem.symbol.sdk.api.RepositoryFactoryConfiguration)6 Account (io.nem.symbol.sdk.model.account.Account)6 BigInteger (java.math.BigInteger)6 Listener (io.nem.symbol.sdk.api.Listener)5 MetadataRepository (io.nem.symbol.sdk.api.MetadataRepository)5 NamespaceRepository (io.nem.symbol.sdk.api.NamespaceRepository)5 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)5 NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)5 MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)4 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)4 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)4 CurrencyService (io.nem.symbol.sdk.api.CurrencyService)3 MetadataTransactionService (io.nem.symbol.sdk.api.MetadataTransactionService)3 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)3 TransactionService (io.nem.symbol.sdk.api.TransactionService)3