File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -1394,13 +1394,10 @@ func TestBlockFilterArgsDefaults(t *testing.T) {
1394
1394
}
1395
1395
1396
1396
func TestBlockFilterArgsWords (t * testing.T ) {
1397
- input := `[{
1398
- "fromBlock": "latest",
1399
- "toBlock": "pending"
1400
- }]`
1397
+ input := `[{"fromBlock": "latest", "toBlock": "latest"}]`
1401
1398
expected := new (BlockFilterArgs )
1402
1399
expected .Earliest = - 1
1403
- expected .Latest = - 2
1400
+ expected .Latest = - 1
1404
1401
1405
1402
args := new (BlockFilterArgs )
1406
1403
if err := json .Unmarshal ([]byte (input ), & args ); err != nil {
@@ -1411,8 +1408,9 @@ func TestBlockFilterArgsWords(t *testing.T) {
1411
1408
t .Errorf ("Earliest shoud be %#v but is %#v" , expected .Earliest , args .Earliest )
1412
1409
}
1413
1410
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" )
1416
1414
}
1417
1415
}
1418
1416
Original file line number Diff line number Diff line change @@ -714,6 +714,13 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
714
714
return err
715
715
}
716
716
}
717
+
718
+ if num == - 2 {
719
+ return fmt .Errorf ("\" pending\" is unsupported" )
720
+ } else if num < - 2 {
721
+ return fmt .Errorf ("Invalid to block number" )
722
+ }
723
+
717
724
args .Latest = num
718
725
719
726
if obj [0 ].Limit == nil {
You can’t perform that action at this time.
0 commit comments