Skip to content

prepared_test: fix TestPreparedMessage for Go 1.20+#1018

Open
alliasgher wants to merge 1 commit intogorilla:mainfrom
alliasgher:fix-prepared-message-test-go124
Open

prepared_test: fix TestPreparedMessage for Go 1.20+#1018
alliasgher wants to merge 1 commit intogorilla:mainfrom
alliasgher:fix-prepared-message-test-go124

Conversation

@alliasgher
Copy link
Copy Markdown

Fixes #983. rand.Rand.Seed was deprecated in Go 1.20 and its internal behaviour changed, causing inconsistent masks. Replace with fresh rand.New(rand.NewSource(1234)) before each write.

The test reset the mask-random source by calling testRand.Seed(1234)
on an existing *rand.Rand. rand.Rand.Seed was deprecated in Go 1.20
and its behaviour changed across minor versions, causing inconsistent
masking between the direct write and the prepared-message write.

Replace the approach: instead of calling Seed on a shared Rand, create
a fresh rand.New(rand.NewSource(1234)) before each of the two writes.
Both writes now use an identical, reproducibly-seeded generator so the
masked bytes always match.

Fixes gorilla#983

Signed-off-by: alliasgher <alliasgher123@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] unit test fails with Go 1.24

1 participant