Search in sources :

Example 6 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class MultisigRepositoryOkHttpImplTest method getMultisigAccountInfo.

@Test
void getMultisigAccountInfo() throws Exception {
    MultisigAccountInfoDTO dto = createMultisigAccountInfoDTO();
    mockRemoteCall(dto);
    MultisigAccountInfo multisigAccountInfo = repository.getMultisigAccountInfo(account.getAddress()).toFuture().get();
    assertMultisignAccountInfo(multisigAccountInfo);
}
Also used : MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) MultisigAccountInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MultisigAccountInfoDTO) Test(org.junit.jupiter.api.Test)

Example 7 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class MultisigRepositoryVertxImplTest method getMultisigAccountGraphInfo.

@Test
void getMultisigAccountGraphInfo() throws Exception {
    MultisigAccountGraphInfoDTO dto = new MultisigAccountGraphInfoDTO();
    dto.setLevel(10);
    dto.setMultisigEntries(new ArrayList<>());
    dto.getMultisigEntries().add(createMultisigAccountInfoDTO());
    List<MultisigAccountGraphInfoDTO> dtos = new ArrayList<>();
    dtos.add(dto);
    mockRemoteCall(dtos);
    MultisigAccountGraphInfo multisigAccountInfo = repository.getMultisigAccountGraphInfo(account.getAddress()).toFuture().get();
    Assertions.assertEquals(1, multisigAccountInfo.getMultisigEntries().size());
    List<MultisigAccountInfo> multisigAccountInfos = multisigAccountInfo.getMultisigEntries().get(10);
    Assertions.assertEquals(1, multisigAccountInfos.size());
    assertMultisignAccountInfo(multisigAccountInfos.get(0));
}
Also used : MultisigAccountGraphInfo(io.nem.symbol.sdk.model.account.MultisigAccountGraphInfo) ArrayList(java.util.ArrayList) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) MultisigAccountGraphInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.MultisigAccountGraphInfoDTO) Test(org.junit.jupiter.api.Test)

Example 8 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class AggregateTransactionServiceTest method getMaxCosignatures.

@Test
void getMaxCosignatures() throws ExecutionException, InterruptedException {
    Map<Integer, List<MultisigAccountInfo>> infoMap = new HashMap<>();
    MultisigAccountInfo multisigAccountInfo1 = new MultisigAccountInfo("a", 1, multisig1.getAddress(), 1, 1, Arrays.asList(account1.getAddress(), account2.getAddress(), account3.getAddress()), Collections.emptyList());
    infoMap.put(-3, Collections.singletonList(multisigAccountInfo1));
    MultisigAccountInfo multisigAccountInfo2 = new MultisigAccountInfo("a", 1, multisig2.getAddress(), 1, 1, Arrays.asList(account4.getAddress(), account2.getAddress(), account3.getAddress()), Collections.emptyList());
    infoMap.put(-2, Collections.singletonList(multisigAccountInfo2));
    MultisigAccountGraphInfo multisigAccountGraphInfo = new MultisigAccountGraphInfo(infoMap);
    Mockito.when(multisigRepository.getMultisigAccountGraphInfo(Mockito.eq(account1.getAddress()))).thenReturn(Observable.just(multisigAccountGraphInfo));
    Integer maxConsignatures = service.getMaxCosignatures(account1.getAddress()).toFuture().get();
    Assertions.assertEquals(4, maxConsignatures);
}
Also used : BigInteger(java.math.BigInteger) MultisigAccountGraphInfo(io.nem.symbol.sdk.model.account.MultisigAccountGraphInfo) HashMap(java.util.HashMap) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 9 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class StateProofServiceTest method multisig.

@Test
void multisig() throws Exception {
    MultisigRepository repository = mock(MultisigRepository.class);
    when(factory.createMultisigRepository()).thenReturn(repository);
    Address id = Address.generateRandom(NetworkType.MIJIN_TEST);
    MultisigAccountInfo state = Mockito.mock(MultisigAccountInfo.class);
    when(state.getAccountAddress()).thenReturn(id);
    when(state.serialize()).thenReturn(ConvertUtils.fromHexToBytes(serialized));
    when(repository.getMultisigAccountInfo(eq(id))).thenReturn(Observable.just(state));
    when(repository.getMultisigAccountInfoMerkle(eq(id))).thenReturn(Observable.just(tree));
    StateMerkleProof<MultisigAccountInfo> proof = service.multisig(id).toFuture().get();
    Assertions.assertTrue(proof.isValid());
    Assertions.assertEquals(state, proof.getState());
}
Also used : MultisigRepository(io.nem.symbol.sdk.api.MultisigRepository) Address(io.nem.symbol.sdk.model.account.Address) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) Test(org.junit.jupiter.api.Test)

Example 10 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class ListenerIntegrationTest method getAllMultisigAddressesAndAliasesWhenMultisig.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAllMultisigAddressesAndAliasesWhenMultisig(RepositoryType type) {
    final MultisigAccountInfo multisigAccountInfo = get(getRepositoryFactory(type).createMultisigRepository().getMultisigAccountInfo(this.multisigAccount.getAddress()));
    Assertions.assertEquals(Arrays.asList(this.cosignatoryAccount.getAddress(), this.cosignatoryAccount2.getAddress()), multisigAccountInfo.getCosignatoryAddresses());
    Set<NamespaceId> aliases = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Arrays.asList(multisigAccount.getAddress(), cosignatoryAccount.getAddress(), cosignatoryAccount2.getAddress()))).stream().flatMap(a -> a.getNames().stream().map(n -> n.getNamespaceId())).collect(Collectors.toSet());
    Listener listener = getRepositoryFactory(type).createListener();
    final Set<UnresolvedAddress> unresolvedAddresses = get(listener.getAllMultisigAddressesAndAliases(this.multisigAccount.getAddress()));
    final Set<UnresolvedAddress> expectedAddresees = Sets.newSet(this.multisigAccount.getAddress(), this.cosignatoryAccount.getAddress(), this.cosignatoryAccount2.getAddress());
    expectedAddresees.addAll(aliases);
    Assertions.assertEquals(expectedAddresees, unresolvedAddresses);
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) FinalizedBlock(io.nem.symbol.sdk.model.blockchain.FinalizedBlock) BeforeEach(org.junit.jupiter.api.BeforeEach) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) Arrays(java.util.Arrays) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) HashLockTransactionFactory(io.nem.symbol.sdk.model.transaction.HashLockTransactionFactory) BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) Account(io.nem.symbol.sdk.model.account.Account) CompletableFuture(java.util.concurrent.CompletableFuture) EnumSource(org.junit.jupiter.params.provider.EnumSource) TransactionStatusError(io.nem.symbol.sdk.model.transaction.TransactionStatusError) 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) Sets(org.mockito.internal.util.collections.Sets) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) Pair(org.apache.commons.lang3.tuple.Pair) TransactionService(io.nem.symbol.sdk.api.TransactionService) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Listener(io.nem.symbol.sdk.api.Listener) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) NamespaceName(io.nem.symbol.sdk.model.namespace.NamespaceName) Set(java.util.Set) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) 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.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) 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) Listener(io.nem.symbol.sdk.api.Listener) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MultisigAccountInfo (io.nem.symbol.sdk.model.account.MultisigAccountInfo)16 Test (org.junit.jupiter.api.Test)9 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)7 Account (io.nem.symbol.sdk.model.account.Account)6 MultisigRepository (io.nem.symbol.sdk.api.MultisigRepository)5 Address (io.nem.symbol.sdk.model.account.Address)5 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)5 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)5 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)5 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)5 List (java.util.List)5 MultisigAccountGraphInfo (io.nem.symbol.sdk.model.account.MultisigAccountGraphInfo)4 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)4 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)4 Observable (io.reactivex.Observable)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Listener (io.nem.symbol.sdk.api.Listener)3 RepositoryCallException (io.nem.symbol.sdk.api.RepositoryCallException)3 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)3