Skip to content

Commit 73602a2

Browse files
committed
fine tune test
1 parent d57054e commit 73602a2

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

modules/util/legacy_test.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,10 @@ import (
1010
"testing"
1111

1212
"github.com/stretchr/testify/assert"
13+
"github.com/unknwon/com" //nolint:depguard
1314
)
1415

15-
func TestAESGCMEncrypt(t *testing.T) {
16-
t.Parallel()
17-
18-
key := make([]byte, aes.BlockSize)
19-
_, err := rand.Read(key)
20-
assert.NoError(t, err)
21-
22-
plaintext := []byte("this will be encrypted")
23-
_, err = AESGCMEncrypt(key, plaintext)
24-
assert.NoError(t, err)
25-
}
26-
27-
func TestAESGCMDecrypt(t *testing.T) {
16+
func TestAESGCM(t *testing.T) {
2817
t.Parallel()
2918

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

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

0 commit comments

Comments
 (0)