Browse Source

Make getchaintips tests pass (they never worked previously, because of assumptions about the number of blocks mined in regtest inherited from BTC/ZEC) and add test for new minBranchLen argument

pull/151/head
Jonathan "Duke" Leto 6 years ago
parent
commit
52e6bd74ca
  1. 19
      qa/rpc-tests/getchaintips.py

19
qa/rpc-tests/getchaintips.py

@ -13,14 +13,15 @@ from test_framework.util import assert_equal
class GetChainTipsTest (BitcoinTestFramework):
def run_test (self):
BitcoinTestFramework.run_test (self)
rpc = self.nodes[0]
#for node in self.nodes:
# node.generate(200)
tips = self.nodes[0].getchaintips ()
print tips
tips = self.nodes[0].getchaintips()
assert_equal (len (tips), 1)
assert_equal (tips[0]['branchlen'], 0)
assert_equal (tips[0]['height'], 200)
assert_equal (tips[0]['status'], 'active')
assert_equal (tips[0]['branchlen'], 0)
assert_equal (tips[0]['height'], 0)
# Split the network and build two chains of different lengths.
self.split_network ()
@ -32,14 +33,14 @@ class GetChainTipsTest (BitcoinTestFramework):
assert_equal (len (tips), 1)
shortTip = tips[0]
assert_equal (shortTip['branchlen'], 0)
assert_equal (shortTip['height'], 210)
assert_equal (shortTip['height'], 10)
assert_equal (tips[0]['status'], 'active')
tips = self.nodes[3].getchaintips ()
assert_equal (len (tips), 1)
longTip = tips[0]
assert_equal (longTip['branchlen'], 0)
assert_equal (longTip['height'], 220)
assert_equal (longTip['height'], 20)
assert_equal (tips[0]['status'], 'active')
# Join the network halves and check that we now have two tips
@ -56,5 +57,9 @@ class GetChainTipsTest (BitcoinTestFramework):
tips[1]['status'] = 'active'
assert_equal (tips[1], shortTip)
# test optional minBranchLen
tips = self.nodes[0].getchaintips(42)
assert_equal (len (tips), 0)
if __name__ == '__main__':
GetChainTipsTest ().main ()

Loading…
Cancel
Save