-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add a bunch of tests, add DONTCOVER text tag - Also fix flaky test (closes: #3559). Don't test values returned by queries since there's no way to query a specific height via REST. * GetTempDir -> NewTestCaseDir
- Loading branch information
Showing
32 changed files
with
225 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package init | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
"encoding/json" | ||
"path/filepath" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package init | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package init | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package init | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/tests" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestExportGenesisFileWithTime(t *testing.T) { | ||
t.Parallel() | ||
dir, cleanup := tests.NewTestCaseDir(t) | ||
defer cleanup() | ||
|
||
fname := filepath.Join(dir, "genesis.json") | ||
require.NoError(t, ExportGenesisFileWithTime(fname, "test", nil, json.RawMessage(""), time.Now())) | ||
} | ||
|
||
func TestLoadGenesisDoc(t *testing.T) { | ||
t.Parallel() | ||
dir, cleanup := tests.NewTestCaseDir(t) | ||
defer cleanup() | ||
|
||
fname := filepath.Join(dir, "genesis.json") | ||
require.NoError(t, ExportGenesisFileWithTime(fname, "test", nil, json.RawMessage(""), time.Now())) | ||
|
||
_, err := LoadGenesisDoc(codec.Cdc, fname) | ||
require.NoError(t, err) | ||
|
||
// Non-existing file | ||
_, err = LoadGenesisDoc(codec.Cdc, "non-existing-file") | ||
require.Error(t, err) | ||
|
||
malformedFilename := filepath.Join(dir, "malformed") | ||
malformedFile, err := os.Create(malformedFilename) | ||
require.NoError(t, err) | ||
fmt.Fprint(malformedFile, "invalidjson") | ||
malformedFile.Close() | ||
// Non-existing file | ||
_, err = LoadGenesisDoc(codec.Cdc, malformedFilename) | ||
require.Error(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package server | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/cosmos-sdk/tests" | ||
) | ||
|
||
func Test_openDB(t *testing.T) { | ||
t.Parallel() | ||
dir, cleanup := tests.NewTestCaseDir(t) | ||
defer cleanup() | ||
_, err := openDB(dir) | ||
require.NoError(t, err) | ||
} | ||
|
||
func Test_openTraceWriter(t *testing.T) { | ||
t.Parallel() | ||
dir, cleanup := tests.NewTestCaseDir(t) | ||
defer cleanup() | ||
fname := filepath.Join(dir, "logfile") | ||
w, err := openTraceWriter(fname) | ||
require.NoError(t, err) | ||
require.NotNil(t, w) | ||
|
||
// test no-op | ||
w, err = openTraceWriter("") | ||
require.NoError(t, err) | ||
require.Nil(t, w) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.