Skip to content

Commit

Permalink
Merge pull request #5923 from mysteriumnetwork/bump-go-ethereum
Browse files Browse the repository at this point in the history
bump more dependencies and get rid of ioutil
  • Loading branch information
Guillembonet authored Nov 15, 2023
2 parents c81cf61 + b396ed0 commit d04911a
Show file tree
Hide file tree
Showing 43 changed files with 124 additions and 141 deletions.
4 changes: 2 additions & 2 deletions ci/deb/tempate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package deb

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -51,7 +51,7 @@ func TermsTemplateFile(path string) error {

defer resp.Body.Close()

terms, err := ioutil.ReadAll(resp.Body)
terms, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions ci/packages/raspberry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ package packages

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/mholt/archiver"
"github.com/mholt/archiver/v3"
"github.com/mysteriumnetwork/go-ci/env"
"github.com/mysteriumnetwork/go-ci/job"
"github.com/mysteriumnetwork/go-ci/shell"
Expand Down Expand Up @@ -192,7 +191,7 @@ func fetchRaspbianImage() (filename string, err error) {
return "", err
}

extractedFiles, err := ioutil.ReadDir(localRaspbianImgDir)
extractedFiles, err := os.ReadDir(localRaspbianImgDir)
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions ci/release/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package release

import (
"fmt"
"io/ioutil"
"os"
"path"
"time"

Expand Down Expand Up @@ -53,7 +53,7 @@ func releaseGithub(opts *releaseGithubOpts) error {
return err
}

artifactFilenames, err := ioutil.ReadDir("build/package")
artifactFilenames, err := os.ReadDir("build/package")
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/commands/cli/command_identities.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package cli
import (
"errors"
"fmt"
"io/ioutil"
"math/big"
"os"
"strconv"
Expand Down Expand Up @@ -554,7 +553,7 @@ func (c *cliApp) importIdentity(actionsArgs []string) (err error) {

blob := []byte(key)
if _, err := os.Stat(key); err == nil {
blob, err = ioutil.ReadFile(key)
blob, err = os.ReadFile(key)
if err != nil {
return fmt.Errorf("can't read provided file: %s reason: %w", key, err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/commands/cli/command_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"

Expand Down Expand Up @@ -242,7 +242,7 @@ func (c *cliApp) invoice(args []string) (err error) {
}
filename := fmt.Sprintf("invoice-%v.pdf", args[1])
clio.Info("Writing invoice to", filename)
return ioutil.WriteFile(filename, resp, 0644)
return os.WriteFile(filename, resp, 0644)
}

func printOrder(o contract.PaymentOrderResponse, rc *remote.Config) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/commands/reset/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package reset

import (
"bytes"
"io/ioutil"
"os"
"testing"

Expand All @@ -30,7 +29,7 @@ import (
)

func TestActionRun(t *testing.T) {
tempDir, err := ioutil.TempDir("", "")
tempDir, err := os.MkdirTemp("", "")
assert.NoError(t, err)
defer os.RemoveAll(tempDir)

Expand Down
7 changes: 3 additions & 4 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package config

import (
"flag"
"io/ioutil"
"os"
"strings"
"testing"
Expand All @@ -42,7 +41,7 @@ func TestUserConfig_Load(t *testing.T) {
[openvpn]
port = 31338
`
err := ioutil.WriteFile(configFileName, []byte(toml), 0700)
err := os.WriteFile(configFileName, []byte(toml), 0700)
assert.NoError(t, err)

// when
Expand Down Expand Up @@ -79,14 +78,14 @@ func TestUserConfig_Save(t *testing.T) {
err = cfg.SaveUserConfig()
// then: only user configuration values are stored
assert.NoError(t, err)
tomlContent, err := ioutil.ReadFile(configFileName)
tomlContent, err := os.ReadFile(configFileName)
assert.NoError(t, err)
assert.Contains(t, string(tomlContent), "port = 22822")
assert.NotContains(t, string(tomlContent), `proto = "tcp"`)
}

func NewTempFileName(t *testing.T) string {
file, err := ioutil.TempFile("", "*")
file, err := os.CreateTemp("", "*")
assert.NoError(t, err)
return file.Name()
}
Expand Down
3 changes: 1 addition & 2 deletions consumer/session/session_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package session

import (
"io/ioutil"
"math/big"
"os"
"testing"
Expand Down Expand Up @@ -483,7 +482,7 @@ func TestSessionStorage_consumeSessionSpendingEvent(t *testing.T) {
}

func newStorage() (*Storage, func()) {
dir, err := ioutil.TempDir("", "sessionStorageTest")
dir, err := os.MkdirTemp("", "sessionStorageTest")
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions core/auth/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package auth
import (
"time"

"github.com/dgrijalva/jwt-go"
"github.com/golang-jwt/jwt/v4"
"github.com/pkg/errors"
)

Expand All @@ -43,7 +43,7 @@ const JWTCookieName string = "token"

type jwtClaims struct {
Username string `json:"username"`
jwt.StandardClaims
jwt.RegisteredClaims
}

const expiresIn = 48 * time.Hour
Expand All @@ -62,8 +62,8 @@ func (jwtAuth *JWTAuthenticator) CreateToken(username string) (JWT, error) {
expirationTime := jwtAuth.getExpirationTime()
claims := &jwtClaims{
Username: username,
StandardClaims: jwt.StandardClaims{
ExpiresAt: expirationTime.Unix(),
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(expirationTime),
},
}

Expand Down
3 changes: 1 addition & 2 deletions core/beneficiary/saver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package beneficiary

import (
"io/ioutil"
"os"
"testing"

Expand All @@ -31,7 +30,7 @@ import (

func TestBeneficiaryChangeStatus(t *testing.T) {
// given:
dir, err := ioutil.TempDir("/tmp", "mysttest")
dir, err := os.MkdirTemp("/tmp", "mysttest")
assert.NoError(t, err)

defer os.RemoveAll(dir)
Expand Down
3 changes: 1 addition & 2 deletions core/discovery/proposal/filter_presets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ import (
"github.com/mysteriumnetwork/node/core/storage/boltdb"
"github.com/stretchr/testify/assert"

"io/ioutil"
"os"
"testing"
)

func Test_ProposalFilterPreset(t *testing.T) {
dir, err := ioutil.TempDir("", "consumerTotalsStorageTest")
dir, err := os.MkdirTemp("", "consumerTotalsStorageTest")
assert.NoError(t, err)
defer os.RemoveAll(dir)

Expand Down
4 changes: 2 additions & 2 deletions core/ip/fallbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package ip

import (
"errors"
"io/ioutil"
"io"
"net"
"strings"

Expand Down Expand Up @@ -64,7 +64,7 @@ func RequestAndParsePlainIPResponse(c *requests.HTTPClient, url string) (string,
}
defer res.Body.Close()

r, err := ioutil.ReadAll(res.Body)
r, err := io.ReadAll(res.Body)
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions core/location/gendb/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package gendb
import (
"compress/gzip"
"encoding/base64"
"io/ioutil"
"io"
"strings"

"github.com/pkg/errors"
Expand All @@ -37,7 +37,7 @@ func EncodedDataLoader(data string, originalSize int, compressed bool) (decompre
}
}

decompressed, err = ioutil.ReadAll(reader)
decompressed, err = io.ReadAll(reader)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions core/location/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"encoding/base64"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"text/template"
Expand All @@ -44,7 +43,7 @@ func main() {
os.Exit(1)
}

binaryData, err := ioutil.ReadFile(*dbFilename)
binaryData, err := os.ReadFile(*dbFilename)
exitOnError(err)
originalDataSize := len(binaryData)

Expand Down
4 changes: 2 additions & 2 deletions core/quality/elastic_search_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package quality

import (
"io/ioutil"
"io"
"strings"
"time"

Expand Down Expand Up @@ -51,7 +51,7 @@ func (transport *elasticSearchTransport) SendEvent(event Event) error {
}
defer response.Body.Close()

bodyBytes, err := ioutil.ReadAll(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
if err != nil {
return errors.Wrapf(err, "error while reading response body")
}
Expand Down
4 changes: 2 additions & 2 deletions core/quality/morqa_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package quality

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -49,7 +49,7 @@ func TestMORQATransport_SendEvent_HandlesSuccess(t *testing.T) {
var events metrics.SignedBatch

server := httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
body, _ := ioutil.ReadAll(request.Body)
body, _ := io.ReadAll(request.Body)
_ = proto.Unmarshal(body, &events)
response.WriteHeader(http.StatusAccepted)
}))
Expand Down
4 changes: 2 additions & 2 deletions core/quality/mysterium_morqa.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"sync"
"time"
Expand Down Expand Up @@ -622,7 +622,7 @@ func (m *MysteriumMORQA) newRequestBinary(method, path string, payload proto.Mes
}

func parseResponseJSON(response *http.Response, dto interface{}) error {
responseJSON, err := ioutil.ReadAll(response.Body)
responseJSON, err := io.ReadAll(response.Body)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions core/storage/boltdb/boltdbtest/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package boltdbtest

import (
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -47,7 +46,7 @@ func CleanupDB(t *testing.T, fileName string, db *storm.DB) {

// CreateTempFile creates a temporary file and returns its path
func CreateTempFile(t *testing.T) string {
file, err := ioutil.TempFile("", "")
file, err := os.CreateTemp("", "")
assert.Nil(t, err)
return file.Name()
}
Expand All @@ -62,7 +61,7 @@ func CleanupTempFile(t *testing.T, fileName string) {

// CreateTempDir creates a temporary directory
func CreateTempDir(t *testing.T) string {
dir, err := ioutil.TempDir("", "")
dir, err := os.MkdirTemp("", "")
assert.Nil(t, err)
return dir
}
Expand Down
Loading

0 comments on commit d04911a

Please sign in to comment.