Test added to blockchain.py as adding a new test to reduce test run time.
Tests: Add test for getdifficulty #10229
pull jimmysong wants to merge 1 commits into bitcoin:master from jimmysong:test_getdifficulty changing 1 files +13 −1-
jimmysong commented at 2:58 AM on April 19, 2017: contributor
- fanquake added the label Tests on Apr 19, 2017
-
in test/functional/blockchain.py:65 in bfd615c6e2 outdated
63 | @@ -57,7 +64,8 @@ def _test_gettxoutsetinfo(self): 64 | def _test_getblockheader(self): 65 | node = self.nodes[0] 66 | 67 | - assert_raises_jsonrpc(-5, "Block not found", node.getblockheader, "nonsense") 68 | + assert_raises_jsonrpc(-5, "Block not found",
paveljanik commented at 2:21 PM on April 19, 2017:Why this change?
jimmysong commented at 2:54 PM on April 19, 2017:flake8 warning:
E501 line too long (85 > 79 characters)
jnewbery commented at 9:40 PM on April 19, 2017:My personal preference is to ignore the 'line too long' warning. Nothing wrong with going over 79 character lines in my opinion (but we don't have a style guide for functional tests, so entirely up to you)
in test/functional/blockchain.py:47 in bfd615c6e2 outdated
39 | @@ -40,8 +40,15 @@ def setup_network(self, split=False): 40 | def run_test(self): 41 | self._test_gettxoutsetinfo() 42 | self._test_getblockheader() 43 | + self._test_getdifficulty() 44 | self.nodes[0].verifychain(4, 0) 45 | 46 | + def _test_getdifficulty(self): 47 | + res = self.nodes[0].getdifficulty()
paveljanik commented at 2:27 PM on April 19, 2017:Mention the
getdifficultyRPC test in the top level comment or remove the list of tested methods there.
jimmysong commented at 2:54 PM on April 19, 2017:adding to the comment, thanks!
in test/functional/blockchain.py:46 in bfd615c6e2 outdated
39 | @@ -40,8 +40,15 @@ def setup_network(self, split=False): 40 | def run_test(self): 41 | self._test_gettxoutsetinfo() 42 | self._test_getblockheader() 43 | + self._test_getdifficulty() 44 | self.nodes[0].verifychain(4, 0) 45 | 46 | + def _test_getdifficulty(self):
paveljanik commented at 2:42 PM on April 19, 2017:Can you move the def after the
_test_getblockheaderso it is ordered the same as it is called?
jimmysong commented at 2:53 PM on April 19, 2017:Yep, will do.
in test/functional/blockchain.py:50 in bfd615c6e2 outdated
45 | 46 | + def _test_getdifficulty(self): 47 | + res = self.nodes[0].getdifficulty() 48 | + # 1 hash in 2 should be valid, so difficulty should be 1/2**31 49 | + # binary => decimal => binary math is why we round 50 | + assert_equal(round(res * 2**31, 4), 1.0)
paveljanik commented at 2:50 PM on April 19, 2017:Ugh.
jimmysong commented at 2:54 PM on April 19, 2017:Is there a cleverer way to do this?
paveljanik changes_requestedjimmysong force-pushed on Apr 19, 2017jimmysong commented at 3:03 PM on April 19, 2017: contributorFixed issues, rebased to master.
jimmysong force-pushed on Apr 19, 2017jimmysong force-pushed on Apr 19, 2017paveljanik approvedpaveljanik commented at 4:13 PM on April 19, 2017: contributorACK 821dd5e
in test/functional/blockchain.py:13 in ba2b295093 outdated
5 | @@ -6,6 +6,7 @@ 6 | 7 | Test the following RPCs: 8 | - gettxoutsetinfo 9 | + - getdifficulty 10 | - verifychain
jnewbery commented at 9:39 PM on April 19, 2017:Might as well fix this docstring while you're at it. The following RPCs are also tested:
- getbestblockhash
- getblockhash
- getblockheader
jimmysong commented at 9:52 PM on April 19, 2017:good idea.
in test/functional/blockchain.py:86 in ba2b295093 outdated
81 | @@ -79,5 +82,11 @@ def _test_getblockheader(self): 82 | assert isinstance(int(header['versionHex'], 16), int) 83 | assert isinstance(header['difficulty'], Decimal) 84 | 85 | + def _test_getdifficulty(self): 86 | + res = self.nodes[0].getdifficulty()
jnewbery commented at 9:41 PM on April 19, 2017:I'd prefer a more descriptive name than
res, perhapsdifficulty? (or even combine with the line below)
jimmysong commented at 9:53 PM on April 19, 2017:Makes sense.
jnewbery commented at 9:41 PM on April 19, 2017: memberLooks good. Tested ACK ba2b295093d5f5cad4701f9ca86b2c83e60c3ef9.
A few nits which you can take or leave.
jnewbery approved821dd5e3e1Tests: Add test for getdifficulty
Test added to blockchain.py as adding a new test to reduce test run time.
jimmysong force-pushed on Apr 19, 2017jimmysong commented at 9:54 PM on April 19, 2017: contributorFixed nits and squashed.
laanwj merged this on Apr 21, 2017laanwj closed this on Apr 21, 2017laanwj referenced this in commit f3db4c6013 on Apr 21, 2017PastaPastaPasta referenced this in commit 64373eda0d on May 21, 2019PastaPastaPasta referenced this in commit 73fcaed8a5 on May 22, 2019PastaPastaPasta referenced this in commit 7881acd853 on May 22, 2019PastaPastaPasta referenced this in commit 5a4845ec9d on May 22, 2019PastaPastaPasta referenced this in commit b889dfdc9e on May 23, 2019PastaPastaPasta referenced this in commit f221038c5e on May 23, 2019PastaPastaPasta referenced this in commit 9d2e8fccf5 on May 28, 2019PastaPastaPasta referenced this in commit dfca65cee4 on May 28, 2019PastaPastaPasta referenced this in commit b6df927e51 on Jun 7, 2019PastaPastaPasta referenced this in commit 6fb2866868 on Jun 8, 2019PastaPastaPasta referenced this in commit 59e7a0a913 on Jun 10, 2019barrystyle referenced this in commit 97b8756acb on Jan 22, 2020DrahtBot locked this on Sep 8, 2021ContributorsLabels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-27 15:16 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me