diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index 1fbfb4866..88773e6b4 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -2,7 +2,7 @@ package benchmarks import ( "encoding/json" - "io/ioutil" + "os" "testing" "time" @@ -119,7 +119,7 @@ func InitializeWasmApp(b testing.TB, db dbm.DB, numAccounts int) AppInfo { wasmApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height, Time: time.Now()}}) // upload the code - cw20Code, err := ioutil.ReadFile("./testdata/cw20_base.wasm") + cw20Code, err := os.ReadFile("./testdata/cw20_base.wasm") require.NoError(b, err) storeMsg := wasmtypes.MsgStoreCode{ Sender: addr.String(), diff --git a/x/wasm/client/cli/genesis_msg_test.go b/x/wasm/client/cli/genesis_msg_test.go index 4de9e7e3d..78a1c53b5 100644 --- a/x/wasm/client/cli/genesis_msg_test.go +++ b/x/wasm/client/cli/genesis_msg_test.go @@ -3,7 +3,6 @@ package cli import ( "context" "encoding/json" - "io/ioutil" "os" "path" "testing" @@ -42,7 +41,7 @@ func TestGenesisStoreCodeCmd(t *testing.T) { minimalWasmGenesis := types.GenesisState{ Params: types.DefaultParams(), } - anyValidWasmFile, err := ioutil.TempFile(t.TempDir(), "wasm") + anyValidWasmFile, err := os.CreateTemp(t.TempDir(), "wasm") require.NoError(t, err) anyValidWasmFile.Write(wasmIdent) require.NoError(t, anyValidWasmFile.Close()) @@ -109,7 +108,7 @@ func TestInstantiateContractCmd(t *testing.T) { minimalWasmGenesis := types.GenesisState{ Params: types.DefaultParams(), } - anyValidWasmFile, err := ioutil.TempFile(t.TempDir(), "wasm") + anyValidWasmFile, err := os.CreateTemp(t.TempDir(), "wasm") require.NoError(t, err) anyValidWasmFile.Write(wasmIdent) require.NoError(t, anyValidWasmFile.Close()) @@ -368,7 +367,7 @@ func TestExecuteContractCmd(t *testing.T) { minimalWasmGenesis := types.GenesisState{ Params: types.DefaultParams(), } - anyValidWasmFile, err := ioutil.TempFile(t.TempDir(), "wasm") + anyValidWasmFile, err := os.CreateTemp(t.TempDir(), "wasm") require.NoError(t, err) anyValidWasmFile.Write(wasmIdent) require.NoError(t, anyValidWasmFile.Close()) diff --git a/x/wasm/ioutils/ioutil_test.go b/x/wasm/ioutils/ioutil_test.go index 13bbbb110..93a478ae0 100644 --- a/x/wasm/ioutils/ioutil_test.go +++ b/x/wasm/ioutils/ioutil_test.go @@ -5,7 +5,7 @@ import ( "compress/gzip" "errors" "io" - "io/ioutil" + "os" "strings" "testing" @@ -16,10 +16,10 @@ import ( ) func TestUncompress(t *testing.T) { - wasmRaw, err := ioutil.ReadFile("../keeper/testdata/hackatom.wasm") + wasmRaw, err := os.ReadFile("../keeper/testdata/hackatom.wasm") require.NoError(t, err) - wasmGzipped, err := ioutil.ReadFile("../keeper/testdata/hackatom.wasm.gzip") + wasmGzipped, err := os.ReadFile("../keeper/testdata/hackatom.wasm.gzip") require.NoError(t, err) const maxSize = 400_000 diff --git a/x/wasm/ioutils/utils_test.go b/x/wasm/ioutils/utils_test.go index 0d2c0a130..cd4846f09 100644 --- a/x/wasm/ioutils/utils_test.go +++ b/x/wasm/ioutils/utils_test.go @@ -1,14 +1,14 @@ package ioutils import ( - "io/ioutil" + "os" "testing" "github.com/stretchr/testify/require" ) func GetTestData() ([]byte, []byte, []byte, error) { - wasmCode, err := ioutil.ReadFile("../keeper/testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("../keeper/testdata/hackatom.wasm") if err != nil { return nil, nil, nil, err } diff --git a/x/wasm/keeper/bench_test.go b/x/wasm/keeper/bench_test.go index ca5489d5b..1ad1693bb 100644 --- a/x/wasm/keeper/bench_test.go +++ b/x/wasm/keeper/bench_test.go @@ -1,7 +1,7 @@ package keeper import ( - "io/ioutil" + "os" "testing" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -89,7 +89,7 @@ func BenchmarkCompilation(b *testing.B) { ctx, keepers := createTestInput(b, false, SupportedFeatures, wasmConfig, db) // print out code size for comparisons - code, err := ioutil.ReadFile(spec.wasmFile) + code, err := os.ReadFile(spec.wasmFile) require.NoError(b, err) b.Logf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b(size: %d) ", len(code)) diff --git a/x/wasm/keeper/genesis_test.go b/x/wasm/keeper/genesis_test.go index ff7c6db53..f4e5b476a 100644 --- a/x/wasm/keeper/genesis_test.go +++ b/x/wasm/keeper/genesis_test.go @@ -6,7 +6,6 @@ import ( "encoding/base64" "errors" "fmt" - "io/ioutil" "math/rand" "os" "testing" @@ -40,7 +39,7 @@ func TestGenesisExportImport(t *testing.T) { wasmKeeper, srcCtx, srcStoreKeys := setupKeeper(t) contractKeeper := NewGovPermissionKeeper(wasmKeeper) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) // store some test data @@ -153,7 +152,7 @@ func TestGenesisExportImport(t *testing.T) { } func TestGenesisInit(t *testing.T) { - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) myCodeInfo := wasmTypes.CodeInfoFixture(wasmTypes.WithSHA256CodeHash(wasmCode)) @@ -498,7 +497,7 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { keeper, ctx, _ := setupKeeper(t) contractKeeper := NewGovPermissionKeeper(keeper) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) wasmCodeHash := sha256.Sum256(wasmCode) @@ -564,7 +563,7 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { } func TestSupportedGenMsgTypes(t *testing.T) { - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) var ( myAddress sdk.AccAddress = bytes.Repeat([]byte{1}, types.ContractAddrLen) @@ -636,7 +635,7 @@ func TestSupportedGenMsgTypes(t *testing.T) { func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) { t.Helper() - tempDir, err := ioutil.TempDir("", "wasm") + tempDir, err := os.MkdirTemp("", "wasm") require.NoError(t, err) t.Cleanup(func() { os.RemoveAll(tempDir) }) var ( diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 14ce0d973..ba1ccdc73 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -4,8 +4,8 @@ import ( "bytes" "encoding/json" "errors" - "io/ioutil" "math" + "os" "testing" "time" @@ -31,7 +31,7 @@ import ( // When migrated to go 1.16, embed package should be used instead. func init() { - b, err := ioutil.ReadFile("./testdata/hackatom.wasm") + b, err := os.ReadFile("./testdata/hackatom.wasm") if err != nil { panic(err) } @@ -348,7 +348,7 @@ func TestCreateWithGzippedPayload(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm.gzip") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm.gzip") require.NoError(t, err, "reading gzipped WASM code") contractID, err := keeper.Create(ctx, creator, wasmCode, nil) @@ -1097,7 +1097,7 @@ func TestMigrateWithDispatchedMessage(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) fred := keepers.Faucet.NewFundedAccount(ctx, sdk.NewInt64Coin("denom", 5000)) - burnerCode, err := ioutil.ReadFile("./testdata/burner.wasm") + burnerCode, err := os.ReadFile("./testdata/burner.wasm") require.NoError(t, err) originalContractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) diff --git a/x/wasm/keeper/legacy_querier_test.go b/x/wasm/keeper/legacy_querier_test.go index e21dd2353..dac7eaa78 100644 --- a/x/wasm/keeper/legacy_querier_test.go +++ b/x/wasm/keeper/legacy_querier_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "os" "testing" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +24,7 @@ func TestLegacyQueryContractState(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) anyAddr := keepers.Faucet.NewFundedAccount(ctx, sdk.NewInt64Coin("denom", 5000)) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) contractID, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) @@ -162,7 +162,7 @@ func TestLegacyQueryContractListByCodeOrdering(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) anyAddr := keepers.Faucet.NewFundedAccount(ctx, topUp...) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) codeID, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) @@ -312,7 +312,7 @@ func TestLegacyQueryContractHistory(t *testing.T) { } func TestLegacyQueryCodeList(t *testing.T) { - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) specs := map[string]struct { diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index 3d5097b50..6d9b76529 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -5,7 +5,7 @@ import ( "encoding/hex" "encoding/json" "errors" - "io/ioutil" + "os" "testing" "github.com/cosmos/cosmos-sdk/x/params/client/utils" @@ -30,7 +30,7 @@ func TestStoreCodeProposal(t *testing.T) { CodeUploadAccess: types.AllowNobody, InstantiateDefaultPermission: types.AccessTypeNobody, }) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) myActorAddress := RandomBech32AccountAddress(t) @@ -68,7 +68,7 @@ func TestInstantiateProposal(t *testing.T) { InstantiateDefaultPermission: types.AccessTypeNobody, }) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) require.NoError(t, wasmKeeper.importCode(ctx, 1, @@ -131,7 +131,7 @@ func TestInstantiateProposal_NoAdmin(t *testing.T) { InstantiateDefaultPermission: types.AccessTypeNobody, }) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) require.NoError(t, wasmKeeper.importCode(ctx, 1, @@ -203,7 +203,7 @@ func TestMigrateProposal(t *testing.T) { InstantiateDefaultPermission: types.AccessTypeNobody, }) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) codeInfoFixture := types.CodeInfoFixture(types.WithSHA256CodeHash(wasmCode)) @@ -394,7 +394,7 @@ func TestAdminProposals(t *testing.T) { otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) contractAddr = BuildContractAddress(1, 1) ) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) specs := map[string]struct { diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index f473f52fa..d9721f91b 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "os" "testing" "time" @@ -265,7 +265,7 @@ func TestQueryContractListByCodeOrdering(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) anyAddr := keepers.Faucet.NewFundedAccount(ctx, topUp...) - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) codeID, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) @@ -454,7 +454,7 @@ func TestQueryContractHistory(t *testing.T) { } func TestQueryCodeList(t *testing.T) { - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) ctx, keepers := CreateTestInput(t, false, SupportedFeatures) @@ -656,7 +656,7 @@ func TestQueryPinnedCodes(t *testing.T) { } func TestQueryCodeInfo(t *testing.T) { - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) ctx, keepers := CreateTestInput(t, false, SupportedFeatures) @@ -711,7 +711,7 @@ func TestQueryCodeInfo(t *testing.T) { } func TestQueryCodeInfoList(t *testing.T) { - wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) ctx, keepers := CreateTestInput(t, false, SupportedFeatures) diff --git a/x/wasm/keeper/reflect_test.go b/x/wasm/keeper/reflect_test.go index 2f89a265c..079324fac 100644 --- a/x/wasm/keeper/reflect_test.go +++ b/x/wasm/keeper/reflect_test.go @@ -2,7 +2,7 @@ package keeper import ( "encoding/json" - "io/ioutil" + "os" "strings" "testing" @@ -52,7 +52,7 @@ func TestReflectContractSend(t *testing.T) { require.Equal(t, uint64(1), reflectID) // upload hackatom escrow code - escrowCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + escrowCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) escrowID, err := keeper.Create(ctx, creator, escrowCode, nil) require.NoError(t, err) diff --git a/x/wasm/keeper/snapshotter_integration_test.go b/x/wasm/keeper/snapshotter_integration_test.go index 49f2ca6ba..bef6cf005 100644 --- a/x/wasm/keeper/snapshotter_integration_test.go +++ b/x/wasm/keeper/snapshotter_integration_test.go @@ -2,7 +2,7 @@ package keeper_test import ( "crypto/sha256" - "io/ioutil" + "os" "testing" "time" @@ -53,7 +53,7 @@ func TestSnapshotter(t *testing.T) { srcCodeIDToChecksum := make(map[uint64][]byte, len(spec.wasmFiles)) for i, v := range spec.wasmFiles { - wasmCode, err := ioutil.ReadFile(v) + wasmCode, err := os.ReadFile(v) require.NoError(t, err) codeID, err := contractKeeper.Create(ctx, genesisAddr, wasmCode, nil) require.NoError(t, err) diff --git a/x/wasm/keeper/staking_test.go b/x/wasm/keeper/staking_test.go index b6d719f13..633cbcf1f 100644 --- a/x/wasm/keeper/staking_test.go +++ b/x/wasm/keeper/staking_test.go @@ -2,7 +2,7 @@ package keeper import ( "encoding/json" - "io/ioutil" + "os" "testing" wasmvmtypes "github.com/CosmWasm/wasmvm/types" @@ -106,7 +106,7 @@ func TestInitializeStaking(t *testing.T) { creator := k.Faucet.NewFundedAccount(ctx, deposit...) // upload staking derivates code - stakingCode, err := ioutil.ReadFile("./testdata/staking.wasm") + stakingCode, err := os.ReadFile("./testdata/staking.wasm") require.NoError(t, err) stakingID, err := keeper.Create(ctx, creator, stakingCode, nil) require.NoError(t, err) @@ -189,7 +189,7 @@ func initializeStaking(t *testing.T) initInfo { creator := k.Faucet.NewFundedAccount(ctx, deposit...) // upload staking derivates code - stakingCode, err := ioutil.ReadFile("./testdata/staking.wasm") + stakingCode, err := os.ReadFile("./testdata/staking.wasm") require.NoError(t, err) stakingID, err := k.ContractKeeper.Create(ctx, creator, stakingCode, nil) require.NoError(t, err) diff --git a/x/wasm/keeper/submsg_test.go b/x/wasm/keeper/submsg_test.go index 4cf25fc89..d1f1d30cd 100644 --- a/x/wasm/keeper/submsg_test.go +++ b/x/wasm/keeper/submsg_test.go @@ -3,7 +3,7 @@ package keeper import ( "encoding/json" "fmt" - "io/ioutil" + "os" "strconv" "testing" @@ -117,7 +117,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { require.NoError(t, err) // create hackatom contract for testing (for infinite loop) - hackatomCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + hackatomCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) hackatomID, err := keepers.ContractKeeper.Create(ctx, uploader, hackatomCode, nil) require.NoError(t, err) diff --git a/x/wasm/module_test.go b/x/wasm/module_test.go index ab52363b7..f9dde8769 100644 --- a/x/wasm/module_test.go +++ b/x/wasm/module_test.go @@ -3,7 +3,7 @@ package wasm import ( "encoding/json" "fmt" - "io/ioutil" + "os" "testing" "github.com/CosmWasm/wasmd/x/wasm/keeper/testdata" @@ -57,7 +57,7 @@ func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { } func mustLoad(path string) []byte { - bz, err := ioutil.ReadFile(path) + bz, err := os.ReadFile(path) if err != nil { panic(err) }