Skip to content

Commit de487b7

Browse files
committed
Tests: Add test for getnetworkhashps
1 parent a6548a4 commit de487b7

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.
@@ -45,6 +46,7 @@ def run_test(self):
4546
self._test_gettxoutsetinfo()
4647
self._test_getblockheader()
4748
self._test_getdifficulty()
49+
self._test_getnetworkhashps()
4850
self.nodes[0].verifychain(4, 0)
4951

5052
def _test_gettxoutsetinfo(self):
@@ -91,5 +93,10 @@ def _test_getdifficulty(self):
9193
# binary => decimal => binary math is why we do this check
9294
assert abs(difficulty * 2**31 - 1) < 0.0001
9395

96+
def _test_getnetworkhashps(self):
97+
hashes_per_second = self.nodes[0].getnetworkhashps()
98+
# This should be 2 hashes every 10 minutes or 1/300
99+
assert abs(hashes_per_second * 300 - 1) < 0.0001
100+
94101
if __name__ == '__main__':
95102
BlockchainTest().main()

0 commit comments

Comments
 (0)