Skip to content

Commit

Permalink
Functional test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed May 11, 2023
1 parent 1a1a5ff commit 21d05be
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/functional/rpc_invalidateblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
from test_framework.test_framework import PivxTestFramework
from test_framework.util import assert_equal, connect_nodes, wait_until


class InvalidateTest(PivxTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 3
self.extra_args = [["-nuparams=v5_shield:1"]] * self.num_nodes

def setup_network(self):
self.setup_nodes()
Expand Down Expand Up @@ -79,6 +81,18 @@ def run_test(self):
# Should be back at the tip by now
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])

self.log.info("Verify that it works for more than 100 blocks (sapling cache reconstruction)")
blocks = self.nodes[1].generate(200)
assert_equal(self.nodes[0].getblockchaininfo()['upgrades']['v5 shield']['status'], 'active')
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
# Invalidate a block deeper than the maximum cache size (i.e deeper than 100 blocks)
self.nodes[1].invalidateblock(blocks[-140])
assert_equal(self.nodes[1].getbestblockhash(), blocks[-141])
# Reconsider only the previous tip
self.nodes[1].reconsiderblock(blocks[-140])
# Should be back at the tip by now
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])


if __name__ == '__main__':
InvalidateTest().main()

0 comments on commit 21d05be

Please sign in to comment.