Search in sources :

Example 31 with RepositoryFactory

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

the class FinalizationRepositoryIntegrationTest method getFinalizationProofAtEpochLatest.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getFinalizationProofAtEpochLatest(RepositoryType type) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    FinalizedBlock finalizedBlock = get(repositoryFactory.createChainRepository().getChainInfo()).getLatestFinalizedBlock();
    FinalizationRepository repository = repositoryFactory.createFinalizationRepository();
    FinalizationProof finalizationProof = get(repository.getFinalizationProofAtEpoch(finalizedBlock.getFinalizationEpoch()));
    Assertions.assertEquals(finalizationProof.getFinalizationEpoch(), finalizationProof.getFinalizationEpoch());
    Assertions.assertEquals(finalizationProof.getFinalizationPoint(), finalizationProof.getFinalizationPoint());
    Assertions.assertEquals(finalizationProof.getHeight(), finalizationProof.getHeight());
    Assertions.assertEquals(1, finalizationProof.getVersion());
}
Also used : FinalizationProof(io.nem.symbol.sdk.model.finalization.FinalizationProof) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) FinalizedBlock(io.nem.symbol.sdk.model.blockchain.FinalizedBlock) FinalizationRepository(io.nem.symbol.sdk.api.FinalizationRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 32 with RepositoryFactory

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

the class ListenerIntegrationTest method shouldReturnCosignatureAddedViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
@Disabled
void shouldReturnCosignatureAddedViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    TransactionService transactionService = new TransactionServiceImpl(repositoryFactory);
    Pair<SignedTransaction, SignedTransaction> pair = this.createAggregateBondedTransaction(type);
    System.out.println("Announcing HashLock transaction " + pair.getRight().getHash());
    get(transactionService.announce(listener, pair.getRight()));
    SignedTransaction signedTransaction = pair.getLeft();
    AggregateTransaction announcedTransaction = get(transactionService.announceAggregateBonded(listener, signedTransaction));
    assertEquals(signedTransaction.getHash(), announcedTransaction.getTransactionInfo().get().getHash().get());
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(TransactionType.AGGREGATE_BONDED)).signerPublicKey(this.cosignatoryAccount.getPublicAccount().getPublicKey()))).getData();
    AggregateTransaction transactionToCosign = (AggregateTransaction) transactions.get(0);
    this.announceCosignatureTransaction(transactionToCosign, type);
    CosignatureSignedTransaction cosignatureSignedTransaction = get(listener.cosignatureAdded(this.cosignatoryAccount.getAddress()).take(1));
    assertEquals(cosignatureSignedTransaction.getSigner(), this.cosignatoryAccount2.getPublicAccount());
}
Also used : CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) Listener(io.nem.symbol.sdk.api.Listener) TransactionService(io.nem.symbol.sdk.api.TransactionService) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) 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 33 with RepositoryFactory

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

the class ListenerIntegrationTest method shouldReturnAggregateBondedRemovedTransactionViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
@Disabled
void shouldReturnAggregateBondedRemovedTransactionViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    TransactionService transactionService = new TransactionServiceImpl(repositoryFactory);
    Pair<SignedTransaction, SignedTransaction> pair = this.createAggregateBondedTransaction(type);
    System.out.println("Announcing HashLock transaction " + pair.getRight().getHash());
    get(transactionService.announce(listener, pair.getRight()));
    SignedTransaction signedTransaction = pair.getLeft();
    System.out.println("Announcing Aggregate transaction " + signedTransaction.getHash());
    get(transactionService.announceAggregateBonded(listener, signedTransaction).take(1));
    String transactionHash = get(listener.aggregateBondedRemoved(this.account.getAddress()).take(1));
    assertEquals(signedTransaction.getHash(), transactionHash);
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) TransactionService(io.nem.symbol.sdk.api.TransactionService) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) 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 34 with RepositoryFactory

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

the class AAASetupIntegrationTest method createMultisigAccountBondedUsingNemesis.

@Test
@Order(7)
void createMultisigAccountBondedUsingNemesis() {
    Account multisig = config().getNemesisAccount8();
    RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
    MultisigAccountInfo info = helper().createMultisigAccountBonded(type, multisig, config().getNemesisAccount9(), config().getNemesisAccount10());
    StateProofService service = new StateProofServiceImpl(repositoryFactory);
    StateMerkleProof<MultisigAccountInfo> proof = get(service.multisig(info));
    Assertions.assertTrue(proof.isValid());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) StateProofService(io.nem.symbol.sdk.api.StateProofService) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 35 with RepositoryFactory

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

the class AAASetupIntegrationTest method createMultisigAccountCompleteUsingNemesis.

@Test
@Order(6)
void createMultisigAccountCompleteUsingNemesis() {
    Account multisig = config().getNemesisAccount8();
    System.out.println(multisig.getAddress().plain());
    RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
    MultisigAccountInfo info = helper().createMultisigAccountComplete(type, multisig, config().getNemesisAccount9(), config().getNemesisAccount10());
    StateProofService service = new StateProofServiceImpl(repositoryFactory);
    StateMerkleProof<MultisigAccountInfo> proof = get(service.multisig(info));
    Assertions.assertTrue(proof.isValid());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) StateProofService(io.nem.symbol.sdk.api.StateProofService) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

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