Skip to content

Commit

Permalink
fine tune test
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Apr 1, 2022
1 parent d57054e commit 73602a2
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions modules/util/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,10 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/unknwon/com" //nolint:depguard
)

func TestAESGCMEncrypt(t *testing.T) {
t.Parallel()

key := make([]byte, aes.BlockSize)
_, err := rand.Read(key)
assert.NoError(t, err)

plaintext := []byte("this will be encrypted")
_, err = AESGCMEncrypt(key, plaintext)
assert.NoError(t, err)
}

func TestAESGCMDecrypt(t *testing.T) {
func TestAESGCM(t *testing.T) {
t.Parallel()

key := make([]byte, aes.BlockSize)
Expand All @@ -40,4 +29,9 @@ func TestAESGCMDecrypt(t *testing.T) {
assert.NoError(t, err)

assert.Equal(t, plaintext, decrypted)

// at the moment, we make sure the result is the same as the legacy package, this assertion can be removed in next round refactoring
legacy, err := com.AESGCMDecrypt(key, ciphertext)
assert.NoError(t, err)
assert.Equal(t, legacy, plaintext)
}

0 comments on commit 73602a2

Please sign in to comment.