Skip to content

Commit 6dfbbc3

Browse files
committed
Merge pull request #1948 from bas-vk/rpcfix
Infinite loop in filters
2 parents 5ff0814 + 76410df commit 6dfbbc3

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

rpc/api/args_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,13 +1394,10 @@ func TestBlockFilterArgsDefaults(t *testing.T) {
13941394
}
13951395

13961396
func TestBlockFilterArgsWords(t *testing.T) {
1397-
input := `[{
1398-
"fromBlock": "latest",
1399-
"toBlock": "pending"
1400-
}]`
1397+
input := `[{"fromBlock": "latest", "toBlock": "latest"}]`
14011398
expected := new(BlockFilterArgs)
14021399
expected.Earliest = -1
1403-
expected.Latest = -2
1400+
expected.Latest = -1
14041401

14051402
args := new(BlockFilterArgs)
14061403
if err := json.Unmarshal([]byte(input), &args); err != nil {
@@ -1411,8 +1408,9 @@ func TestBlockFilterArgsWords(t *testing.T) {
14111408
t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest)
14121409
}
14131410

1414-
if expected.Latest != args.Latest {
1415-
t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest)
1411+
input = `[{"toBlock": "pending"}]`
1412+
if err := json.Unmarshal([]byte(input), &args); err == nil {
1413+
t.Errorf("Pending isn't currently supported and should raise an unsupported error")
14161414
}
14171415
}
14181416

rpc/api/eth_args.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,13 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
722722
return err
723723
}
724724
}
725+
726+
if num == -2 {
727+
return fmt.Errorf("\"pending\" is unsupported")
728+
} else if num < -2 {
729+
return fmt.Errorf("Invalid to block number")
730+
}
731+
725732
args.Latest = num
726733

727734
if obj[0].Limit == nil {

0 commit comments

Comments
 (0)