Skip to content

Commit

Permalink
chore: replace deprecated function (#103)
Browse files Browse the repository at this point in the history
* chore: replace deprecated function

Signed-off-by: zemyblue <zemyblue@gmail.com>

* chore: update changelog

Signed-off-by: zemyblue <zemyblue@gmail.com>

* Update CHANGELOG.md

Co-authored-by: Youngtaek Yoon <noreply@yoon.anonaddy.me>

Signed-off-by: zemyblue <zemyblue@gmail.com>
Co-authored-by: Youngtaek Yoon <noreply@yoon.anonaddy.me>
  • Loading branch information
zemyblue and 0Tech authored Oct 26, 2022
1 parent 2e8cac3 commit 11b4e03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
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

0 comments on commit 11b4e03

Please sign in to comment.