Skip to content

Commit 85211c1

Browse files
committed
Fix flakiness in channel-token-test.
Corrupting a byte by setting it to 0 doesn't always work because 1/256 of the time the byte is already zero, due to the encryption key being random. Flipping a bit using XOR should always corrupt it.
1 parent 91275d4 commit 85211c1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/workerd/server/channel-token-test.c++

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ KJ_TEST("channel token basics") {
9494

9595
auto corruptedToken = [&](uint index) {
9696
auto copy = kj::heapArray(token.asPtr());
97-
copy[index] = 0;
97+
copy[index] ^= 1;
9898
return copy;
9999
};
100100

@@ -146,7 +146,7 @@ KJ_TEST("channel tokens for storage") {
146146

147147
auto corruptedToken = [&](uint index) {
148148
auto copy = kj::heapArray(token.asPtr());
149-
copy[index] = 0;
149+
copy[index] ^= 1;
150150
return copy;
151151
};
152152

0 commit comments

Comments
 (0)