|
7 | 7 | from test_framework.test_framework import PivxTestFramework |
8 | 8 | from test_framework.util import assert_equal, connect_nodes, wait_until |
9 | 9 |
|
| 10 | + |
10 | 11 | class InvalidateTest(PivxTestFramework): |
11 | 12 | def set_test_params(self): |
12 | 13 | self.setup_clean_chain = True |
13 | 14 | self.num_nodes = 3 |
| 15 | + self.extra_args = [["-nuparams=v5_shield:1"]] * self.num_nodes |
14 | 16 |
|
15 | 17 | def setup_network(self): |
16 | 18 | self.setup_nodes() |
@@ -79,6 +81,18 @@ def run_test(self): |
79 | 81 | # Should be back at the tip by now |
80 | 82 | assert_equal(self.nodes[1].getbestblockhash(), blocks[-1]) |
81 | 83 |
|
| 84 | + self.log.info("Verify that it works for more than 100 blocks (sapling cache reconstruction)") |
| 85 | + blocks = self.nodes[1].generate(200) |
| 86 | + assert_equal(self.nodes[0].getblockchaininfo()['upgrades']['v5 shield']['status'], 'active') |
| 87 | + assert_equal(self.nodes[1].getbestblockhash(), blocks[-1]) |
| 88 | + # Invalidate a block deeper than the maximum cache size (i.e deeper than 100 blocks) |
| 89 | + self.nodes[1].invalidateblock(blocks[-140]) |
| 90 | + assert_equal(self.nodes[1].getbestblockhash(), blocks[-141]) |
| 91 | + # Reconsider only the previous tip |
| 92 | + self.nodes[1].reconsiderblock(blocks[-140]) |
| 93 | + # Should be back at the tip by now |
| 94 | + assert_equal(self.nodes[1].getbestblockhash(), blocks[-1]) |
| 95 | + |
82 | 96 |
|
83 | 97 | if __name__ == '__main__': |
84 | 98 | InvalidateTest().main() |
0 commit comments