diff options
author | Andrew Chow <github@achow101.com> | 2023-11-02 15:19:26 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-11-02 15:19:37 -0400 |
commit | 5f886221914fc4cb8a606f1b74aab2cddd8c0c84 (patch) | |
tree | 12235012e7455f47a61ef9da7b98e52d440a9947 | |
parent | 0857f2935f90df9c3d303582e5b62a9c8dedd9d7 (diff) | |
parent | 376dc2cfb32806a8aa450589effe4d384e648398 (diff) | |
download | bitcoin-5f886221914fc4cb8a606f1b74aab2cddd8c0c84.tar.xz |
Merge bitcoin/bitcoin#27852: test: add coverage to rpc_blockchain.py
376dc2cfb32806a8aa450589effe4d384e648398 test: add coverage to rpc_blockchain.py (kevkevin)
Pull request description:
Included a test that checks the functionality of setting
the first param of getnetworkhashps to negative value returns
the average network hashes per second from the last difficulty change.
ACKs for top commit:
jlopp:
tACK https://github.com/bitcoin/bitcoin/commit/376dc2cfb32806a8aa450589effe4d384e648398
achow101:
ACK 376dc2cfb32806a8aa450589effe4d384e648398
ismaelsadeeq:
Tested ACK 376dc2cfb32806a8aa450589effe4d384e648398
pablomartin4btc:
tACK 376dc2cfb32806a8aa450589effe4d384e648398
Tree-SHA512: 02d52f622e9cb7a1240c5d124510dd75d03f696f119b2625b0befd60b004ec50ff1a2d5515e0e227601adeecd837e0778ed131ee2a8c5f75f1b824be711213a7
-rwxr-xr-x | test/functional/rpc_blockchain.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 53163720bb..8eb9f3aeb1 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -58,6 +58,7 @@ TIME_RANGE_STEP = 600 # ten-minute steps TIME_RANGE_MTP = TIME_GENESIS_BLOCK + (HEIGHT - 6) * TIME_RANGE_STEP TIME_RANGE_TIP = TIME_GENESIS_BLOCK + (HEIGHT - 1) * TIME_RANGE_STEP TIME_RANGE_END = TIME_GENESIS_BLOCK + HEIGHT * TIME_RANGE_STEP +DIFFICULTY_ADJUSTMENT_INTERVAL = 2016 class BlockchainTest(BitcoinTestFramework): @@ -451,6 +452,15 @@ class BlockchainTest(BitcoinTestFramework): # This should be 2 hashes every 10 minutes or 1/300 assert abs(hashes_per_second * 300 - 1) < 0.0001 + # Test setting the first param of getnetworkhashps to negative value returns the average network + # hashes per second from the last difficulty change. + current_block_height = self.nodes[0].getmininginfo()['blocks'] + blocks_since_last_diff_change = current_block_height % DIFFICULTY_ADJUSTMENT_INTERVAL + 1 + expected_hashes_per_second_since_diff_change = self.nodes[0].getnetworkhashps(blocks_since_last_diff_change) + + assert_equal(self.nodes[0].getnetworkhashps(-1), expected_hashes_per_second_since_diff_change) + assert_equal(self.nodes[0].getnetworkhashps(-2), expected_hashes_per_second_since_diff_change) + def _test_stopatheight(self): self.log.info("Test stopping at height") assert_equal(self.nodes[0].getblockcount(), HEIGHT) |