Skip to content

Commit c447b09

Browse files
committed
test: Add tests for getindexinfo RPC
1 parent 667bc7a commit c447b09

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/functional/rpc_misc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,34 @@ def run_test(self):
6161
node.logging(include=['qt'])
6262
assert_equal(node.logging()['qt'], True)
6363

64+
self.log.info("test getindexinfo")
65+
# Without any indices running the RPC returns an empty object
66+
assert_equal(node.getindexinfo(), {})
67+
68+
# Restart the node with indices and wait for them to sync
69+
self.restart_node(0, ["-txindex", "-blockfilterindex"])
70+
self.wait_until(lambda: all(i["synced"] for i in node.getindexinfo().values()))
71+
72+
# Returns a list of all running indices by default
73+
assert_equal(
74+
node.getindexinfo(),
75+
{
76+
"txindex": {"synced": True, "best_block_height": 200},
77+
"basic block filter index": {"synced": True, "best_block_height": 200}
78+
}
79+
)
80+
81+
# Specifying an index by name returns only the status of that index
82+
assert_equal(
83+
node.getindexinfo("txindex"),
84+
{
85+
"txindex": {"synced": True, "best_block_height": 200},
86+
}
87+
)
88+
89+
# Specifying an unknown index name returns an empty result
90+
assert_equal(node.getindexinfo("foo"), {})
91+
6492

6593
if __name__ == '__main__':
6694
RpcMiscTest().main()

0 commit comments

Comments
 (0)