Skip to content

Commit

Permalink
fix(i): Remove flakyness of AES decrypt test (sourcenetwork#3241)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves sourcenetwork#3240 

## Description

This PR fixes a flaky test where the modification of the cypher text was
supposed to cause it to fail decryption. The modification turned out to
sometime be the same as the actual cypher text.
  • Loading branch information
fredcarle authored Nov 15, 2024
1 parent 198454b commit 8e24ee4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crypto/aes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ func TestDecryptAES(t *testing.T) {
errorContains: "message authentication failed",
},
{
name: "Tampered ciphertext",
nonce: validNonce,
cipherText: append([]byte{0}, validCiphertext[AESNonceSize+1:]...),
name: "Tampered ciphertext",
nonce: validNonce,
// Flip a byte in the ciphertext to corrupt it.
cipherText: append([]byte{^validCiphertext[AESNonceSize]}, validCiphertext[AESNonceSize+1:]...),
key: validKey,
additionalData: validAAD,
expectError: true,
Expand Down

0 comments on commit 8e24ee4

Please sign in to comment.