From 8f2123572dc0455372523bc8a3414c11abae9d97 Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Mon, 1 Apr 2019 17:12:18 -0700 Subject: [PATCH] Sped up the performance of feature_keva test. --- test/functional/feature_keva.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/test/functional/feature_keva.py b/test/functional/feature_keva.py index 328ecee84..f60c71af8 100755 --- a/test/functional/feature_keva.py +++ b/test/functional/feature_keva.py @@ -15,12 +15,12 @@ import re class KevaTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = True self.num_nodes = 2 def setup_network(self): super().setup_network() - connect_nodes_bi(self.nodes, 0, 1) + connect_nodes(self.nodes[0], 1) + connect_nodes(self.nodes[1], 0) self.sync_all() def run_unconfirmed_namespaces(self): @@ -57,15 +57,17 @@ class KevaTest(BitcoinTestFramework): assert(response['value'] == value2) # Disconnect the block self.sync_all() - self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) - self.nodes[1].invalidateblock(self.nodes[1].getbestblockhash()) + tip = self.nodes[0].getbestblockhash() + self.nodes[0].invalidateblock(tip) + self.nodes[1].invalidateblock(tip) self.sync_all() response = self.nodes[0].keva_get(namespaceId, key) assert(response['value'] == value1) # Disconnect the block again self.sync_all() - self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) - self.nodes[1].invalidateblock(self.nodes[1].getbestblockhash()) + tip = self.nodes[0].getbestblockhash() + self.nodes[0].invalidateblock(tip) + self.nodes[1].invalidateblock(tip) self.sync_all() response = self.nodes[0].keva_get(namespaceId, key) assert(response['value'] == '') @@ -87,8 +89,9 @@ class KevaTest(BitcoinTestFramework): assert(response['value'] == '') # Disconnect the block self.sync_all() - self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) - self.nodes[1].invalidateblock(self.nodes[1].getbestblockhash()) + tip = self.nodes[0].getbestblockhash() + self.nodes[0].invalidateblock(tip) + self.nodes[1].invalidateblock(tip) self.sync_all() response = self.nodes[0].keva_get(namespaceId, keyToDelete) # The value should be undeleted. @@ -123,8 +126,13 @@ class KevaTest(BitcoinTestFramework): def run_test(self): - self.nodes[0].generate(105) - self.nodes[1].generate(105) + # Start with a 200 block chain + assert_equal(self.nodes[0].getblockcount(), 200) + assert_equal(self.nodes[1].getblockcount(), 200) + + new_blocks = self.nodes[0].generate(1) + self.sync_all() + response = self.nodes[0].keva_namespace('first_namespace') namespaceId = response['namespaceId']