Skip to content

Commit

Permalink
Add package helloworld for docker test
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Jun 21, 2023
1 parent 9ec47cb commit 1dd9130
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
5 changes: 5 additions & 0 deletions gnovm/tests/integ/helloworld/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/r/demo/helloworld

require (
"gno.land/r/demo/helloworld/world" v0.0.0-latest
)
7 changes: 7 additions & 0 deletions gnovm/tests/integ/helloworld/hello.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package helloworld

import "gno.land/r/demo/helloworld/world"

func SayHelloWorld() string {
return "Hello " + world.World()
}
4 changes: 4 additions & 0 deletions gnovm/tests/integ/helloworld/world/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module gno.land/r/demo/helloworld/world

// TODO: this file should not exist.
// This is a temporary workaround. Until https://github.com/gnolang/gno/issues/852
5 changes: 5 additions & 0 deletions gnovm/tests/integ/helloworld/world/world.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package world

func World() string {
return "world"
}
25 changes: 18 additions & 7 deletions misc/docker-integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,38 @@ func runSuite(t *testing.T, tempdir string) {
require.True(t, acc.Coins.IsAllGTE(minCoins),
"test1 account coins expected at least %s, got %s", minCoins, acc.Coins)

// add gno.land/r/demo/tests package as tests_copy
// add gno.land/r/demo/helloworld/world
// TODO: it should be added automatically by its parent package `gno.land/r/demo/helloworld`.
dockerExec(t,
`echo 'pass' | gnokey maketx addpkg -insecure-password-stdin \
-gas-fee 1000000ugnot -gas-wanted 2000000 \
-broadcast -chainid dev \
-pkgdir /opt/gno/src/examples/gno.land/r/demo/tests/ \
-pkgpath gno.land/r/demo/tests_copy \
-pkgdir /opt/gno/src/gnovm/tests/integ/helloworld/world/ \
-deposit 100000000ugnot \
test1`,
)
// assert gno.land/r/demo/tests_copy has been added

// add gno.land/r/demo/helloworld
dockerExec(t,
`echo 'pass' | gnokey maketx addpkg -insecure-password-stdin \
-gas-fee 1000000ugnot -gas-wanted 2000000 \
-broadcast -chainid dev \
-pkgdir /opt/gno/src/gnovm/tests/integ/helloworld/ \
-deposit 100000000ugnot \
test1`,
)

// assert gno.land/r/demo/helloworld has been added
var qfuncs vm.FunctionSignatures
dockerExec_gnokeyQuery(t, `-data "gno.land/r/demo/tests_copy" vm/qfuncs`, &qfuncs)
require.True(t, len(qfuncs) > 0, "gno.land/r/demo/tests_copy not added")
dockerExec_gnokeyQuery(t, `-data "gno.land/r/demo/helloworld" vm/qfuncs`, &qfuncs)
require.True(t, len(qfuncs) > 0, "gno.land/r/demo/helloworld not added")

// broadcast a package TX
dockerExec(t,
`echo 'pass' | gnokey maketx call -insecure-password-stdin \
-gas-fee 1000000ugnot -gas-wanted 2000000 \
-broadcast -chainid dev \
-pkgpath "gno.land/r/demo/tests_copy" -func "InitTestNodes" \
-pkgpath "gno.land/r/demo/helloworld" -func "SayHelloWorld" \
test1`,
)
}
Expand Down

0 comments on commit 1dd9130

Please sign in to comment.