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

blockchain: Fix return amts test for Go 1.23+. #3424

Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Aug 20, 2024

This updates the test for ticket return calculation amounts to work properly with Go 1.23+.

Specifically, it updates the default ticket commitment script that is used when creating the mock minimal ouputs that the tests then modify to be an actual commitment script. Note that this is solely a test issue.

It appears that an invalid mock ticket commitment script was specified when the test was created, but since the tests only deal with the return amounts which are explicitly modified in the mock script to the values the test data requires, it did not previously matter.

However, the code that updates the mock script for the tests inadvertently relied on undocumented behavior in hex.DecodeString returning a slice with a larger capacity which allowed the slice to be extended when setting the appropriate amounts. However, that is no longer the case as of Go 1.23+ which uncovered the otherwise invalid script.

@davecgh davecgh added the test coverage Discussion and pull requests for improving test coverage. label Aug 20, 2024
@davecgh davecgh added this to the 2.1.0 milestone Aug 20, 2024
This updates the test for ticket return calculation amounts to work
properly with Go 1.23+.

Specifically, it updates the default ticket commitment script that is
used when creating the mock minimal ouputs that the tests then modify to
be an actual commitment script.  Note that this is solely a test issue.

It appears that an invalid mock ticket commitment script was specified
when the test was created, but since the tests only deal with the return
amounts which are explicitly modified in the mock script to the values
the test data requires, it did not previously matter.

However, the code that updates the mock script for the tests
inadvertently relied on undocumented behavior in hex.DecodeString
returning a slice with a larger capacity which allowed the slice to be
extended when setting the appropriate amounts.  However, that is no
longer the case as of Go 1.23+ which uncovered the otherwise invalid
script.
@davecgh davecgh force-pushed the blockchain_fix_ticket_return_amts_test_go_1_23 branch from 2bd25aa to d505edd Compare August 20, 2024 17:24
@davecgh davecgh merged commit d505edd into decred:master Aug 20, 2024
2 checks passed
@davecgh davecgh deleted the blockchain_fix_ticket_return_amts_test_go_1_23 branch August 20, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test coverage Discussion and pull requests for improving test coverage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants