On NetBSD, with newer Python versions 3.12.8 and 3.13.1, many functional tests fail due to float
numbers internal representation.
A typical error looks as follows:
0$ python3.12 ./build/test/functional/feature_assumeutxo.py
1...
22025-01-02T20:43:01.865000Z TestFramework (INFO): Submit a spending transaction for a snapshot chainstate coin to the mempool
32025-01-02T20:43:01.889000Z TestFramework (ERROR): JSONRPC error
4Traceback (most recent call last):
5 File "/home/hebasto/dev/bitcoin/test/functional/test_framework/test_framework.py", line 135, in main
6 self.run_test()
7 File "/home/hebasto/dev/bitcoin/./build/test/functional/feature_assumeutxo.py", line 563, in run_test
8 raw_tx = n1.createrawtransaction([prevout], {getnewdestination()[2]: 24.99})
9 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 File "/home/hebasto/dev/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
11 return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
12 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13 File "/home/hebasto/dev/bitcoin/test/functional/test_framework/authproxy.py", line 146, in __call__
14 raise JSONRPCException(response['error'], status)
15test_framework.authproxy.JSONRPCException: Invalid amount (-3)
162025-01-02T20:43:01.954000Z TestFramework (INFO): Stopping nodes
17...
Running the same test with --tracerpc
:
0$ python3.12 ./build/test/functional/feature_assumeutxo.py --tracerpc
1...
2-2269-> createrawtransaction [[{"txid": "7935c5e149f7206122dfc8de0db6e5b2484923650b94ed56b8612609b896e021", "vout": 0, "scriptPubKey": "76a9142b4569203694fc997e13f2c0a1383b9e16c77a0d88ac"}], {"bcrt1pehl52uxx4ndz844j2xkasc3kqesyfmjhfukx42wdte2u5elzxhgqf9nnkt": 24.989999999999998}]
3<-- [0.013652] {"jsonrpc":"2.0","error":{"code":-3,"message":"Invalid amount"},"id":2269}
4
52025-01-03T08:17:42.532000Z TestFramework (ERROR): JSONRPC error
6Traceback (most recent call last):
7 File "/home/hebasto/dev/bitcoin/test/functional/test_framework/test_framework.py", line 135, in main
8 self.run_test()
9 File "/home/hebasto/dev/bitcoin/./build/test/functional/feature_assumeutxo.py", line 563, in run_test
10 raw_tx = n1.createrawtransaction([prevout], {getnewdestination()[2]: 24.99})
11 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 File "/home/hebasto/dev/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
13 return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
14 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 File "/home/hebasto/dev/bitcoin/test/functional/test_framework/authproxy.py", line 146, in __call__
16 raise JSONRPCException(response['error'], status)
17test_framework.authproxy.JSONRPCException: Invalid amount (-3)
182025-01-03T08:17:42.588000Z TestFramework (INFO): Stopping nodes
19...
This PR fixes this issue by consistent use of Decimal
numbers.