replace testutil.NewTestCaseDir() with Go1.15's T.TempDir() (#7014)
Override go's default version with go 1.15.
This commit is contained in:
parent
2715af34a2
commit
3e616a60d5
|
@ -21,17 +21,24 @@ jobs:
|
|||
if: "!contains(github.event.head_commit.message, 'skip-sims')"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: |
|
||||
make build
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
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/setup-go@v2.1.2
|
||||
- name: install runsim
|
||||
run: |
|
||||
export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0
|
||||
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/runsim@v1.0.0
|
||||
- uses: actions/cache@v2.1.1
|
||||
with:
|
||||
path: ~/go/bin
|
||||
|
@ -42,6 +49,11 @@ jobs:
|
|||
needs: [build, install-runsim]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
with:
|
||||
SUFFIX_FILTER: |
|
||||
|
@ -65,6 +77,11 @@ jobs:
|
|||
needs: [build, install-runsim]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
with:
|
||||
SUFFIX_FILTER: |
|
||||
|
@ -88,6 +105,11 @@ jobs:
|
|||
needs: [build, install-runsim]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
with:
|
||||
SUFFIX_FILTER: |
|
||||
|
@ -111,6 +133,11 @@ jobs:
|
|||
needs: [build, install-runsim]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
with:
|
||||
SUFFIX_FILTER: |
|
||||
|
|
|
@ -15,7 +15,7 @@ jobs:
|
|||
- name: Install Go
|
||||
uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.14
|
||||
go-version: 1.15
|
||||
- name: Unshallow
|
||||
run: git fetch --prune --unshallow
|
||||
- name: Create release
|
||||
|
|
|
@ -19,6 +19,10 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- name: install tparse
|
||||
run: |
|
||||
export GO111MODULE="on" && go get github.com/mfridman/tparse@v0.8.3
|
||||
|
@ -31,6 +35,11 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v1
|
||||
id: git_diff
|
||||
with:
|
||||
|
@ -48,6 +57,11 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
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
|
||||
|
@ -76,6 +90,11 @@ jobs:
|
|||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
|
@ -113,6 +132,11 @@ jobs:
|
|||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
|
@ -150,6 +174,11 @@ jobs:
|
|||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
|
@ -187,6 +216,11 @@ jobs:
|
|||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
|
@ -224,6 +258,11 @@ jobs:
|
|||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
|
@ -249,6 +288,11 @@ jobs:
|
|||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
|
@ -274,6 +318,11 @@ jobs:
|
|||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
|
@ -299,6 +348,11 @@ jobs:
|
|||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2.1.2
|
||||
with:
|
||||
go-version: 1.15
|
||||
- name: Display go version
|
||||
run: go version
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
@ -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",
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
|
@ -30,9 +29,9 @@ func init() {
|
|||
}
|
||||
|
||||
func TestNewKeyring(t *testing.T) {
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
dir := t.TempDir()
|
||||
mockIn := strings.NewReader("")
|
||||
t.Cleanup(cleanup)
|
||||
|
||||
kr, err := New("cosmos", BackendFile, dir, mockIn)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -48,9 +47,7 @@ func TestNewKeyring(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKeyManagementKeyRing(t *testing.T) {
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
kb, err := New("keybasename", "test", dir, nil)
|
||||
kb, err := New("keybasename", "test", t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
algo := hd.Secp256k1
|
||||
|
@ -130,8 +127,7 @@ func TestKeyManagementKeyRing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSignVerifyKeyRing(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)
|
||||
|
@ -209,9 +205,7 @@ func TestSignVerifyKeyRing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExportImportKeyRing(t *testing.T) {
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
kb, err := New("keybasename", "test", dir, nil)
|
||||
kb, err := New("keybasename", "test", t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
info, _, err := kb.NewMnemonic("john", English, sdk.FullFundraiserPath, hd.Secp256k1)
|
||||
|
@ -243,9 +237,7 @@ func TestExportImportKeyRing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExportImportPubKeyKeyRing(t *testing.T) {
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
kb, err := New("keybasename", "test", dir, nil)
|
||||
kb, err := New("keybasename", "test", t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
algo := hd.Secp256k1
|
||||
|
||||
|
@ -283,8 +275,7 @@ func TestExportImportPubKeyKeyRing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAdvancedKeyManagementKeyRing(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)
|
||||
|
@ -319,8 +310,8 @@ func TestAdvancedKeyManagementKeyRing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSeedPhraseKeyRing(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)
|
||||
|
||||
|
@ -350,9 +341,7 @@ func TestSeedPhraseKeyRing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKeyringKeybaseExportImportPrivKey(t *testing.T) {
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
kb, err := New("keybasename", "test", dir, nil)
|
||||
kb, err := New("keybasename", "test", t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, _, err = kb.NewMnemonic("john", English, sdk.FullFundraiserPath, hd.Secp256k1)
|
||||
|
@ -730,10 +719,7 @@ func TestInMemorySeedPhrase(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKeyChain_ShouldFailWhenAddingSameGeneratedAccount(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
kr, err := New(t.Name(), BackendTest, dir, nil)
|
||||
kr, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Given we create a mnemonic
|
||||
|
@ -802,8 +788,7 @@ func ExampleNew() {
|
|||
}
|
||||
|
||||
func TestAltKeyring_List(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)
|
||||
|
@ -836,10 +821,7 @@ func TestAltKeyring_List(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_NewAccount(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
entropy, err := bip39.NewEntropy(defaultEntropySize)
|
||||
|
@ -865,10 +847,7 @@ func TestAltKeyring_NewAccount(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_Get(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := someKey
|
||||
|
@ -881,10 +860,7 @@ func TestAltKeyring_Get(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_KeyByAddress(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := someKey
|
||||
|
@ -897,10 +873,7 @@ func TestAltKeyring_KeyByAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_Delete(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := someKey
|
||||
|
@ -920,10 +893,7 @@ func TestAltKeyring_Delete(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_DeleteByAddress(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := someKey
|
||||
|
@ -943,10 +913,7 @@ func TestAltKeyring_DeleteByAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_SavePubKey(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
list, err := keyring.List()
|
||||
|
@ -969,10 +936,7 @@ func TestAltKeyring_SavePubKey(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_SaveMultisig(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
mnemonic1, _, err := keyring.NewMnemonic("key1", English, sdk.FullFundraiserPath, hd.Secp256k1)
|
||||
|
@ -1000,10 +964,7 @@ func TestAltKeyring_SaveMultisig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_Sign(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := "jack"
|
||||
|
@ -1019,10 +980,7 @@ func TestAltKeyring_Sign(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_SignByAddress(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := "jack"
|
||||
|
@ -1038,10 +996,7 @@ func TestAltKeyring_SignByAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_ImportExportPrivKey(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := theID
|
||||
|
@ -1067,10 +1022,7 @@ func TestAltKeyring_ImportExportPrivKey(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_ImportExportPrivKey_ByAddress(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := theID
|
||||
|
@ -1097,10 +1049,7 @@ func TestAltKeyring_ImportExportPrivKey_ByAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_ImportExportPubKey(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := theID
|
||||
|
@ -1122,10 +1071,7 @@ func TestAltKeyring_ImportExportPubKey(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_ImportExportPubKey_ByAddress(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
uid := theID
|
||||
|
@ -1147,10 +1093,7 @@ func TestAltKeyring_ImportExportPubKey_ByAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAltKeyring_ConstructorSupportedAlgos(t *testing.T) {
|
||||
dir, clean := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean)
|
||||
|
||||
keyring, err := New(t.Name(), BackendTest, dir, nil)
|
||||
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
// should fail when using unsupported signing algorythm.
|
||||
|
@ -1162,10 +1105,7 @@ func TestAltKeyring_ConstructorSupportedAlgos(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
// but we can create a new keybase with our provided algos.
|
||||
dir2, clean2 := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(clean2)
|
||||
|
||||
keyring2, err := New(t.Name(), BackendTest, dir2, nil, func(options *Options) {
|
||||
keyring2, err := New(t.Name(), BackendTest, t.TempDir(), nil, func(options *Options) {
|
||||
options.SupportedAlgos = SigningAlgoList{
|
||||
notSupportedAlgo{},
|
||||
}
|
||||
|
|
|
@ -9,20 +9,18 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
)
|
||||
|
||||
func TestNewLegacyKeyBase(t *testing.T) {
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
dir := t.TempDir()
|
||||
|
||||
kb, err := keyring.NewLegacy("keybasename", dir)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, kb.Close())
|
||||
}
|
||||
|
||||
func TestLegacyKeybase(t *testing.T) {
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
dir := t.TempDir()
|
||||
|
||||
// Backup testdata
|
||||
require.NoError(t, copy.Copy("testdata", dir))
|
||||
|
|
|
@ -5,11 +5,12 @@ import (
|
|||
|
||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
||||
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
crypto "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
multisigtypes "github.com/cosmos/cosmos-sdk/crypto/types/multisig"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
var _ multisigtypes.PubKey = &LegacyAminoPubKey{}
|
||||
|
|
|
@ -3,17 +3,19 @@ package multisig_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
crypto "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestAddress(t *testing.T) {
|
||||
|
|
|
@ -5,23 +5,18 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
)
|
||||
|
||||
func Test_openDB(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
_, err := openDB(dir)
|
||||
_, err := openDB(t.TempDir())
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func Test_openTraceWriter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
fname := filepath.Join(dir, "logfile")
|
||||
|
||||
fname := filepath.Join(t.TempDir(), "logfile")
|
||||
w, err := openTraceWriter(fname)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, w)
|
||||
|
|
|
@ -25,14 +25,12 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
)
|
||||
|
||||
func TestExportCmd_ConsensusParams(t *testing.T) {
|
||||
tempDir, clean := testutil.NewTestCaseDir(t)
|
||||
defer clean()
|
||||
tempDir := t.TempDir()
|
||||
|
||||
_, ctx, genDoc, cmd := setupApp(t, tempDir)
|
||||
|
||||
|
@ -58,12 +56,10 @@ func TestExportCmd_ConsensusParams(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExportCmd_HomeDir(t *testing.T) {
|
||||
tempDir, clean := testutil.NewTestCaseDir(t)
|
||||
defer clean()
|
||||
|
||||
_, ctx, _, cmd := setupApp(t, tempDir)
|
||||
_, ctx, _, cmd := setupApp(t, t.TempDir())
|
||||
|
||||
cmd.SetArgs([]string{fmt.Sprintf("--%s=%s", flags.FlagHome, "foobar")})
|
||||
|
||||
err := cmd.ExecuteContext(ctx)
|
||||
require.EqualError(t, err, "stat foobar/config/genesis.json: no such file or directory")
|
||||
}
|
||||
|
@ -98,9 +94,7 @@ func TestExportCmd_Height(t *testing.T) {
|
|||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
tempDir, clean := testutil.NewTestCaseDir(t)
|
||||
defer clean()
|
||||
|
||||
tempDir := t.TempDir()
|
||||
app, ctx, _, cmd := setupApp(t, tempDir)
|
||||
|
||||
// Fast forward to block `tc.fastForward`.
|
||||
|
@ -128,8 +122,7 @@ func TestExportCmd_Height(t *testing.T) {
|
|||
}
|
||||
|
||||
func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *tmtypes.GenesisDoc, *cobra.Command) {
|
||||
err := createConfigFolder(tempDir)
|
||||
if err != nil {
|
||||
if err := createConfigFolder(tempDir); err != nil {
|
||||
t.Fatalf("error creating config folder: %s", err)
|
||||
}
|
||||
|
||||
|
@ -142,11 +135,9 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t
|
|||
serverCtx.Config.RootDir = tempDir
|
||||
|
||||
clientCtx := client.Context{}.WithJSONMarshaler(app.AppCodec())
|
||||
|
||||
genDoc := newDefaultGenesisDoc()
|
||||
err = saveGenesisFile(genDoc, serverCtx.Config.GenesisFile())
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, saveGenesisFile(genDoc, serverCtx.Config.GenesisFile()))
|
||||
app.InitChain(
|
||||
abci.RequestInitChain{
|
||||
Validators: []abci.ValidatorUpdate{},
|
||||
|
@ -154,7 +145,6 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t
|
|||
AppStateBytes: genDoc.AppState,
|
||||
},
|
||||
)
|
||||
|
||||
app.Commit()
|
||||
|
||||
cmd := server.ExportCmd(
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
|
@ -25,10 +24,8 @@ func TestGenerateCoinKey(t *testing.T) {
|
|||
|
||||
func TestGenerateSaveCoinKey(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
|
||||
kb, err := keyring.New(t.Name(), "test", dir, nil)
|
||||
kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
addr, mnemonic, err := server.GenerateSaveCoinKey(kb, "keyname", false, hd.Secp256k1)
|
||||
|
@ -47,10 +44,8 @@ func TestGenerateSaveCoinKey(t *testing.T) {
|
|||
|
||||
func TestGenerateSaveCoinKeyOverwriteFlag(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
|
||||
kb, err := keyring.New(t.Name(), "test", dir, nil)
|
||||
kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
keyname := "justakey"
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simcmd "github.com/cosmos/cosmos-sdk/simapp/simd/cmd"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
|
@ -54,9 +53,7 @@ func TestAddGenesisAccountCmd(t *testing.T) {
|
|||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
home, cleanup := testutil.NewTestCaseDir(t)
|
||||
defer cleanup()
|
||||
|
||||
home := t.TempDir()
|
||||
logger := log.NewNopLogger()
|
||||
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -12,15 +12,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// NewTestCaseDir creates a new temporary directory for a test case.
|
||||
// Returns the directory path and a cleanup function.
|
||||
// nolint: errcheck
|
||||
func NewTestCaseDir(t testing.TB) (string, func()) {
|
||||
dir, err := ioutil.TempDir("", strings.ReplaceAll(t.Name(), "/", "_")+"_")
|
||||
require.NoError(t, err)
|
||||
return dir, func() { os.RemoveAll(dir) }
|
||||
}
|
||||
|
||||
// BufferReader is implemented by types that read from a string buffer.
|
||||
type BufferReader interface {
|
||||
io.Reader
|
||||
|
|
|
@ -10,23 +10,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
)
|
||||
|
||||
func TestNewTestCaseDir(t *testing.T) {
|
||||
dir1, cleanup1 := testutil.NewTestCaseDir(t)
|
||||
dir2, cleanup2 := testutil.NewTestCaseDir(t)
|
||||
|
||||
require.NotEqual(t, dir1, dir2)
|
||||
require.DirExists(t, dir1)
|
||||
require.DirExists(t, dir2)
|
||||
|
||||
cleanup1()
|
||||
|
||||
require.NoDirExists(t, dir1)
|
||||
require.DirExists(t, dir2)
|
||||
|
||||
cleanup2()
|
||||
require.NoDirExists(t, dir2)
|
||||
}
|
||||
|
||||
func TestApplyMockIO(t *testing.T) {
|
||||
cmd := &cobra.Command{}
|
||||
oldStdin := cmd.InOrStdin()
|
||||
|
|
|
@ -773,9 +773,7 @@ func TestGetBroadcastCommand_WithoutOfflineFlag(t *testing.T) {
|
|||
|
||||
cmd := authcli.GetBroadcastCommand()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
testDir, cleanFunc := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanFunc)
|
||||
testDir := t.TempDir()
|
||||
|
||||
// Create new file with tx
|
||||
builder := txCfg.NewTxBuilder()
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -687,9 +686,8 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() {
|
|||
func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
invalidPropFile, err := ioutil.TempFile(os.TempDir(), "invalid_community_spend_proposal.*.json")
|
||||
invalidPropFile, err := ioutil.TempFile(s.T().TempDir(), "invalid_community_spend_proposal.*.json")
|
||||
s.Require().NoError(err)
|
||||
defer os.Remove(invalidPropFile.Name())
|
||||
|
||||
invalidProp := `{
|
||||
"title": "",
|
||||
|
@ -702,9 +700,8 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
|
|||
_, err = invalidPropFile.WriteString(invalidProp)
|
||||
s.Require().NoError(err)
|
||||
|
||||
validPropFile, err := ioutil.TempFile(os.TempDir(), "valid_community_spend_proposal.*.json")
|
||||
validPropFile, err := ioutil.TempFile(s.T().TempDir(), "valid_community_spend_proposal.*.json")
|
||||
s.Require().NoError(err)
|
||||
defer os.Remove(validPropFile.Name())
|
||||
|
||||
validProp := fmt.Sprintf(`{
|
||||
"title": "Community Pool Spend",
|
||||
|
|
|
@ -48,9 +48,7 @@ func (s *IntegrationTestSuite) TearDownSuite() {
|
|||
|
||||
func (s *IntegrationTestSuite) TestGenTxCmd() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
dir, clean := testutil.NewTestCaseDir(s.T())
|
||||
defer clean()
|
||||
dir := s.T().TempDir()
|
||||
|
||||
cmd := cli.GenTxCmd(
|
||||
simapp.ModuleBasics,
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/server/mock"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
|
@ -54,9 +53,7 @@ func TestInitCmd(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
home, cleanup := testutil.NewTestCaseDir(t)
|
||||
defer cleanup()
|
||||
|
||||
home := t.TempDir()
|
||||
logger := log.NewNopLogger()
|
||||
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
|
||||
require.NoError(t, err)
|
||||
|
@ -89,17 +86,8 @@ func TestInitCmd(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
func setupClientHome(t *testing.T) func() {
|
||||
_, cleanup := testutil.NewTestCaseDir(t)
|
||||
return cleanup
|
||||
}
|
||||
|
||||
func TestEmptyState(t *testing.T) {
|
||||
t.Cleanup(setupClientHome(t))
|
||||
|
||||
home, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
|
||||
home := t.TempDir()
|
||||
logger := log.NewNopLogger()
|
||||
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
|
||||
require.NoError(t, err)
|
||||
|
@ -148,10 +136,7 @@ func TestEmptyState(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStartStandAlone(t *testing.T) {
|
||||
home, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
t.Cleanup(setupClientHome(t))
|
||||
|
||||
home := t.TempDir()
|
||||
logger := log.NewNopLogger()
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
||||
|
@ -180,10 +165,10 @@ func TestStartStandAlone(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInitNodeValidatorFiles(t *testing.T) {
|
||||
home, cleanup := testutil.NewTestCaseDir(t)
|
||||
home := t.TempDir()
|
||||
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
|
||||
t.Cleanup(cleanup)
|
||||
nodeID, valPubKey, err := genutil.InitializeNodeValidatorFiles(cfg)
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotEqual(t, "", nodeID)
|
||||
require.NotEqual(t, 0, len(valPubKey.Bytes()))
|
||||
|
|
|
@ -20,8 +20,7 @@ func TestGetMigrationCallback(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMigrateGenesis(t *testing.T) {
|
||||
home, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
home := t.TempDir()
|
||||
|
||||
cdc := makeCodec()
|
||||
|
||||
|
|
|
@ -6,16 +6,13 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestExportGenesisFileWithTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
|
||||
fname := filepath.Join(dir, "genesis.json")
|
||||
fname := filepath.Join(t.TempDir(), "genesis.json")
|
||||
|
||||
require.NoError(t, ExportGenesisFileWithTime(fname, "test", nil, json.RawMessage(`{"account_owner": "Bob"}`), time.Now()))
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ package cli_test
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
|
@ -47,9 +46,8 @@ func (s *IntegrationTestSuite) TearDownSuite() {
|
|||
func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
invalidPropFile, err := ioutil.TempFile(os.TempDir(), "invalid_text_proposal.*.json")
|
||||
invalidPropFile, err := ioutil.TempFile(s.T().TempDir(), "invalid_text_proposal.*.json")
|
||||
s.Require().NoError(err)
|
||||
defer os.Remove(invalidPropFile.Name())
|
||||
|
||||
invalidProp := `{
|
||||
"title": "",
|
||||
|
@ -61,9 +59,8 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
|
|||
_, err = invalidPropFile.WriteString(invalidProp)
|
||||
s.Require().NoError(err)
|
||||
|
||||
validPropFile, err := ioutil.TempFile(os.TempDir(), "valid_text_proposal.*.json")
|
||||
validPropFile, err := ioutil.TempFile(s.T().TempDir(), "valid_text_proposal.*.json")
|
||||
s.Require().NoError(err)
|
||||
defer os.Remove(validPropFile.Name())
|
||||
|
||||
validProp := fmt.Sprintf(`{
|
||||
"title": "Text Proposal",
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
@ -22,15 +21,11 @@ type KeeperTestSuite struct {
|
|||
|
||||
func (s *KeeperTestSuite) SetupTest() {
|
||||
app := simapp.Setup(false)
|
||||
|
||||
homeDir, err := ioutil.TempDir(os.TempDir(), "x_upgrade_keeper_test")
|
||||
s.Require().NoError(err)
|
||||
|
||||
// recreate keeper in order to use a custom home path
|
||||
app.UpgradeKeeper = keeper.NewKeeper(
|
||||
homeDir := filepath.Join(s.T().TempDir(), "x_upgrade_keeper_test")
|
||||
app.UpgradeKeeper = keeper.NewKeeper( // recreate keeper in order to use a custom home path
|
||||
make(map[int64]bool), app.GetKey(types.StoreKey), app.AppCodec(), homeDir,
|
||||
)
|
||||
|
||||
s.T().Log("home dir:", homeDir)
|
||||
s.homeDir = homeDir
|
||||
s.app = app
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
||||
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
|
@ -67,15 +66,15 @@ func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte
|
|||
// Test that LoadLatestVersion actually does.
|
||||
func TestSetLoader(t *testing.T) {
|
||||
// set a temporary home dir
|
||||
homeDir, cleanup := testutil.NewTestCaseDir(t)
|
||||
t.Cleanup(cleanup)
|
||||
|
||||
homeDir := t.TempDir()
|
||||
upgradeInfoFilePath := filepath.Join(homeDir, "upgrade-info.json")
|
||||
upgradeInfo := &store.UpgradeInfo{
|
||||
Name: "test", Height: 0,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(upgradeInfo)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = ioutil.WriteFile(upgradeInfoFilePath, data, 0644)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
Loading…
Reference in New Issue