Skip to content

test: correct miner_tests#22

Merged
gto90 merged 3 commits intoDigiByte-Core:developfrom
SmartArray:tests/miner_tests
Apr 7, 2021
Merged

test: correct miner_tests#22
gto90 merged 3 commits intoDigiByte-Core:developfrom
SmartArray:tests/miner_tests

Conversation

@SmartArray
Copy link

@SmartArray SmartArray commented Apr 4, 2021

DigiByte specific miner_tests

What is the intention of this PR?

This PR fixes the miner_tests with DigiByte's specific Mining Parameters.
Unfortunately, this one required a big custom-made mining script and additional hours of mining in order to generate the test vectors. If something is wrong we have to regenerate those, but on my machines the test is working great so far.

Description of the changes

The commit SmartArray@56f829f adds a custom code snipped to contrib/testgen and updates the miner_tests unit test with the test vectors generated using that code snipped. Furthermore, it fixes a bunch of other issues in order to have 100% coverage.

SmartArray@30330b2 removes a debug statement.

How to verify?

  1. Change to the directory src/test
  2. Compile the test suite
  3. Run it using
./test_digibyte --run_test=miner_tests

Expected outcome

$ ./test_digibyte --run_test=miner_tests                            
Running 1 test case...

*** No errors detected

@SmartArray SmartArray marked this pull request as ready for review April 4, 2021 07:20
Copy link
Member

@gto90 gto90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Copy link

@digicontributer digicontributer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@gto90 gto90 merged commit 7323711 into DigiByte-Core:develop Apr 7, 2021
@SmartArray SmartArray deleted the tests/miner_tests branch April 8, 2021 05:13
JaredTate added a commit that referenced this pull request Mar 12, 2026
…22)

PROBLEM: During rescan/revalidation, ValidateDigiDollarTransaction checks
lockTime - ctx.nHeight to verify the lock tier matches the lock duration.
But ctx.nHeight is the CURRENT chain tip during rescan, not the original
block height. Historical mints where lockTime < currentHeight produce a
negative result and are falsely rejected as 'bad-mint-lock-height-mismatch'.
This blocked rescan on 3+ testnet nodes.

FIX: If lockTime <= ctx.nHeight or skipOracleValidation is set, the mint
has already matured — skip the tier consistency check. The security check
is still enforced for fresh mints entering the mempool.

TESTS: 4 new test cases in digidollar_lock_height_tests.cpp:
- rescan_mature_mint_passes (matured historical mint validates)
- rescan_immature_mint_still_valid (in-progress lock during rescan validates)
- fresh_mint_tier_mismatch_fails (short lock claiming long tier rejected)
- fresh_mint_tier_correct_passes (correct tier/lock combo accepted)

Files changed: src/digidollar/validation.cpp, src/test/digidollar_lock_height_tests.cpp,
src/Makefile.test.include
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants