1
1
mirror of https://github.com/bitcoin/bitcoin.git synced 2024-05-17 23:56:39 +00:00

test: add coinstatsindex getindexinfo coverage, improve current tests

This commit is contained in:
Jon Atack 2021-03-27 19:44:11 +01:00 committed by Fabian Jahr
parent ca01bb8d68
commit 655d929836
No known key found for this signature in database
GPG Key ID: F13D1E9D890798CD

View File

@ -66,25 +66,22 @@ class RpcMiscTest(BitcoinTestFramework):
assert_equal(node.getindexinfo(), {}) assert_equal(node.getindexinfo(), {})
# Restart the node with indices and wait for them to sync # Restart the node with indices and wait for them to sync
self.restart_node(0, ["-txindex", "-blockfilterindex"]) self.restart_node(0, ["-txindex", "-blockfilterindex", "-coinstatsindex"])
self.wait_until(lambda: all(i["synced"] for i in node.getindexinfo().values())) self.wait_until(lambda: all(i["synced"] for i in node.getindexinfo().values()))
# Returns a list of all running indices by default # Returns a list of all running indices by default
values = {"synced": True, "best_block_height": 200}
assert_equal( assert_equal(
node.getindexinfo(), node.getindexinfo(),
{ {
"txindex": {"synced": True, "best_block_height": 200}, "txindex": values,
"basic block filter index": {"synced": True, "best_block_height": 200} "basic block filter index": values,
"coinstatsindex": values,
} }
) )
# Specifying an index by name returns only the status of that index # Specifying an index by name returns only the status of that index
assert_equal( for i in {"txindex", "basic block filter index", "coinstatsindex"}:
node.getindexinfo("txindex"), assert_equal(node.getindexinfo(i), {i: values})
{
"txindex": {"synced": True, "best_block_height": 200},
}
)
# Specifying an unknown index name returns an empty result # Specifying an unknown index name returns an empty result
assert_equal(node.getindexinfo("foo"), {}) assert_equal(node.getindexinfo("foo"), {})