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);
}
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));
}
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);
}
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());
}
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);
}
Aggregations