This repository has been archived by the owner on Nov 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #6: Fix progress reporting & initialblockdownload
- Loading branch information
Showing
8 changed files
with
95 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2015-2016 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
# | ||
# Test progress code | ||
# | ||
|
||
import time | ||
|
||
from test_framework.test_framework import BitcoinTestFramework | ||
from test_framework.util import ( | ||
start_nodes, | ||
Decimal, | ||
) | ||
|
||
def assert_close(f1, f2): | ||
assert(abs(Decimal(f1)-f2) < 0.1) | ||
|
||
class ProgressTest(BitcoinTestFramework): | ||
def __init__(self): | ||
super().__init__() | ||
self.setup_clean_chain = True | ||
self.num_nodes = 2 | ||
self.extra_args = [["-debug", "-con_npowtargetspacing=1", "-maxtimeadjustment=0"]] * self.num_nodes | ||
|
||
def setup_network(self): | ||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, extra_args=self.extra_args) | ||
self.is_network_split = True | ||
self.starttime = int(time.time()) | ||
|
||
def setmocktime(self, ntime): | ||
for node in self.nodes: | ||
node.setmocktime(self.starttime + ntime) | ||
|
||
def run_test(self): | ||
node1 = self.nodes[0] | ||
node2 = self.nodes[1] | ||
self.setmocktime(0) | ||
|
||
blocks = [] | ||
for i in range(10): | ||
self.setmocktime(i) | ||
blocks.extend(node1.generate(1)) | ||
|
||
self.setmocktime(19) | ||
assert_close(0.5, node1.getblockchaininfo()["verificationprogress"]) | ||
|
||
assert(node2.getblockchaininfo()["initialblockdownload"]) | ||
|
||
self.setmocktime(10) | ||
for i in range(10): | ||
node2.submitblock(node1.getblock(blocks[i], False)) | ||
progress = node2.getblockchaininfo()["verificationprogress"] | ||
assert_close(i/10.0, progress) | ||
|
||
assert(not node2.getblockchaininfo()["initialblockdownload"]) | ||
|
||
if __name__ == '__main__': | ||
ProgressTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters