Skip to content

Commit

Permalink
replace testutil.NewTestCaseDir() with Go1.15's T.TempDir() (cosmos#7014
Browse files Browse the repository at this point in the history
)

Override go's default version with go 1.15.
  • Loading branch information
Alessio Treglia authored Sep 18, 2020
1 parent 2715af3 commit 3e616a6
Show file tree
Hide file tree
Showing 34 changed files with 175 additions and 263 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,24 @@ jobs:
if: "!contains(github.event.head_commit.message, 'skip-sims')"
steps:
- uses: actions/checkout@v2
- run: |
make build
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- run: make build

install-runsim:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/[email protected]
- name: install runsim
run: |
export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- name: Install runsim
run: export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/[email protected]
- uses: actions/[email protected]
with:
path: ~/go/bin
Expand All @@ -42,6 +49,11 @@ jobs:
needs: [build, install-runsim]
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
with:
SUFFIX_FILTER: |
Expand All @@ -65,6 +77,11 @@ jobs:
needs: [build, install-runsim]
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
with:
SUFFIX_FILTER: |
Expand All @@ -88,6 +105,11 @@ jobs:
needs: [build, install-runsim]
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
with:
SUFFIX_FILTER: |
Expand All @@ -111,6 +133,11 @@ jobs:
needs: [build, install-runsim]
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
with:
SUFFIX_FILTER: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/[email protected]
with:
go-version: 1.14
go-version: 1.15
- name: Unshallow
run: git fetch --prune --unshallow
- name: Create release
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- name: install tparse
run: |
export GO111MODULE="on" && go get github.com/mfridman/[email protected]
Expand All @@ -31,6 +35,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v1
id: git_diff
with:
Expand All @@ -48,6 +57,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- name: Create a file with all the pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
Expand Down Expand Up @@ -76,6 +90,11 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
id: git_diff
with:
Expand Down Expand Up @@ -113,6 +132,11 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
id: git_diff
with:
Expand Down Expand Up @@ -150,6 +174,11 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
id: git_diff
with:
Expand Down Expand Up @@ -187,6 +216,11 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
id: git_diff
with:
Expand Down Expand Up @@ -224,6 +258,11 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
id: git_diff
with:
Expand All @@ -249,6 +288,11 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
id: git_diff
with:
Expand All @@ -274,6 +318,11 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
id: git_diff
with:
Expand All @@ -299,6 +348,11 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v3
id: git_diff
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ It is being used to build [`Gaia`](https://github.com/cosmos/gaia), the first im
**WARNING**: The SDK has mostly stabilized, but we are still making some
breaking changes.

**Note**: Requires [Go 1.14+](https://golang.org/dl/)
**Note**: Requires [Go 1.15+](https://golang.org/dl/)

## Quick Start

Expand Down
10 changes: 2 additions & 8 deletions client/keys/add_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ func Test_runAddCmdLedgerWithCustomCoinType(t *testing.T) {
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())

// Prepare a keybase
kbHome, kbCleanUp := testutil.NewTestCaseDir(t)
require.NotNil(t, kbHome)
t.Cleanup(kbCleanUp)
kbHome := t.TempDir()

cmd.SetArgs([]string{
"keyname1",
Expand Down Expand Up @@ -86,11 +84,7 @@ func Test_runAddCmdLedger(t *testing.T) {
cmd := AddKeyCommand()
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

// Prepare a keybase
kbHome, kbCleanUp := testutil.NewTestCaseDir(t)
require.NotNil(t, kbHome)
t.Cleanup(kbCleanUp)
kbHome := t.TempDir()

cmd.SetArgs([]string{
"keyname1",
Expand Down
7 changes: 2 additions & 5 deletions client/keys/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ func Test_runAddCmdBasic(t *testing.T) {
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())

mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

kbHome, kbCleanUp := testutil.NewTestCaseDir(t)
require.NotNil(t, kbHome)
t.Cleanup(kbCleanUp)

kbHome := t.TempDir()
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn)

require.NoError(t, err)
t.Cleanup(func() {
_ = kb.Delete("keyname1")
Expand Down
4 changes: 1 addition & 3 deletions client/keys/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import (

func Test_runDeleteCmd(t *testing.T) {
// Now add a temporary keybase
kbHome, cleanUp := testutil.NewTestCaseDir(t)
t.Cleanup(cleanUp)

kbHome := t.TempDir()
cmd := DeleteKeyCommand()
cmd.Flags().AddFlagSet(Commands(kbHome).PersistentFlags())
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
Expand Down
3 changes: 1 addition & 2 deletions client/keys/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ func Test_runExportCmd(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

// Now add a temporary keybase
kbHome, cleanUp := testutil.NewTestCaseDir(t)
t.Cleanup(cleanUp)
kbHome := t.TempDir()

// create a key
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn)
Expand Down
5 changes: 2 additions & 3 deletions client/keys/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ func Test_runImportCmd(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

// Now add a temporary keybase
kbHome, cleanUp := testutil.NewTestCaseDir(t)
t.Cleanup(cleanUp)

kbHome := t.TempDir()
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn)

require.NoError(t, err)
t.Cleanup(func() {
kb.Delete("keyname1") // nolint:errcheck
Expand Down
7 changes: 2 additions & 5 deletions client/keys/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ func Test_runListCmd(t *testing.T) {
cmd := ListKeysCmd()
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())

kbHome1, cleanUp1 := testutil.NewTestCaseDir(t)
t.Cleanup(cleanUp1)

kbHome2, cleanUp2 := testutil.NewTestCaseDir(t)
t.Cleanup(cleanUp2)
kbHome1 := t.TempDir()
kbHome2 := t.TempDir()

mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome2, mockIn)
Expand Down
6 changes: 2 additions & 4 deletions client/keys/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ func Test_runMigrateCmd(t *testing.T) {
_ = testutil.ApplyMockIODiscardOutErr(cmd)
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())

kbHome, kbCleanUp := testutil.NewTestCaseDir(t)
copy.Copy("testdata", kbHome)
assert.NotNil(t, kbHome)
t.Cleanup(kbCleanUp)
kbHome := t.TempDir()

copy.Copy("testdata", kbHome)
cmd.SetArgs([]string{
"keyname1",
fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
Expand Down
4 changes: 1 addition & 3 deletions client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ func Test_runShowCmd(t *testing.T) {
cmd.SetArgs([]string{"invalid1", "invalid2"})
require.EqualError(t, cmd.Execute(), "invalid1 is not a valid name or address: decoding bech32 failed: invalid index of 1")

kbHome, cleanUp := testutil.NewTestCaseDir(t)
t.Cleanup(cleanUp)

kbHome := t.TempDir()
fakeKeyName1 := "runShowCmd_Key1"
fakeKeyName2 := "runShowCmd_Key2"

Expand Down
6 changes: 1 addition & 5 deletions client/tx/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -122,11 +121,8 @@ func TestBuildUnsignedTx(t *testing.T) {
}

func TestSign(t *testing.T) {
dir, clean := testutil.NewTestCaseDir(t)
t.Cleanup(clean)

path := hd.CreateHDPath(118, 0, 0).String()
kr, err := keyring.New(t.Name(), "test", dir, nil)
kr, err := keyring.New(t.Name(), "test", t.TempDir(), nil)
require.NoError(t, err)

var from = "test_sign"
Expand Down
8 changes: 3 additions & 5 deletions crypto/keyring/keyring_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down Expand Up @@ -52,8 +51,8 @@ func TestInMemoryCreateLedger(t *testing.T) {
// TestSignVerify does some detailed checks on how we sign and validate
// signatures
func TestSignVerifyKeyRingWithLedger(t *testing.T) {
dir, cleanup := testutil.NewTestCaseDir(t)
t.Cleanup(cleanup)
dir := t.TempDir()

kb, err := New("keybasename", "test", dir, nil)
require.NoError(t, err)

Expand Down Expand Up @@ -89,8 +88,7 @@ func TestSignVerifyKeyRingWithLedger(t *testing.T) {
}

func TestAltKeyring_SaveLedgerKey(t *testing.T) {
dir, clean := testutil.NewTestCaseDir(t)
t.Cleanup(clean)
dir := t.TempDir()

keyring, err := New(t.Name(), BackendTest, dir, nil)
require.NoError(t, err)
Expand Down
Loading

0 comments on commit 3e616a6

Please sign in to comment.