Skip to content

Commit 87abe20

Browse files
author
MarcoFalke
committed
Merge #10253: [test] Add test for getnetworkhashps
de487b7 Tests: Add test for getnetworkhashps (Jimmy Song) Tree-SHA512: b1418ad904618f639ffa34dd40906692aff1fdf1a0d13a9af00039e7a6a2b758091734b89c0c91e8d455da6b15a0e435a9a9ca97a41d97bf395b844c761ffa27
2 parents 94e5227 + de487b7 commit 87abe20

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/functional/blockchain.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- getbestblockhash
1111
- getblockhash
1212
- getblockheader
13+
- getnetworkhashps
1314
- verifychain
1415
1516
Tests correspond to code in rpc/blockchain.cpp.
@@ -37,6 +38,7 @@ def run_test(self):
3738
self._test_gettxoutsetinfo()
3839
self._test_getblockheader()
3940
self._test_getdifficulty()
41+
self._test_getnetworkhashps()
4042
self.nodes[0].verifychain(4, 0)
4143

4244
def _test_gettxoutsetinfo(self):
@@ -83,5 +85,10 @@ def _test_getdifficulty(self):
8385
# binary => decimal => binary math is why we do this check
8486
assert abs(difficulty * 2**31 - 1) < 0.0001
8587

88+
def _test_getnetworkhashps(self):
89+
hashes_per_second = self.nodes[0].getnetworkhashps()
90+
# This should be 2 hashes every 10 minutes or 1/300
91+
assert abs(hashes_per_second * 300 - 1) < 0.0001
92+
8693
if __name__ == '__main__':
8794
BlockchainTest().main()

0 commit comments

Comments
 (0)