Since there is currently no test to validate the specified 21 million bitcoin requirement, I have created this one. Its very simple and can be expanded upon if needed.
Add scarcity unit test. #3706
pull sdaves wants to merge 1 commits into bitcoin:master from sdaves:master changing 1 files +12 −0-
sdaves commented at 11:20 PM on February 18, 2014: none
-
Add scarcity unit test. a86402eb9c
-
luke-jr commented at 11:22 PM on February 18, 2014: member
This doesn't seem to actually test anything...
-
BitcoinPullTester commented at 11:42 PM on February 18, 2014: none
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/a86402eb9c505098cc06e7f80390b06635e6450b for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
-
sipa commented at 11:46 PM on February 18, 2014: member
Won't hurt, but indeed: it doesn't actually test the scarcity.
A test that generated a chain of a few million blocks, and then iterated the UTXO set would be nice :p
-
sdaves commented at 12:20 AM on February 19, 2014: none
You are correct. It doesn't generate the blocks. However, it does verify that the number of Satoshis in a Bitcoin is correct, as well as the limit of Bitcoins allowed.
-
gmaxwell commented at 12:28 AM on February 19, 2014: contributor
MAX_MONEY has really nothing to do with limiting the scarcity of the coin. The finite supply arises out of the limit of the geometric series of subsidies. MAX_MONEY just gets used as a sanity check in single transaction values and such.
What you want is a block with a subsidy above program, but IIRC the pull tester does this.
-
sdaves commented at 12:39 AM on February 19, 2014: none
The MoneyRange function in core.h directly checks MAX_MONEY.
-
gmaxwell commented at 12:40 AM on February 19, 2014: contributor
sdaves: Yes, and go look where that function is called. It does not limit the total supply of coins.
-
sdaves commented at 12:44 AM on February 19, 2014: none
In rpcserver main core and wallet.
-
gmaxwell commented at 12:47 AM on February 19, 2014: contributor
Right, where it does NOTHING to limit the number of coins in existence.
-
sdaves commented at 12:50 AM on February 19, 2014: none
Are you saying there is already a test that verifies that more than 21 million bitcoins cannot be created?
-
sdaves commented at 12:51 AM on February 19, 2014: none
I compiled the bitcoin master branch with the MAX_MONEY set to double the value, and everything ran fine, as well as no tests throwing an error. However, with this patch, there is a test error thrown.
-
sipa commented at 12:56 AM on February 19, 2014: member
Well duh...
How about you try setting MAX_MONEY to let's say 1 million and see if you can still validate the blockchain? You'll see it succeeds, even though there is a lot more than 1000000 BTC in circulation.
-
sdaves commented at 1:10 AM on February 19, 2014: none
Shouldn't you also verify that MAX_MONEY hasn't been compromised? MoneyRange is dependent on MAX_MONEY.
Pieter Wuille notifications@github.com wrote:
See #3707 for a simple test that does verify something.
Reply to this email directly or view it on GitHub: #3706 (comment)
-
sipa commented at 1:15 AM on February 19, 2014: member
How about we go checking that the constant NULL hasn't been compromised?
Tests aren't about detecting compromisation. They're there to detect bugs. If someone changes the MAX_MONEY constant, we'll notice. Just defining it a second time in tests doesn't make it any more obvious.
-
int03h commented at 1:22 AM on February 19, 2014: none
compare null to random . when equal execute.. code that will never be executed ever.. lol.
-
sdaves commented at 1:29 AM on February 19, 2014: none
Validating business requirements with tests is not superfluous. It's good testing. Not sure why you are making agreements from absurdity.
Pieter Wuille notifications@github.com wrote:
How about we go checking that the constant NULL hasn't been compromised?
Tests aren't about detecting compromisation. They're there to detect bugs. If someone changes the MAX_MONEY constant, we'll notice. Just defining it a second time in tests doesn't make it any more obvious.
Reply to this email directly or view it on GitHub: #3706 (comment)
-
gavinandresen commented at 2:03 AM on February 19, 2014: contributor
NACK. Useless unit test, closing.
- gavinandresen closed this on Feb 19, 2014
- bitcoin locked this on Sep 8, 2021