Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 2 More Unit Tests #196

Merged
merged 3 commits into from
Mar 14, 2024
Merged

Fix 2 More Unit Tests #196

merged 3 commits into from
Mar 14, 2024

Conversation

JaredTate
Copy link

This PR fixes 2 more Unit tests. Unit tests are the most important C++ tests located in the src folder and are what first runs when you make check. This fixes policy_fee_tests.cpp & transaction_tests.cpp.

You can read more about Unit Tests here:
https://github.com/DigiByte-Core/digibyte/blob/develop/src/test/README.md

To Compile & Run Unit Tests:

  ./autogen.sh
  ./configure
  make -j 8
  make check

Run Specific Unit Test Fixed

cd src/test
./test_digibyte --run_test=transaction_tests
./test_digibyte --run_test=policy_fee_tests

Explanation of Changes In policy_fee_tests.cpp

  1. 974 changed to 0:
  • In the original test case, the fee rate was set to 10000, and the expected rounded value for 1000 was 974.
  • However, after updating the fee rate to 100000 (10 times higher), the rounding logic changed.
  • With the new fee rate, the rounded value for 1000 becomes 0 because 1000 is less than the minimum fee unit of 100000.
  • Therefore, the expected value was updated from 974 to 0 to reflect the new rounding behavior.
  1. 1071 changed to 50000:
  • Similar to the previous change, the original expected value of 1071 was based on the fee rate of 10000.
  • With the updated fee rate of 100000, the rounding logic changed, and the expected value needed to be adjusted.
  • The new expected value of 50000 was determined by running the test and observing the actual rounded value.
  • The test case checks that the rounded value for 1000 should be either 0 or another value (previously 1071, now 50000).
  • The actual rounded value turned out to be 50000 with the new fee rate, so the expected value was updated accordingly.
  1. 9170997 changed to 9936506125:
  • The original expected value of 9170997 for rounding MAX_MONEY was based on the fee rate of 10000.
  • With the updated fee rate of 100000, the rounding behavior for MAX_MONEY changed as well.
  • The new expected value of 9936506125 was determined by running the test and observing the actual rounded value.
  • The test case checks that rounding MAX_MONEY should equal the expected value, which was previously 9170997 but is now 9936506125 with the new fee rate.

After this PR make check now fails on: wallet_tests.cpp

So we need to approve: #180

@ycagel ycagel requested review from SmartArray, ycagel, digicontributer, gto90, j50ng and a user March 14, 2024 21:22
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.

ACK

Copy link
Member

@ycagel ycagel left a comment

Choose a reason for hiding this comment

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

cACK

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Screenshot from 2024-03-14 22-32-03

ACK Tested

@ycagel ycagel merged commit bdc295e into DigiByte-Core:develop Mar 14, 2024
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