Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return block hash for eth_getTransactionReceipt #122

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ impl<S: Send + Sync + 'static + ForkSource + std::fmt::Debug> EthNamespaceT for
let receipt = tx_result.map(|info| TransactionReceipt {
transaction_hash: hash,
transaction_index: U64::from(1),
block_hash: Some(hash),
block_hash: reader.block_hashes.get(&info.miniblock_number).cloned(),
block_number: Some(U64::from(info.miniblock_number)),
l1_batch_tx_index: None,
l1_batch_number: Some(U64::from(info.batch_number as u64)),
Expand Down Expand Up @@ -2536,4 +2536,19 @@ mod tests {
);
}
}

#[tokio::test]
async fn test_get_transaction_receipt_uses_produced_block_hash() {
let node = InMemoryNode::<HttpForkSource>::default();
let tx_hash = H256::repeat_byte(0x01);
let expected_block_hash = testing::apply_tx(&node, tx_hash);

let actual_tx_receipt = node
.get_transaction_receipt(tx_hash)
.await
.expect("failed fetching transaction receipt by hash")
.expect("no transaction receipt");

assert_eq!(Some(expected_block_hash), actual_tx_receipt.block_hash);
}
}
Loading