Skip to content

Commit

Permalink
refine test
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Sep 4, 2023
1 parent a0d973e commit 0998050
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions test/functional/feature_evm_rpc_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from test_framework.test_framework import DefiTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
int_to_eth_u256,
)

Expand Down Expand Up @@ -121,10 +122,21 @@ def test_get_logs(self):
)
assert_equal(len(logs), 3)

def test_new_filter(self):
def test_get_filter_logs(self):
node = self.nodes[0]

self.create_block(3)
id = node.eth_newFilter(
{
"fromBlock": "earliest",
"toBlock": "latest",
}
)

logs = node.eth_getFilterLogs(id)
assert_equal(len(logs), 3)

def test_new_filter(self):
node = self.nodes[0]

id1 = node.eth_newFilter(
{
Expand All @@ -140,18 +152,27 @@ def test_new_filter(self):
)
assert_equal(hex(int(id1, 16) + 1), id2)

def test_get_filter_logs(self):
node = self.nodes[0]

id = node.eth_newFilter(
def fail_new_filter_to_greater_than_from(self):
assert_raises_rpc_error(
-32001,
"Custom error: fromBlock (0x1) > toBlock (0x0)",
self.nodes[0].eth_newFilter,
{
"fromBlock": "earliest",
"toBlock": "latest",
"fromBlock": "0x1",
"toBlock": "0x0"
}
)

logs = node.eth_getFilterLogs(id)
assert_equal(len(logs), 3)
def fail_new_filter_unavailable_block(self):
assert_raises_rpc_error(
-32001,
"Custom error: header not found",
self.nodes[0].eth_newFilter,
{
"fromBlock": "0x1",
"toBlock": "0x999999999"
}
)

def run_test(self):
self.setup()
Expand All @@ -164,6 +185,12 @@ def run_test(self):

self.test_new_filter()

self.fail_new_filter_to_greater_than_from()

self.fail_new_filter_unavailable_block()

self.fail_new_filter_unavailable_block()


if __name__ == "__main__":
EVMTest().main()

0 comments on commit 0998050

Please sign in to comment.