aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_decodescript.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-03-16 16:31:38 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-03-16 16:31:42 -0400
commit7060d2d97a289097f41fcc79698312c0117a75c8 (patch)
treef3f6c273868fb44be61f02392f87301e6d9de341 /test/functional/rpc_decodescript.py
parent25424cf57e296fc4ed3f32bf5d472646d0df3a11 (diff)
parent7a6627ae87b637bf32c03122865402bd71adf0d1 (diff)
Merge #18350: test: Fix mining to an invalid target + ensure that a new block has the correct hash internally
7a6627ae87b637bf32c03122865402bd71adf0d1 Fix mining to an invalid target + ensure that a new block has the correct hash internally in Python tests (Samer Afach) Pull request description: Test with block 47 in the `feature_block.py` creates a block with a hash higher than the target, which is supposed to fail. Now two issues exist there, and both have low probability of showing up: 1. The creation is done with `while (hash < target)`, which is wrong, because hash = target is a valid mined value based on the code in the function `CheckProofOfWork()` that validates the mining target: ``` if (UintToArith256(hash) > bnTarget) return false; ``` 2. As we know the hash stored in CBlock class in Python is stateful, unlike how it's in C++, where calling `CBlock::GetHash()` will actively calculate the hash and not cache it anywhere. With this, blocks that come out of the method `next_block` can have incorrect hash value when `solve=False`. This is because the `next_block` is mostly used with `solve=True`, and solving does call the function `rehash()` which calculates the hash of the block, but with `solve=False`, nothing calls that method. And since the work to be done in regtests is very low, the probably of this problem showing up is very low, but it practically happens (well, with much higher probability compared to issue No. 1 above). This PR fixes both these issues. Top commit has no ACKs. Tree-SHA512: f3b54d18f5073d6f1c26eab89bfec78620dda4ac1e4dde4f1d69543f1b85a7989d64c907e091db63f3f062408f5ed1e111018b842819ba1a5f8348c7b01ade96
Diffstat (limited to 'test/functional/rpc_decodescript.py')
0 files changed, 0 insertions, 0 deletions