use of io.nem.symbol.sdk.openapi.vertx.model.Cosignature in project nem2-sdk-java by nemtech.
the class ListenerVertxTest method cosignatureAdded.
@Test
public void cosignatureAdded() throws InterruptedException, ExecutionException, TimeoutException {
simulateWebSocketStartup();
ListenerChannel consignature = ListenerChannel.COSIGNATURE;
NetworkType networkType = NETWORK_TYPE;
Cosignature cosignature = new Cosignature().parentHash("aParentHash").signature("aSignature").version(BigInteger.ONE).signerPublicKey(Account.generateNewAccount(networkType).getPublicKey());
ObjectNode transactionInfoDtoJsonObject = jsonHelper.convert(cosignature, ObjectNode.class);
Address address = Address.createFromPublicKey(cosignature.getSignerPublicKey(), networkType);
String channelName = consignature.toString();
List<CosignatureSignedTransaction> transactions = new ArrayList<>();
listener.cosignatureAdded(address).forEach(transactions::add);
handle(transactionInfoDtoJsonObject, consignature.toString() + "/" + address.plain());
Assertions.assertEquals(1, transactions.size());
Assertions.assertEquals(cosignature.getSignerPublicKey(), transactions.get(0).getSigner().getPublicKey().toHex());
Assertions.assertEquals(cosignature.getParentHash(), transactions.get(0).getParentHash());
Assertions.assertEquals(cosignature.getSignature(), transactions.get(0).getSignature());
Mockito.verify(webSocketMock).handler(Mockito.any());
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName + "/" + address.plain())));
}
use of io.nem.symbol.sdk.openapi.vertx.model.Cosignature in project nem2-sdk-java by nemtech.
the class TransactionRepositoryVertxImplTest method announceAggregateBondedCosignature.
@Test
public void announceAggregateBondedCosignature() throws Exception {
Account signer = Account.generateNewAccount(networkType);
BigInteger version = AggregateTransactionCosignature.DEFAULT_VERSION;
CosignatureSignedTransaction signedTransaction = new CosignatureSignedTransaction(version, "aParentHash", "aSignature", signer.getPublicAccount());
AnnounceTransactionInfoDTO announceTransactionInfoDTO = new AnnounceTransactionInfoDTO();
announceTransactionInfoDTO.setMessage("SomeMessage");
ArgumentCaptor<Object> parameter = mockRemoteCall(announceTransactionInfoDTO);
TransactionAnnounceResponse response = repository.announceAggregateBondedCosignature(signedTransaction).toFuture().get();
Assertions.assertNotNull(response);
Assertions.assertEquals(announceTransactionInfoDTO.getMessage(), announceTransactionInfoDTO.getMessage());
Cosignature cosignature = (Cosignature) parameter.getValue();
Assertions.assertEquals(signedTransaction.getParentHash(), cosignature.getParentHash());
Assertions.assertEquals(signedTransaction.getSignature(), cosignature.getSignature());
Assertions.assertEquals(signedTransaction.getSigner().getPublicKey().toHex(), cosignature.getSignerPublicKey());
Assertions.assertEquals(signedTransaction.getVersion(), cosignature.getVersion());
}
Aggregations