-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve gno.land/gnoclient integration tests speed
Signed-off-by: gfanton <[email protected]>
- Loading branch information
Showing
7 changed files
with
227 additions
and
147 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package integration | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/gnolang/gno/gnovm/pkg/gnoenv" | ||
"github.com/gnolang/gno/tm2/pkg/bft/rpc/client" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestGnolandIntegration tests the forking of a Gnoland node. | ||
// XXX: For now keep this test sequential (no parallel execution is allowed). | ||
func TestGnolandIntegration(t *testing.T) { | ||
// Set a timeout of 20 seconds for the test context. | ||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) | ||
defer cancel() | ||
|
||
tmpdir := t.TempDir() // Create a temporary directory for the test. | ||
|
||
gnoRootDir := gnoenv.RootDir() // Get the root directory for Gnolang. | ||
|
||
// Define paths for the build directory and the gnoland binary. | ||
gnolandBuildDir := filepath.Join(tmpdir, "build") | ||
gnolandBin := filepath.Join(gnolandBuildDir, "gnoland") | ||
|
||
// Compile the gnoland binary. | ||
err := buildGnoland(t, gnoRootDir, gnolandBin) | ||
require.NoError(t, err) | ||
|
||
// Prepare a minimal node configuration for testing. | ||
cfg := TestingMinimalNodeConfig(gnoRootDir) | ||
remoteAddr, cmd, err := ExecuteNode(ctx, gnolandBin, &Config{ | ||
Verbose: true, | ||
RootDir: gnoRootDir, | ||
TMConfig: cfg.TMConfig, | ||
Genesis: NewMarshalableGenesisDoc(cfg.Genesis), | ||
}, os.Stderr) | ||
require.NoError(t, err) | ||
|
||
defer func() { | ||
// Ensure the process is killed after the test to clean up resources. | ||
if cmd.Process != nil { | ||
cmd.Process.Kill() | ||
} | ||
}() | ||
|
||
// Create a new HTTP client to interact with the integration node. | ||
cli, err := client.NewHTTPClient(remoteAddr) | ||
require.NoError(t, err) | ||
|
||
// Retreive node info. | ||
info, err := cli.ABCIInfo() | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, info.Response.Data) | ||
} |
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
Oops, something went wrong.