From b58afe73bbcc9c19b14d04c1675490b193002367 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 28 Oct 2025 15:16:26 +0100 Subject: [PATCH] testgen: add tests for eth_getLogs with blockhash --- testgen/generators.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/testgen/generators.go b/testgen/generators.go index 335e04a..99c2587 100644 --- a/testgen/generators.go +++ b/testgen/generators.go @@ -1986,6 +1986,43 @@ var EthGetLogs = MethodTests{ return nil }, }, + { + Name: "blockhash-all", + About: "queries for all logs of a specific block hash", + Run: func(ctx context.Context, t *T) error { + emits := t.chain.txinfo.DynamicFeeEmit + info := emits[len(emits)-1] + hash := t.chain.GetBlock(int(info.Block)).Hash() + result, err := t.eth.FilterLogs(ctx, ethereum.FilterQuery{BlockHash: &hash}) + if err != nil { + return err + } + if len(result) == 0 { + return fmt.Errorf("result contains no logs") + } + return nil + }, + }, + { + Name: "blockhash-filter", + About: "queries for filtered logs of a specific block hash", + Run: func(ctx context.Context, t *T) error { + emits := t.chain.txinfo.DynamicFeeEmit + info := emits[len(emits)-1] + hash := t.chain.GetBlock(int(info.Block)).Hash() + result, err := t.eth.FilterLogs(ctx, ethereum.FilterQuery{ + BlockHash: &hash, + Topics: [][]common.Hash{{*info.LogTopic0}, {*info.LogTopic1}}, + }) + if err != nil { + return err + } + if len(result) == 0 { + return fmt.Errorf("result contains no logs") + } + return nil + }, + }, }, }