Skip to content

Commit

Permalink
Merge pull request #1434 from zmcNotafraid/issue-1426
Browse files Browse the repository at this point in the history
feat: mempool transaction's tx raw may be nil
  • Loading branch information
zmcNotafraid committed May 12, 2023
2 parents 5eb7f94 + ef4ed67 commit 66b144b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/godwoken_indexer/block/pending_transaction_worker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ defmodule GodwokenIndexer.Block.PendingTransactionWorker do
end

def parse_and_import(eth_hash) do
with {:ok, transaction} <- GodwokenRPC.fetch_mempool_transaction(eth_hash) do
with {:ok, transaction} <- GodwokenRPC.fetch_mempool_transaction(eth_hash),
raw when not is_nil(raw) <- transaction["transaction"]["raw"] do
tx = transaction["transaction"]

pending_transaction_attr =
Expand Down
21 changes: 21 additions & 0 deletions test/godwoken_indexer/block/pending_transaction_worker_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,25 @@ defmodule GodwokenIndexer.Block.PendingTransactionWorkerTest do
assert Repo.aggregate(Polyjuice, :count) == 1
end
end

test "fetch mempool transactions but raw is nil" do
with_mock GodwokenRPC,
fetch_mempool_transaction: fn _eth_hash ->
{:ok,
%{
"status" => "committed",
"transaction" => %{
"hash" => "0x1cfee93deed308e1bba6bf79821737ac66e537474932c137898243b04987554a",
"raw" => nil
},
"signature" =>
"0x98ddd37908d6022a77bdba8d4739ace9599f1c126704cf68add6b57dcd737c596fab8f13d31a2bfad94ebc38c46304e708d02f7bc0cdcc3f5bc1b42fff38d62201"
}}
end do
assert {0, nil} ==
GodwokenIndexer.Block.PendingTransactionWorker.parse_and_import(
"0x019d19911a44651bde39ba6d44a3f0a56cfdccefdf4c2e953ed8ef04e503b0dd"
)
end
end
end

0 comments on commit 66b144b

Please sign in to comment.