cmd/tendermint/commands: replace $HOME/.some/test/dir with t.TempDir (#6623)

* cmd/tendermint/commands: replace $HOME/.some/test/dir with t.TempDir

* update changelog

Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
Tanya Bouman
2021-06-28 10:38:15 -04:00
committed by GitHub
parent 7eef4d7ac2
commit 09ec247646
2 changed files with 6 additions and 6 deletions

View File

@@ -131,6 +131,7 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi
- [statesync] \#6587 Increase chunk priority and re-request chunks that don't arrive (@cmwaters)
- [state/privval] \#6578 No GetPubKey retry beyond the proposal/voting window (@JayT106)
- [rpc] \#6615 Add TotalGasUsed to block_results response (@crypto-facs)
- [cmd/tendermint/commands] \#6623 replace `$HOME/.some/test/dir` with `t.TempDir` (@tanyabouman)
### BUG FIXES

View File

@@ -18,10 +18,6 @@ import (
tmos "github.com/tendermint/tendermint/libs/os"
)
var (
defaultRoot = os.ExpandEnv("$HOME/.some/test/dir")
)
// clearConfig clears env vars, the given root dir, and resets viper.
func clearConfig(dir string) {
if err := os.Unsetenv("TMHOME"); err != nil {
@@ -52,10 +48,10 @@ func testRootCmd() *cobra.Command {
}
func testSetup(rootDir string, args []string, env map[string]string) error {
clearConfig(defaultRoot)
clearConfig(rootDir)
rootCmd := testRootCmd()
cmd := cli.PrepareBaseCmd(rootCmd, "TM", defaultRoot)
cmd := cli.PrepareBaseCmd(rootCmd, "TM", rootDir)
// run with the args and env
args = append([]string{rootCmd.Use}, args...)
@@ -63,6 +59,7 @@ func testSetup(rootDir string, args []string, env map[string]string) error {
}
func TestRootHome(t *testing.T) {
defaultRoot := t.TempDir()
newRoot := filepath.Join(defaultRoot, "something-else")
cases := []struct {
args []string
@@ -105,6 +102,7 @@ func TestRootFlagsEnv(t *testing.T) {
{nil, map[string]string{"TM_LOG_LEVEL": "debug"}, "debug"}, // right env
}
defaultRoot := t.TempDir()
for i, tc := range cases {
idxString := strconv.Itoa(i)
@@ -135,6 +133,7 @@ func TestRootConfig(t *testing.T) {
}
for i, tc := range cases {
defaultRoot := t.TempDir()
idxString := strconv.Itoa(i)
clearConfig(defaultRoot)