Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace deprecated function #103

Merged
merged 3 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements

### Bug Fixes
* (global) [\#103](https://github.com/line/lbm/pull/103) replace deprecated functions of ioutil package

### Improvements

Expand Down
5 changes: 2 additions & 3 deletions cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -1113,7 +1112,7 @@ func TestLBMCollectGentxs(t *testing.T) {
f := NewFixtures(t, getHomeDir(t))

// Initialize temporary directories
gentxDir, err := ioutil.TempDir("", "")
gentxDir, err := os.MkdirTemp("", "")
gentxDoc := filepath.Join(gentxDir, "gentx.json")
require.NoError(t, err)

Expand Down Expand Up @@ -1278,7 +1277,7 @@ func TestLBMWasmContract(t *testing.T) {
require.Len(t, queryCodesResponse.CodeInfos, 1)

// validate the hash is the same
expectedRow, err := ioutil.ReadFile(hashFile)
expectedRow, err := os.ReadFile(hashFile)
require.NoError(t, err)
expected, err := hex.DecodeString(string(expectedRow[:64]))
require.NoError(t, err)
Expand Down
15 changes: 7 additions & 8 deletions cli_test/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -177,7 +176,7 @@ func getHomeDir(t *testing.T) string {
tmpDir := path.Join(os.ExpandEnv("$HOME"), ".lbmtest")
err := os.MkdirAll(tmpDir, os.ModePerm)
require.NoError(t, err)
tmpDir, err = ioutil.TempDir(tmpDir, "link_integration_"+strings.Split(t.Name(), "/")[0]+"_")
tmpDir, err = os.MkdirTemp(tmpDir, "link_integration_"+strings.Split(t.Name(), "/")[0]+"_")
require.NoError(t, err)
return tmpDir
}
Expand Down Expand Up @@ -1147,7 +1146,7 @@ func (fg *FixtureGroup) initNodes(numberOfNodes int) {
t := fg.T

// Initialize temporary directories
gentxDir, err := ioutil.TempDir("", "")
gentxDir, err := os.MkdirTemp("", "")
require.NoError(t, err)
defer func() {
require.NoError(t, os.RemoveAll(gentxDir))
Expand Down Expand Up @@ -1179,13 +1178,13 @@ func (fg *FixtureGroup) initNodes(numberOfNodes int) {
f.CollectGenTxs(fmt.Sprintf("--gentx-dir=%s", gentxDir))
f.ValidateGenesis(filepath.Join(f.Home, "config", "genesis.json"))
if len(fg.genesisFileContent) == 0 {
fg.genesisFileContent, err = ioutil.ReadFile(f.GenesisFile())
fg.genesisFileContent, err = os.ReadFile(f.GenesisFile())
require.NoError(t, err)
}
}

for _, f := range fg.fixturesMap {
err := ioutil.WriteFile(f.GenesisFile(), fg.genesisFileContent, os.ModePerm)
err := os.WriteFile(f.GenesisFile(), fg.genesisFileContent, os.ModePerm)
require.NoError(t, err)
}
}
Expand All @@ -1212,7 +1211,7 @@ func (fg *FixtureGroup) AddFullNode(flags ...string) *Fixtures {
chainID := fg.T.Name()

name := fmt.Sprintf("%s-%s%d", t.Name(), namePrefix, idx)
tmpDir, err := ioutil.TempDir("", "")
tmpDir, err := os.MkdirTemp("", "")
require.NoError(t, err)

appCfg := srvconfig.DefaultConfig()
Expand All @@ -1231,7 +1230,7 @@ func (fg *FixtureGroup) AddFullNode(flags ...string) *Fixtures {
if len(fg.genesisFileContent) == 0 {
panic("genesis file is not loaded")
}
err := ioutil.WriteFile(f.GenesisFile(), fg.genesisFileContent, os.ModePerm)
err := os.WriteFile(f.GenesisFile(), fg.genesisFileContent, os.ModePerm)
require.NoError(t, err)
}

Expand Down Expand Up @@ -1336,7 +1335,7 @@ func addFlags(args string, flags ...string) []string {

// Write the given string to a new temporary file
func WriteToNewTempFile(t *testing.T, s string) *os.File {
fp, err := ioutil.TempFile(os.TempDir(), "cosmos_cli_test_")
fp, err := os.CreateTemp(os.TempDir(), "cosmos_cli_test_")
require.Nil(t, err)
_, err = fp.WriteString(s)
require.Nil(t, err)
Expand Down