Skip to content

Commit

Permalink
snapshots: document use of ioutil.TempDir() (#8508)
Browse files Browse the repository at this point in the history
Document with inline comments the changes introduced
in cosmos/cosmos-sdk#8475.

Run make format.
  • Loading branch information
Alessio Treglia authored and daeMOn63 committed Feb 28, 2022
1 parent e75a027 commit 7701bef
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 26 deletions.
3 changes: 2 additions & 1 deletion server/grpc/grpc_web.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package grpc
import (
"net/http"

"github.com/cosmos/cosmos-sdk/server/config"
"github.com/improbable-eng/grpc-web/go/grpcweb"
"google.golang.org/grpc"

"github.com/cosmos/cosmos-sdk/server/config"
)

// StartGRPCWeb starts a gRPC-Web server on the given address.
Expand Down
3 changes: 3 additions & 0 deletions snapshots/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (m *mockSnapshotter) Snapshot(height uint64, format uint32) (<-chan io.Read
// setupBusyManager creates a manager with an empty store that is busy creating a snapshot at height 1.
// The snapshot will complete when the returned closer is called.
func setupBusyManager(t *testing.T) *snapshots.Manager {
// ioutil.TempDir() is used instead of testing.T.TempDir()
// see https://github.com/cosmos/cosmos-sdk/pull/8475 for
// this change's rationale.
tempdir, err := ioutil.TempDir("", "")
require.NoError(t, err)
t.Cleanup(func() { _ = os.RemoveAll(tempdir) })
Expand Down
3 changes: 3 additions & 0 deletions snapshots/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
)

func setupStore(t *testing.T) *snapshots.Store {
// ioutil.TempDir() is used instead of testing.T.TempDir()
// see https://github.com/cosmos/cosmos-sdk/pull/8475 for
// this change's rationale.
tempdir, err := ioutil.TempDir("", "")
require.NoError(t, err)
t.Cleanup(func() { _ = os.RemoveAll(tempdir) })
Expand Down
3 changes: 2 additions & 1 deletion x/authz/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (

"github.com/stretchr/testify/suite"

tmcli "github.com/tendermint/tendermint/libs/cli"

"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
tmcli "github.com/tendermint/tendermint/libs/cli"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/testutil"
Expand Down
5 changes: 2 additions & 3 deletions x/authz/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import (
"testing"
"time"

"github.com/cosmos/cosmos-sdk/baseapp"
proto "github.com/gogo/protobuf/proto"

"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/authz/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/stretchr/testify/suite"
)

type TestSuite struct {
Expand Down
7 changes: 4 additions & 3 deletions x/feegrant/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"testing"
"time"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/stretchr/testify/suite"
"github.com/tendermint/tendermint/crypto"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
Expand Down
7 changes: 4 additions & 3 deletions x/feegrant/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
"fmt"
"testing"

"github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/suite"
tmcli "github.com/tendermint/tendermint/libs/cli"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand All @@ -16,9 +20,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/suite"
tmcli "github.com/tendermint/tendermint/libs/cli"
)

type IntegrationTestSuite struct {
Expand Down
3 changes: 2 additions & 1 deletion x/feegrant/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/spf13/cobra"
)

// GetQueryCmd returns the cli query commands for this module
Expand Down
3 changes: 2 additions & 1 deletion x/feegrant/client/rest/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand All @@ -14,7 +16,6 @@ import (
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
"github.com/cosmos/cosmos-sdk/x/feegrant/client/cli"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/stretchr/testify/suite"
)

type IntegrationTestSuite struct {
Expand Down
5 changes: 3 additions & 2 deletions x/feegrant/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package feegrant_test
import (
"testing"

"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
feegrant "github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)

type GenesisTestSuite struct {
Expand Down
3 changes: 2 additions & 1 deletion x/feegrant/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/x/feegrant/simulation"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/stretchr/testify/require"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion x/feegrant/simulation/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"math/rand"
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/feegrant/simulation"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/stretchr/testify/require"
)

func TestRandomizedGenState(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions x/feegrant/types/basic_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"testing"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
)

func TestBasicFeeValidAllow(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion x/feegrant/types/expiration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"testing"
"time"

"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/feegrant/types"
)

func TestExpiresAt(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion x/feegrant/types/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package types
import (
"time"

proto "github.com/gogo/protobuf/proto"

"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
proto "github.com/gogo/protobuf/proto"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions x/feegrant/types/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package types_test
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestGrant(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion x/feegrant/types/msgs.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package types

import (
"github.com/gogo/protobuf/proto"

"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/gogo/protobuf/proto"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions x/feegrant/types/periodic_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"testing"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
)

func TestPeriodicFeeValidAllow(t *testing.T) {
Expand Down

0 comments on commit 7701bef

Please sign in to comment.