From 322899256ce8c953d8f1d988d18643f218a08eb1 Mon Sep 17 00:00:00 2001 From: Igor Artamonov Date: Tue, 2 Apr 2024 20:18:48 +0100 Subject: [PATCH] solution: make sure EtherJar can parse Sepolia transactions --- .../etherjar/tx/TransactionDecoderSpec.groovy | 34 ++++++++++++++++++- .../src/test/resources/tx-blob-0x9fd491.hex | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 etherjar-tx/src/test/resources/tx-blob-0x9fd491.hex diff --git a/etherjar-tx/src/test/groovy/io/emeraldpay/etherjar/tx/TransactionDecoderSpec.groovy b/etherjar-tx/src/test/groovy/io/emeraldpay/etherjar/tx/TransactionDecoderSpec.groovy index e9d2ccd..37a8576 100644 --- a/etherjar-tx/src/test/groovy/io/emeraldpay/etherjar/tx/TransactionDecoderSpec.groovy +++ b/etherjar-tx/src/test/groovy/io/emeraldpay/etherjar/tx/TransactionDecoderSpec.groovy @@ -426,7 +426,7 @@ class TransactionDecoderSpec extends Specification { Hex.encodeHexString(encoded) == txHex } - def "Parse tx type 0x109332"() { + def "Parse tx type 3 0x109332"() { // tx 0x109332e227bb505e5731fcbe231dc8d9c0136c14300cd34e40097abf72c51105 setup: def txHex = TransactionDecoderSpec.class.getClassLoader().getResourceAsStream("tx-blob-0x109332.hex").text.trim() @@ -465,4 +465,36 @@ class TransactionDecoderSpec extends Specification { then: Hex.encodeHexString(encoded) == txHex } + + def "Parse tx type 3 - sepolia 0x9fd491"() { + // tx 0x9fd49139b36d116b4eb5389eec4065a944792a04cb5c0f1e9a6f31837d5e40ab + setup: + def txHex = TransactionDecoderSpec.class.getClassLoader().getResourceAsStream("tx-blob-0x9fd491.hex").text.trim() + def tx = Hex.decodeHex(txHex) + + when: + def act = decoder.decode(tx) + + then: + act.type == TransactionType.BLOB + with((TransactionWithBlob)act) { + value == Wei.ZERO + chainId == 11155111 + extractFrom() == Address.from("0x8aad4Fa2839a9E2A6dF43Ea0e8e691D0b4b03ED6") + to == Address.from("0x06676d75a43F38BEE9f48a0FFe99f95FDffA9238") + gas == 21_000 + nonce == 7529 + accessList.isEmpty() + transactionId().toHex() == "0x9fd49139b36d116b4eb5389eec4065a944792a04cb5c0f1e9a6f31837d5e40ab" + data.isEmpty() + blobVersionedHashes.size() == 1 + blobVersionedHashes[0].toHex() == "0x0125c9f873a8784a430f9472f3991b42c21da929b2d3800e6925422adc70c26d" + } + + when: + def encoded = TransactionEncoder.DEFAULT.encode(act, true) + + then: + Hex.encodeHexString(encoded) == txHex + } } diff --git a/etherjar-tx/src/test/resources/tx-blob-0x9fd491.hex b/etherjar-tx/src/test/resources/tx-blob-0x9fd491.hex new file mode 100644 index 0000000..20699b6 --- /dev/null +++ b/etherjar-tx/src/test/resources/tx-blob-0x9fd491.hex @@ -0,0 +1 @@ +03f89783aa36a7821d69843b9aca0084b2d05e008252089406676d75a43f38bee9f48a0ffe99f95fdffa92388080c0854d2efc158ae1a00125c9f873a8784a430f9472f3991b42c21da929b2d3800e6925422adc70c26d01a059b9827b25031a4a107eee4704843b945a0f7a142ef7bac5f7566f812e35299ca0124c018c1a0ad629b4e997fcc1f2eefcc918ae88267cd9f5acd99a434908bb5a