Skip to content

Commit

Permalink
feat: modernize tests and update metadata
Browse files Browse the repository at this point in the history
Reordered imports in test files and replaced ioutil.ReadAll with io.ReadAll for compatibility with modern Go standards. Improved error handling in defer statements for better clarity. Updated copyright year in LICENSE and cleaned up an obsolete build tag in secp256k1_cgo.go.
  • Loading branch information
Krasovskiy Saveliy Igorevich committed Dec 12, 2024
1 parent 8dbb833 commit c54743c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Weiliang Li
Copyright (c) 2024 Weiliang Li

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
13 changes: 8 additions & 5 deletions ecies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/sha256"
"encoding/hex"
"io"
"io/ioutil"
"math/big"
"net/http"
"net/url"
Expand Down Expand Up @@ -140,13 +139,15 @@ func TestDecryptAgainstPythonVersion(t *testing.T) {
return
}

defer resp.Body.Close()
defer func() {
_ = resp.Body.Close()
}()

if !assert.Equal(t, http.StatusCreated, resp.StatusCode) {
return
}

hexBytes, err := ioutil.ReadAll(resp.Body)
hexBytes, err := io.ReadAll(resp.Body)
if !assert.NoError(t, err) {
return
}
Expand Down Expand Up @@ -184,13 +185,15 @@ func TestEncryptAgainstPythonVersion(t *testing.T) {
return
}

defer resp.Body.Close()
defer func() {
_ = resp.Body.Close()
}()

if !assert.Equal(t, http.StatusCreated, resp.StatusCode) {
return
}

plaintext, err := ioutil.ReadAll(resp.Body)
plaintext, err := io.ReadAll(resp.Body)
if !assert.NoError(t, err) {
return
}
Expand Down
3 changes: 2 additions & 1 deletion privatekey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package eciesgo

import (
"crypto/subtle"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

const privkeyBase = "f0e5b2c3ba4df3fdb3ecea30d0e60c4e4a31d1ba928f51783ae18bbd3cada572"
Expand Down
3 changes: 2 additions & 1 deletion publickey_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package eciesgo

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestNewPublicKeyFromHex(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion secp256k1_cgo.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build cgo && !ecies_test_race
// +build cgo,!ecies_test_race

package eciesgo

Expand Down

0 comments on commit c54743c

Please sign in to comment.