Skip to content

Commit ab35060

Browse files
committed
feat: add eth.Byte case to Filter.Accept type switch
Add support for filtering on eth.Byte fields (like tx_type, tx_status) by converting to uint64 in the Filter.Accept type switch. Includes tests for eq, ne, lt, gt operators on eth.Byte type.
1 parent 9e98531 commit ab35060

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

dig/dig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ func (f Filter) Accept(ctx context.Context, pgmut *sync.Mutex, pg wpg.Conn, d an
396396
d = []byte(v)
397397
case eth.Uint64:
398398
d = uint64(v)
399+
case eth.Byte:
400+
d = uint64(v)
399401
}
400402
switch v := d.(type) {
401403
case []byte:

dig/dig_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,47 @@ func TestFilter(t *testing.T) {
430430
eth.Uint64(2),
431431
true,
432432
},
433+
// eth.Byte tests (tx_type, tx_status)
434+
{
435+
Filter{Op: "eq", Arg: []string{"2"}},
436+
eth.Byte(2),
437+
true,
438+
},
439+
{
440+
Filter{Op: "eq", Arg: []string{"2"}},
441+
eth.Byte(118),
442+
false,
443+
},
444+
{
445+
Filter{Op: "ne", Arg: []string{"118"}},
446+
eth.Byte(2),
447+
true,
448+
},
449+
{
450+
Filter{Op: "ne", Arg: []string{"118"}},
451+
eth.Byte(118),
452+
false,
453+
},
454+
{
455+
Filter{Op: "lt", Arg: []string{"118"}},
456+
eth.Byte(2),
457+
true,
458+
},
459+
{
460+
Filter{Op: "lt", Arg: []string{"118"}},
461+
eth.Byte(118),
462+
false,
463+
},
464+
{
465+
Filter{Op: "gt", Arg: []string{"100"}},
466+
eth.Byte(118),
467+
true,
468+
},
469+
{
470+
Filter{Op: "gt", Arg: []string{"100"}},
471+
eth.Byte(2),
472+
false,
473+
},
433474
{
434475
Filter{Op: "eq", Arg: []string{"340282366920938463463374607431768211456"}},
435476
dec2uint256("340282366920938463463374607431768211456"),

0 commit comments

Comments
 (0)