aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-11-03 22:22:02 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-11-03 22:22:02 +0800
commit6dfbbc3e11cd5c88ed7d4311b30222d5c3f6cd0f (patch)
tree05e98fb000bb7182115784d881afb55b7af8a956 /rpc/api
parent5ff0814b1f4f739cc7d9d244fa5855d28061194a (diff)
parent76410df6a21a10dec09ca955b1896ac083853ef7 (diff)
downloaddexon-6dfbbc3e11cd5c88ed7d4311b30222d5c3f6cd0f.tar
dexon-6dfbbc3e11cd5c88ed7d4311b30222d5c3f6cd0f.tar.gz
dexon-6dfbbc3e11cd5c88ed7d4311b30222d5c3f6cd0f.tar.bz2
dexon-6dfbbc3e11cd5c88ed7d4311b30222d5c3f6cd0f.tar.lz
dexon-6dfbbc3e11cd5c88ed7d4311b30222d5c3f6cd0f.tar.xz
dexon-6dfbbc3e11cd5c88ed7d4311b30222d5c3f6cd0f.tar.zst
dexon-6dfbbc3e11cd5c88ed7d4311b30222d5c3f6cd0f.zip
Merge pull request #1948 from bas-vk/rpcfix
Infinite loop in filters
Diffstat (limited to 'rpc/api')
-rw-r--r--rpc/api/args_test.go12
-rw-r--r--rpc/api/eth_args.go7
2 files changed, 12 insertions, 7 deletions
diff --git a/rpc/api/args_test.go b/rpc/api/args_test.go
index 23ae2930d..130315bd9 100644
--- a/rpc/api/args_test.go
+++ b/rpc/api/args_test.go
@@ -1394,13 +1394,10 @@ func TestBlockFilterArgsDefaults(t *testing.T) {
}
func TestBlockFilterArgsWords(t *testing.T) {
- input := `[{
- "fromBlock": "latest",
- "toBlock": "pending"
- }]`
+ input := `[{"fromBlock": "latest", "toBlock": "latest"}]`
expected := new(BlockFilterArgs)
expected.Earliest = -1
- expected.Latest = -2
+ expected.Latest = -1
args := new(BlockFilterArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil {
@@ -1411,8 +1408,9 @@ func TestBlockFilterArgsWords(t *testing.T) {
t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest)
}
- if expected.Latest != args.Latest {
- t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest)
+ input = `[{"toBlock": "pending"}]`
+ if err := json.Unmarshal([]byte(input), &args); err == nil {
+ t.Errorf("Pending isn't currently supported and should raise an unsupported error")
}
}
diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go
index 457350d74..ed3d761f1 100644
--- a/rpc/api/eth_args.go
+++ b/rpc/api/eth_args.go
@@ -722,6 +722,13 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
return err
}
}
+
+ if num == -2 {
+ return fmt.Errorf("\"pending\" is unsupported")
+ } else if num < -2 {
+ return fmt.Errorf("Invalid to block number")
+ }
+
args.Latest = num
if obj[0].Limit == nil {