Merge #10253: [test] Add test for getnetworkhashps
de487b7 Tests: Add test for getnetworkhashps (Jimmy Song) Tree-SHA512: b1418ad904618f639ffa34dd40906692aff1fdf1a0d13a9af00039e7a6a2b758091734b89c0c91e8d455da6b15a0e435a9a9ca97a41d97bf395b844c761ffa27
This commit is contained in:
parent
4b376794c0
commit
65d0fbf3c2
@ -10,6 +10,7 @@ Test the following RPCs:
|
|||||||
- getbestblockhash
|
- getbestblockhash
|
||||||
- getblockhash
|
- getblockhash
|
||||||
- getblockheader
|
- getblockheader
|
||||||
|
- getnetworkhashps
|
||||||
- verifychain
|
- verifychain
|
||||||
|
|
||||||
Tests correspond to code in rpc/blockchain.cpp.
|
Tests correspond to code in rpc/blockchain.cpp.
|
||||||
@ -39,6 +40,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||||||
self._test_gettxoutsetinfo()
|
self._test_gettxoutsetinfo()
|
||||||
self._test_getblockheader()
|
self._test_getblockheader()
|
||||||
self._test_getdifficulty()
|
self._test_getdifficulty()
|
||||||
|
self._test_getnetworkhashps()
|
||||||
self.nodes[0].verifychain(4, 0)
|
self.nodes[0].verifychain(4, 0)
|
||||||
|
|
||||||
def _test_gettxoutsetinfo(self):
|
def _test_gettxoutsetinfo(self):
|
||||||
@ -110,5 +112,10 @@ class BlockchainTest(BitcoinTestFramework):
|
|||||||
# binary => decimal => binary math is why we do this check
|
# binary => decimal => binary math is why we do this check
|
||||||
assert abs(difficulty * 2**31 - 1) < 0.0001
|
assert abs(difficulty * 2**31 - 1) < 0.0001
|
||||||
|
|
||||||
|
def _test_getnetworkhashps(self):
|
||||||
|
hashes_per_second = self.nodes[0].getnetworkhashps()
|
||||||
|
# This should be 2 hashes every 10 minutes or 1/300
|
||||||
|
assert abs(hashes_per_second * 300 - 1) < 0.0001
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
BlockchainTest().main()
|
BlockchainTest().main()
|
||||||
|
Loading…
Reference in New Issue
Block a user