@@ -212,7 +212,7 @@ public void shouldNotScheduleGetPooledTransactionsTaskTwice() {
212212 public void shouldCreateAndDecodeForEth66 () {
213213
214214 final List <TransactionAnnouncement > expectedAnnouncementList =
215- transactionList .stream ().map (TransactionAnnouncement ::new ).collect ( Collectors . toList () );
215+ transactionList .stream ().map (TransactionAnnouncement ::new ).toList ();
216216
217217 final NewPooledTransactionHashesMessage message =
218218 NewPooledTransactionHashesMessage .create (transactionList , EthProtocol .ETH66 );
@@ -268,7 +268,7 @@ public void shouldThrowRLPExceptionIfIncorrectVersion() {
268268 public void shouldEncodeTransactionsCorrectly_Eth68 () {
269269
270270 final String expected =
271- "0xf879c3000102cf840000000184000000028400000003f863a00000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000003 " ;
271+ "0xf87983000102cf840000000184000000028400000003f863a00000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000003 " ;
272272 final List <Hash > hashes =
273273 List .of (
274274 Hash .fromHexString (
@@ -289,7 +289,7 @@ public void shouldEncodeTransactionsCorrectly_Eth68() {
289289 public void shouldDecodeBytesCorrectly_Eth68 () {
290290 /*
291291 * [
292- * ["0x00","0x01","0x02 "]
292+ * "0x0000102 "]
293293 * ["0x00000001","0x00000002","0x00000003"],
294294 * ["0x0000000000000000000000000000000000000000000000000000000000000001",
295295 * "0x0000000000000000000000000000000000000000000000000000000000000002",
@@ -299,7 +299,7 @@ public void shouldDecodeBytesCorrectly_Eth68() {
299299
300300 final Bytes bytes =
301301 Bytes .fromHexString (
302- "0xf879c3000102cf840000000184000000028400000003f863a00000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000003 " );
302+ "0xf87983000102cf840000000184000000028400000003f863a00000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000003 " );
303303
304304 final List <TransactionAnnouncement > announcementList =
305305 getDecoder (EthProtocol .ETH68 ).decode (RLP .input (bytes ));
@@ -375,9 +375,8 @@ public void shouldThrowInvalidArgumentExceptionWhenCreatingListsWithDifferentSiz
375375 final Exception exception =
376376 assertThrows (
377377 IllegalArgumentException .class ,
378- () -> {
379- TransactionAnnouncement .create (new ArrayList <>(), List .of (1L ), new ArrayList <>());
380- });
378+ () ->
379+ TransactionAnnouncement .create (new ArrayList <>(), List .of (1L ), new ArrayList <>()));
381380 final String expectedMessage = "Hashes, sizes and types must have the same number of elements" ;
382381 final String actualMessage = exception .getMessage ();
383382 assertThat (actualMessage ).isEqualTo (expectedMessage );
@@ -388,10 +387,9 @@ public void shouldThrowInvalidArgumentExceptionWhenEncodingListsWithDifferentSiz
388387 final Exception exception =
389388 assertThrows (
390389 IllegalArgumentException .class ,
391- () -> {
392- TransactionAnnouncementEncoder .encodeForEth68 (
393- new ArrayList <>(), List .of (1 ), new ArrayList <>());
394- });
390+ () ->
391+ TransactionAnnouncementEncoder .encodeForEth68 (
392+ new ArrayList <>(), List .of (1 ), new ArrayList <>()));
395393 final String expectedMessage = "Hashes, sizes and types must have the same number of elements" ;
396394 final String actualMessage = exception .getMessage ();
397395 assertThat (actualMessage ).isEqualTo (expectedMessage );
@@ -401,18 +399,17 @@ public void shouldThrowInvalidArgumentExceptionWhenEncodingListsWithDifferentSiz
401399 @ SuppressWarnings ("UnusedVariable" )
402400 public void shouldThrowRLPExceptionWhenDecodingListsWithDifferentSizes () {
403401
404- // [[] ,[],["0x881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351"]]
402+ // ["0x000102" ,[],["0x881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351"]]
405403 final Bytes invalidMessageBytes =
406404 Bytes .fromHexString (
407- "0xe4c0c0e1a0881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351 " );
405+ "0xe783000102c0e1a0881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351 " );
408406
409407 final Exception exception =
410408 assertThrows (
411409 RLPException .class ,
412- () -> {
413- TransactionAnnouncementDecoder .getDecoder (EthProtocol .ETH68 )
414- .decode (RLP .input (invalidMessageBytes ));
415- });
410+ () ->
411+ TransactionAnnouncementDecoder .getDecoder (EthProtocol .ETH68 )
412+ .decode (RLP .input (invalidMessageBytes )));
416413
417414 final String expectedMessage = "Hashes, sizes and types must have the same number of elements" ;
418415 final String actualMessage = exception .getMessage ();
@@ -423,38 +420,36 @@ public void shouldThrowRLPExceptionWhenDecodingListsWithDifferentSizes() {
423420 public void shouldThrowRLPExceptionWhenTypeIsInvalid () {
424421 final Bytes invalidMessageBytes =
425422 Bytes .fromHexString (
426- // [["0x09"] ,["0x00000002"],["0x881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351"]]
427- "0xeac109c58400000002e1a0881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351 " );
423+ // ["0x07" ,["0x00000002"],["0x881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351"]]
424+ "0xe907c58400000002e1a0881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351 " );
428425
429426 final Exception exception =
430427 assertThrows (
431- RLPException .class ,
432- () -> {
433- TransactionAnnouncementDecoder .getDecoder (EthProtocol .ETH68 )
434- .decode (RLP .input (invalidMessageBytes ));
435- });
428+ IllegalArgumentException .class ,
429+ () ->
430+ TransactionAnnouncementDecoder .getDecoder (EthProtocol .ETH68 )
431+ .decode (RLP .input (invalidMessageBytes )));
436432
437433 final String expectedMessage = "Unsupported transaction type" ;
438- final String actualMessage = exception .getCause (). getMessage ();
434+ final String actualMessage = exception .getMessage ();
439435 assertThat (actualMessage ).contains (expectedMessage );
440436 }
441437
442438 @ Test
443439 public void shouldThrowRLPExceptionWhenSizeSizeGreaterThanFourBytes () {
444440 final Bytes invalidMessageBytes =
445441 Bytes .fromHexString (
446- // [[ "0x02"] ,["0xffffffff01"],["0x881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351"]]
447- "0xebc102c685ffffffff00e1a0881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351 " );
442+ // ["0x02",["0xffffffff01"],["0x881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351"]]
443+ "0xea02c685ffffffff00e1a0881699519a25b0e32db9b1ba9981f3fbec93fbc0726c3e096af89e5ada2b1351 " );
448444
449445 final Exception exception =
450446 assertThrows (
451447 RLPException .class ,
452- () -> {
453- TransactionAnnouncementDecoder .getDecoder (EthProtocol .ETH68 )
454- .decode (RLP .input (invalidMessageBytes ));
455- });
448+ () ->
449+ TransactionAnnouncementDecoder .getDecoder (EthProtocol .ETH68 )
450+ .decode (RLP .input (invalidMessageBytes )));
456451
457- final String expectedMessage = "Cannot read a 4-byte int " ;
452+ final String expectedMessage = "Value of size 5 has more than 4 bytes " ;
458453 final String actualMessage = exception .getCause ().getMessage ();
459454 assertThat (actualMessage ).contains (expectedMessage );
460455 }
0 commit comments