aboutsummaryrefslogtreecommitdiffstats
path: root/eth/filters/api_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-09-27 18:14:52 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-09-27 18:14:52 +0800
commit2ab2a9f13116748ca343892f851e3632861c994e (patch)
tree97e5cc5dc3b07dbcdc6a73adfbfb07acf816d35f /eth/filters/api_test.go
parent860e697b00c25b8f47371f8b8c7342d0230cee84 (diff)
downloadgo-tangerine-2ab2a9f13116748ca343892f851e3632861c994e.tar
go-tangerine-2ab2a9f13116748ca343892f851e3632861c994e.tar.gz
go-tangerine-2ab2a9f13116748ca343892f851e3632861c994e.tar.bz2
go-tangerine-2ab2a9f13116748ca343892f851e3632861c994e.tar.lz
go-tangerine-2ab2a9f13116748ca343892f851e3632861c994e.tar.xz
go-tangerine-2ab2a9f13116748ca343892f851e3632861c994e.tar.zst
go-tangerine-2ab2a9f13116748ca343892f851e3632861c994e.zip
core/bloombits, eth/filters: handle null topics (#15195)
When implementing the new bloombits based filter, I've accidentally broke null topics by removing the special casing of common.Hash{} filter rules, which acted as the wildcard topic until now. This PR fixes the regression, but instead of using the magic hash common.Hash{} as the null wildcard, the PR reworks the code to handle nil topics during parsing, converting a JSON null into nil []common.Hash topic.
Diffstat (limited to 'eth/filters/api_test.go')
-rw-r--r--eth/filters/api_test.go24
1 files changed, 6 insertions, 18 deletions
diff --git a/eth/filters/api_test.go b/eth/filters/api_test.go
index 068a5ea24..4ae37f977 100644
--- a/eth/filters/api_test.go
+++ b/eth/filters/api_test.go
@@ -34,7 +34,6 @@ func TestUnmarshalJSONNewFilterArgs(t *testing.T) {
topic0 = common.HexToHash("3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1ca")
topic1 = common.HexToHash("9084a792d2f8b16a62b882fd56f7860c07bf5fa91dd8a2ae7e809e5180fef0b3")
topic2 = common.HexToHash("6ccae1c4af4152f460ff510e573399795dfab5dcf1fa60d1f33ac8fdc1e480ce")
- nullTopic = common.Hash{}
)
// default values
@@ -150,11 +149,8 @@ func TestUnmarshalJSONNewFilterArgs(t *testing.T) {
if test6.Topics[0][0] != topic0 {
t.Fatalf("got %x, expected %x", test6.Topics[0][0], topic0)
}
- if len(test6.Topics[1]) != 1 {
- t.Fatalf("expected 1 topic, got %d", len(test6.Topics[1]))
- }
- if test6.Topics[1][0] != nullTopic {
- t.Fatalf("got %x, expected empty hash", test6.Topics[1][0])
+ if len(test6.Topics[1]) != 0 {
+ t.Fatalf("expected 0 topic, got %d", len(test6.Topics[1]))
}
if len(test6.Topics[2]) != 1 {
t.Fatalf("expected 1 topic, got %d", len(test6.Topics[2]))
@@ -180,18 +176,10 @@ func TestUnmarshalJSONNewFilterArgs(t *testing.T) {
topic0, topic1, test7.Topics[0][0], test7.Topics[0][1],
)
}
- if len(test7.Topics[1]) != 1 {
- t.Fatalf("expected 1 topic, got %d topics", len(test7.Topics[1]))
- }
- if test7.Topics[1][0] != nullTopic {
- t.Fatalf("expected empty hash, got %x", test7.Topics[1][0])
- }
- if len(test7.Topics[2]) != 2 {
- t.Fatalf("expected 2 topics, got %d topics", len(test7.Topics[2]))
+ if len(test7.Topics[1]) != 0 {
+ t.Fatalf("expected 0 topic, got %d topics", len(test7.Topics[1]))
}
- if test7.Topics[2][0] != topic2 || test7.Topics[2][1] != nullTopic {
- t.Fatalf("invalid topics expected [%x,%x], got [%x,%x]",
- topic2, nullTopic, test7.Topics[2][0], test7.Topics[2][1],
- )
+ if len(test7.Topics[2]) != 0 {
+ t.Fatalf("expected 0 topics, got %d topics", len(test7.Topics[2]))
}
}