@@ -306,8 +306,6 @@ void accountInfoFlowFunctions() throws Throwable {
306306 .setNodeAccountIds (List .of (AccountId .fromString ("0.0.3" )))
307307 .freeze ();
308308
309- var properlySignedTx = makeTx .get ().sign (privateKey );
310- var improperlySignedTx = makeTx .get ().sign (otherPrivateKey );
311309 var properBigBytesSignature = privateKey .sign (BIG_BYTES );
312310 var improperBigBytesSignature = otherPrivateKey .sign (BIG_BYTES );
313311
@@ -331,28 +329,19 @@ void accountInfoFlowFunctions() throws Throwable {
331329 .build ()));
332330 }
333331
334- Assertions .assertTrue (AccountInfoFlow .verifyTransactionSignature (server .client , accountId , properlySignedTx ));
335- Assertions .assertFalse (
336- AccountInfoFlow .verifyTransactionSignature (server .client , accountId , improperlySignedTx ));
337332 Assertions .assertTrue (
338333 AccountInfoFlow .verifySignature (server .client , accountId , BIG_BYTES , properBigBytesSignature ));
339334 Assertions .assertFalse (
340335 AccountInfoFlow .verifySignature (server .client , accountId , BIG_BYTES , improperBigBytesSignature ));
341- Assertions .assertTrue (
342- AccountInfoFlow .verifyTransactionSignatureAsync (server .client , accountId , properlySignedTx )
343- .get ());
344- Assertions .assertFalse (
345- AccountInfoFlow .verifyTransactionSignatureAsync (server .client , accountId , improperlySignedTx )
346- .get ());
347336 Assertions .assertTrue (
348337 AccountInfoFlow .verifySignatureAsync (server .client , accountId , BIG_BYTES , properBigBytesSignature )
349338 .get ());
350339 Assertions .assertFalse (
351340 AccountInfoFlow .verifySignatureAsync (server .client , accountId , BIG_BYTES , improperBigBytesSignature )
352341 .get ());
353342
354- Assertions .assertEquals (16 , cryptoService .buffer .queryRequestsReceived .size ());
355- for (int i = 0 ; i < 16 ; i += 2 ) {
343+ Assertions .assertEquals (8 , cryptoService .buffer .queryRequestsReceived .size ());
344+ for (int i = 0 ; i < 8 ; i += 2 ) {
356345 var costQueryRequest = cryptoService .buffer .queryRequestsReceived .get (i );
357346 var queryRequest = cryptoService .buffer .queryRequestsReceived .get (i + 1 );
358347
@@ -370,6 +359,60 @@ void accountInfoFlowFunctions() throws Throwable {
370359 server .close ();
371360 }
372361
362+ @ Test
363+ void testVerifyTransactionFail () throws InvalidProtocolBufferException {
364+ var key = PrivateKey .generateED25519 ();
365+ var bogusSignature = new byte [64 ];
366+
367+ var serialized = new TokenMintTransaction ()
368+ .setTokenId (TokenId .fromString ("1.2.3" ))
369+ .setAmount (5 )
370+ .setTransactionId (TransactionId .generate (AccountId .fromString ("1.2.4" )))
371+ .setNodeAccountIds (List .of (AccountId .fromString ("0.0.3" )))
372+ .freeze ()
373+ .addSignature (key .getPublicKey (), bogusSignature )
374+ .toBytes ();
375+
376+ var signedTransaction = SignedTransaction .parseFrom (
377+ com .hedera .hashgraph .sdk .proto .Transaction .parseFrom (serialized ).getSignedTransactionBytes ());
378+ com .hedera .hashgraph .sdk .Transaction <?> roundTrip = com .hedera .hashgraph .sdk .Transaction .fromBytes (serialized );
379+
380+ boolean rawVerify =
381+ key .getPublicKey ().verify (signedTransaction .getBodyBytes ().toByteArray (), bogusSignature );
382+ boolean txVerify = key .getPublicKey ().verifyTransaction (roundTrip );
383+
384+ Assertions .assertFalse (rawVerify );
385+ Assertions .assertFalse (txVerify );
386+ }
387+
388+ @ Test
389+ void testVerifyTransactionFailSpecificNode () throws InvalidProtocolBufferException {
390+ var key = PrivateKey .generateED25519 ();
391+ var bogusSignature = new byte [64 ];
392+ TransactionId transactionId = TransactionId .generate (AccountId .fromString ("1.2.4" ));
393+ List <AccountId > nodeId = List .of (AccountId .fromString ("0.0.3" ));
394+
395+ var serialized = new TokenMintTransaction ()
396+ .setTokenId (TokenId .fromString ("1.2.3" ))
397+ .setAmount (5 )
398+ .setTransactionId (transactionId )
399+ .setNodeAccountIds (nodeId )
400+ .freeze ()
401+ .addSignature (key .getPublicKey (), bogusSignature , transactionId , nodeId .getFirst ())
402+ .toBytes ();
403+
404+ var signedTransaction = SignedTransaction .parseFrom (
405+ com .hedera .hashgraph .sdk .proto .Transaction .parseFrom (serialized ).getSignedTransactionBytes ());
406+ com .hedera .hashgraph .sdk .Transaction <?> roundTrip = com .hedera .hashgraph .sdk .Transaction .fromBytes (serialized );
407+
408+ boolean rawVerify =
409+ key .getPublicKey ().verify (signedTransaction .getBodyBytes ().toByteArray (), bogusSignature );
410+ boolean txVerify = key .getPublicKey ().verifyTransaction (roundTrip );
411+
412+ Assertions .assertFalse (rawVerify );
413+ Assertions .assertFalse (txVerify );
414+ }
415+
373416 @ Test
374417 void exitOnAborted () throws PrecheckStatusException , TimeoutException , InterruptedException {
375418 List <Object > responses1 = List .of ();
0 commit comments