-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple integration tests for {base,demo}coind
Closes: #1632
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,22 @@ jobs: | |
export PATH="$GOBIN:$PATH" | ||
make test_cli | ||
test_examples: | ||
<<: *defaults | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
alessio
via email
Author
Contributor
|
||
parallelism: 1 | ||
steps: | ||
- attach_workspace: | ||
at: /tmp/workspace | ||
- restore_cache: | ||
key: v1-pkg-cache | ||
- restore_cache: | ||
key: v1-tree-{{ .Environment.CIRCLE_SHA1 }} | ||
- run: | ||
name: Test examples | ||
command: | | ||
export PATH="$GOBIN:$PATH" | ||
make test_examples | ||
test_sim_modules: | ||
<<: *defaults | ||
parallelism: 1 | ||
|
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,52 @@ | ||
package clitest | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/server" | ||
"github.com/cosmos/cosmos-sdk/tests" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
var ( | ||
basecoindHome = "" | ||
) | ||
|
||
func init() { | ||
basecoindHome = getTestingHomeDir() | ||
} | ||
|
||
func TestInitStartSequence(t *testing.T) { | ||
os.RemoveAll(basecoindHome) | ||
servAddr, port, err := server.FreeTCPAddr() | ||
require.NoError(t, err) | ||
executeInit(t) | ||
executeStart(t, servAddr, port) | ||
} | ||
|
||
func executeInit(t *testing.T) { | ||
var ( | ||
chainID string | ||
initRes map[string]json.RawMessage | ||
) | ||
out := tests.ExecuteT(t, fmt.Sprintf("basecoind --home=%s init", basecoindHome), "") | ||
err := json.Unmarshal([]byte(out), &initRes) | ||
require.NoError(t, err) | ||
err = json.Unmarshal(initRes["chain_id"], &chainID) | ||
require.NoError(t, err) | ||
} | ||
|
||
func executeStart(t *testing.T, servAddr, port string) { | ||
proc := tests.GoExecuteTWithStdout(t, fmt.Sprintf("basecoind start --home=%s --rpc.laddr=%v", basecoindHome, servAddr)) | ||
defer proc.Stop(false) | ||
tests.WaitForTMStart(port) | ||
} | ||
|
||
func getTestingHomeDir() string { | ||
tmpDir := os.TempDir() | ||
basecoindHome := fmt.Sprintf("%s%s.test_basecoind", tmpDir, string(os.PathSeparator)) | ||
return basecoindHome | ||
} |
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,52 @@ | ||
package clitest | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/server" | ||
"github.com/cosmos/cosmos-sdk/tests" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
var ( | ||
democoindHome = "" | ||
) | ||
|
||
func init() { | ||
democoindHome = getTestingHomeDir() | ||
} | ||
|
||
func TestInitStartSequence(t *testing.T) { | ||
os.RemoveAll(democoindHome) | ||
servAddr, port, err := server.FreeTCPAddr() | ||
require.NoError(t, err) | ||
executeInit(t) | ||
executeStart(t, servAddr, port) | ||
} | ||
|
||
func executeInit(t *testing.T) { | ||
var ( | ||
chainID string | ||
initRes map[string]json.RawMessage | ||
) | ||
out := tests.ExecuteT(t, fmt.Sprintf("democoind --home=%s init", democoindHome), "") | ||
err := json.Unmarshal([]byte(out), &initRes) | ||
require.NoError(t, err) | ||
err = json.Unmarshal(initRes["chain_id"], &chainID) | ||
require.NoError(t, err) | ||
} | ||
|
||
func executeStart(t *testing.T, servAddr, port string) { | ||
proc := tests.GoExecuteTWithStdout(t, fmt.Sprintf("democoind start --home=%s --rpc.laddr=%v", democoindHome, servAddr)) | ||
defer proc.Stop(false) | ||
tests.WaitForTMStart(port) | ||
} | ||
|
||
func getTestingHomeDir() string { | ||
tmpDir := os.TempDir() | ||
democoindHome := fmt.Sprintf("%s%s.test_democoind", tmpDir, string(os.PathSeparator)) | ||
return democoindHome | ||
} |
Can we rename test cli to integration tests, and merge the two? (Cli tests don't bottleneck ci, so making a new test would just increase our container usage)
Alternatively this could go in test cover.