use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.
the class MerkleLoaderIntegrationTest method multisigMerkles.
@Test
void multisigMerkles() {
RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
MultisigAccountInfo state = get(repositoryFactory.createMultisigRepository().getMultisigAccountInfo(Address.createFromRawAddress("TCFAEINOWAAPSGT2OCBCZYMH2Q3PGHQPEYTIUKI")));
StateProofServiceImpl service = new StateProofServiceImpl(repositoryFactory);
StateMerkleProof<MultisigAccountInfo> proof = get(service.multisig(state));
Assertions.assertTrue(proof.isValid(), "Invalid proof " + proof.getState().getAccountAddress().plain());
}
use of io.nem.symbol.sdk.model.account.MultisigAccountInfo 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());
}
use of io.nem.symbol.sdk.model.account.MultisigAccountInfo 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());
}
use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.
the class TestHelper method isMultisig.
public boolean isMultisig(RepositoryType type, Account multisigAccount) {
try {
MultisigRepository multisigRepository = getRepositoryFactory(type).createMultisigRepository();
MultisigAccountInfo multisigAccountInfo = get(multisigRepository.getMultisigAccountInfo(multisigAccount.getAddress()));
return multisigAccountInfo != null;
} catch (RepositoryCallException e) {
Assertions.assertEquals(404, e.getStatusCode());
return false;
}
}
use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.
the class TestHelper method createMultisigAccountComplete.
public MultisigAccountInfo createMultisigAccountComplete(RepositoryType type, Account multisigAccount, Account... accounts) {
AccountRepository accountRepository = getRepositoryFactory(type).createAccountRepository();
MultisigRepository multisigRepository = getRepositoryFactory(type).createMultisigRepository();
AccountInfo accountInfo = get(accountRepository.getAccountInfo(multisigAccount.getAddress()));
System.out.println(getJsonHelper().print(accountInfo));
try {
MultisigAccountInfo multisigAccountInfo = get(multisigRepository.getMultisigAccountInfo(multisigAccount.getAddress()));
System.out.println("Multisig account with address " + multisigAccount.getAddress().plain() + " already exist");
System.out.println(getJsonHelper().print(multisigAccountInfo));
return multisigAccountInfo;
} catch (RepositoryCallException e) {
System.out.println("Multisig account with address " + multisigAccount.getAddress().plain() + " does not exist. Creating");
}
System.out.println("Creating multisg account " + multisigAccount.getAddress().plain());
List<UnresolvedAddress> additions = Arrays.stream(accounts).map(Account::getAddress).collect(Collectors.toList());
MultisigAccountModificationTransaction convertIntoMultisigTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, additions, Collections.emptyList()).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(convertIntoMultisigTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Arrays.asList(accounts), getGenerationHash());
Transaction aggregateTransaciton = get(getTransactionService(type).announce(getListener(type), signedAggregateTransaction));
sleep(1000);
Assertions.assertEquals(aggregateTransaciton.getTransactionInfo().get().getHash().get(), signedAggregateTransaction.getHash());
return get(multisigRepository.getMultisigAccountInfo(multisigAccount.getAddress()));
}
Aggregations