-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
187 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: integration | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "testdata/**" | ||
- "go.sum" | ||
push: | ||
branches: | ||
- master | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 'stable' | ||
- run: go test -v -run='TestIntegration/.*' . |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,91 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
integration "github.com/gnolang/gno/gno.land/pkg/integration" | ||
"github.com/jaekwon/testify/require" | ||
"github.com/rogpeppe/go-internal/testscript" | ||
) | ||
|
||
var balances = []string{ | ||
"g1plqds6kxnfaqcpky0gtt6fpntfhjgcfx8r73a0=100000000000000000ugnot", | ||
"g1sgy2zhqg2wecuz3qt8th63d539afagjnhs4zj3=100000000000000000ugnot", | ||
"g1unk9a8yt595p4yxpfpejewvf9lx6yrvd2ylgtm=100000000000000000ugnot", | ||
"g17x4qwuhmc6fyp6ut2qtscc9265xe5jnj83s8c6=100000000000000000ugnot", | ||
"g1agq8t3289xxmm63z55axykmmve2pz87yqgyn5n=100000000000000000ugnot", | ||
"g153xesqpfvr5y35l0aykew3796kz452zttp0xt2=100000000000000000ugnot", | ||
"g18epncd7avkhmdlf930e4t2p7c7j9qdv3yda93f=100000000000000000ugnot", | ||
"g1elguymy8sjjy246u09qddtx587934k6uzf8mc4=100000000000000000ugnot", | ||
"g1sl70rzvu49mp0lstxaptmvle8h2a8rx8pu56uk=100000000000000000ugnot", | ||
"g18dgugclk93v65qtxxus82eg30af59fgk246nqy=100000000000000000ugnot", | ||
} | ||
|
||
func generateGenesisFile(genesispath, target string) error { | ||
genesis, err := os.ReadFile(genesispath) | ||
if err != nil { | ||
return fmt.Errorf("Error reading genesis file: %w", err) | ||
} | ||
|
||
outputFile, err := os.Create(target) | ||
if err != nil { | ||
return fmt.Errorf("Error creating output file: %w", err) | ||
} | ||
defer outputFile.Close() | ||
|
||
writer := bufio.NewWriter(outputFile) | ||
writer.Write(genesis) | ||
writer.WriteRune('\n') | ||
writer.WriteRune('\n') | ||
|
||
for _, line := range balances { | ||
writer.Write([]byte(line)) | ||
writer.WriteRune('\n') | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func TestIntegration(t *testing.T) { | ||
ts := integration.SetupGnolandTestScript(t, "testdata") | ||
|
||
goModPath, err := exec.Command("go", "env", "GOMOD").CombinedOutput() | ||
require.NoError(t, err) | ||
|
||
oldsetup := ts.Setup | ||
ts.Setup = func(e *testscript.Env) error { | ||
oldsetup(e) | ||
e.Setenv("ROOTDIR", filepath.Dir(string(goModPath))) | ||
|
||
rootdir := e.Getenv("GNOROOT") | ||
tmpdir := e.Getenv("TMPDIR") | ||
|
||
outpout_genesis := filepath.Join(tmpdir, "genesis_balances.txt") | ||
input_genesis := filepath.Join(rootdir, "gno.land/genesis/genesis_balances.txt") | ||
if err := generateGenesisFile(input_genesis, outpout_genesis); err != nil { | ||
return fmt.Errorf("unable to generate genesis file: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
ts.Cmds["sleep"] = func(ts *testscript.TestScript, neg bool, args []string) { | ||
d := time.Second | ||
if len(args) > 0 { | ||
var err error | ||
if d, err = time.ParseDuration(args[0]); err != nil { | ||
ts.Fatalf("uanble to parse duration %q: %s", args[1], err) | ||
} | ||
} | ||
|
||
time.Sleep(d) | ||
} | ||
|
||
testscript.Run(t, ts) | ||
} |
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,26 @@ | ||
# test for add package | ||
|
||
## start a new node | ||
gnoland start | ||
|
||
## add bar.gno package located in $WORK directory as gno.land/r/foobar/bar | ||
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/foobar/bar -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
|
||
## execute Render | ||
gnokey maketx call -pkgpath gno.land/r/foobar/bar -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -args '' -broadcast -chainid=tendermint_test test1 | ||
|
||
## compare render | ||
cmp stdout stdout.golden | ||
|
||
-- bar.gno -- | ||
package bar | ||
|
||
func Render(path string) string { | ||
return "hello from foo" | ||
} | ||
|
||
-- stdout.golden -- | ||
("hello from foo" string) | ||
OK! | ||
GAS WANTED: 2000000 | ||
GAS USED: 69163 |
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,5 @@ | ||
gnoland start -genesis-balances-file=${TMPDIR}/genesis_balances.txt -genesis-max-vm-cycles 100000000 | ||
|
||
sleep 500ms | ||
|
||
gnokey maketx addpkg -pkgdir ${ROOTDIR}/realm -pkgpath gno.land/r/demo/chess -gas-wanted 20000000 -gas-fee 1ugnot -chainid=tendermint_test -broadcast test1 |
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,22 @@ | ||
# test basic gnoland integrations commands | ||
|
||
## no arguments should fail | ||
! gnoland | ||
|
||
## should be able to start | ||
gnoland start | ||
|
||
## should not be able to start a node twice | ||
! gnoland start | ||
|
||
## test1 account should be available on default | ||
gnokey query auth/accounts/${USER_ADDR_test1} | ||
|
||
## invalid gnokey command should raise an error | ||
! gnokey query foo/bar | ||
|
||
## should be able to stop default | ||
gnoland stop | ||
|
||
## should not be able to stop a node twice | ||
! gnoland stop |