Search in sources :

Example 1 with Cosignature

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())));
}
Also used : CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Address(io.nem.symbol.sdk.model.account.Address) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) ListenerChannel(io.nem.symbol.sdk.infrastructure.ListenerChannel) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) ArrayList(java.util.ArrayList) Cosignature(io.nem.symbol.sdk.openapi.vertx.model.Cosignature) ListenerSubscribeMessage(io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with Cosignature

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());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) BigInteger(java.math.BigInteger) AnnounceTransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO) TransactionAnnounceResponse(io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse) Cosignature(io.nem.symbol.sdk.openapi.vertx.model.Cosignature) AggregateTransactionCosignature(io.nem.symbol.sdk.model.transaction.AggregateTransactionCosignature) Test(org.junit.jupiter.api.Test)

Aggregations

CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)2 Cosignature (io.nem.symbol.sdk.openapi.vertx.model.Cosignature)2 Test (org.junit.jupiter.api.Test)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ListenerChannel (io.nem.symbol.sdk.infrastructure.ListenerChannel)1 ListenerSubscribeMessage (io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage)1 Account (io.nem.symbol.sdk.model.account.Account)1 Address (io.nem.symbol.sdk.model.account.Address)1 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)1 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)1 NetworkType (io.nem.symbol.sdk.model.network.NetworkType)1 AggregateTransactionCosignature (io.nem.symbol.sdk.model.transaction.AggregateTransactionCosignature)1 TransactionAnnounceResponse (io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse)1 AnnounceTransactionInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1