|
|
@ -13,13 +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 () |
|
|
|
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 () |
|
|
@ -31,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 |
|
|
@ -55,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 () |
|
|
|