Skip to content

Commit

Permalink
Merge branch 'master' into hariom/gno-test-patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov authored Sep 11, 2023
2 parents 369cc2c + 207d66d commit 791c1ca
Show file tree
Hide file tree
Showing 31 changed files with 393 additions and 178 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
runs-on: [self-hosted, Linux, X64, benchmark-v1]
steps:
- name: checkout
uses: actions/checkout@v3
with:
uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-go@v4
with:
go-version: "1.20"
with:
go-version: "1.21.x"
- name: "gobenchdata publish: ${{ inputs.publish }}"
run: go run go.bobheadxi.dev/gobenchdata@v1 action
env:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/db-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
tags:
- cleveldb
- memdb
Expand All @@ -44,6 +46,6 @@ jobs:
sudo dpkg -i *.deb
# test ./pkgs/db
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: test ./tm2/pkg/db
run: go test -tags ${{ matrix.tags }} ./tm2/pkg/db/...
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build main Docker image
env:
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,51 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: go install -v ./gnovm/cmd/gno
- run: go run ./gnovm/cmd/gno precompile --verbose ./examples
- run: go run ./gnovm/cmd/gno build --verbose ./examples
test:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
# unittests: TODO: matrix with contracts
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: go install -v ./gnovm/cmd/gno
- run: go run ./gnovm/cmd/gno test --verbose ./examples/...
lint:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
# unittests: TODO: matrix with contracts
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: go install -v ./gnovm/cmd/gno
# testing official directories, basically examples/ minus examples/.../x/.
- run: go run ./gnovm/cmd/gno lint --verbose ./examples/gno.land/p
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: "cd misc/devdeps && make install"
- run: "cd misc/gendocs && make gen"
- run: "find docs/ -type f -ls"
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/gnoland.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,24 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
goarch: [ "amd64" ]
goos: [ "linux" ]
program:
- gnoland
- gnokey
- gnoweb
- gnofaucet
- gnotxsync
- gnotxsync
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: go install
working-directory: gno.land
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go install ./cmd/${{ matrix.program }}
Expand All @@ -45,7 +47,9 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
args:
- _test.gnoland
- _test.gnokey
Expand All @@ -57,7 +61,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: test
working-directory: gno.land
run: |
Expand All @@ -80,7 +84,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# TODO: setup docker caching
- run: make test.docker
- run: docker logs int_gnoland || true
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/gnovm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
fail-fast: false
matrix:
go-version: # two latest versions
- "1.19.x"
- "1.20.x"
- "1.21.x"
goenv: # TODO: replace with pairs, so it's easier to read in the GH interface.
- "GOARCH=amd64 GOOS=linux"
- "GOARCH=wasm GOOS=js"
Expand All @@ -37,7 +37,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: go install
working-directory: gnovm
run: ${{ matrix.goenv }} go install ./cmd/${{ matrix.program }}
Expand All @@ -46,7 +46,9 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
args:
- _test.cmd
- _test.pkg
Expand All @@ -63,7 +65,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: test
working-directory: gnovm
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
go-version: 1.21.x

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
# sync with misc/devdeps/go.mod
version: v1.53
version: v1.54
args:
--config=./.github/golangci.yml
fmt:
Expand All @@ -40,7 +40,7 @@ jobs:
run: sudo apt-get install -y make

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

# prefill dependencies so that mod messages don't show up in make output
- name: Fetch dependencies
Expand All @@ -67,7 +67,7 @@ jobs:
go-version: 1.20.x

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check go.mods
run: |
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/tm2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
goarch: [ "amd64" ]
goos: [ "linux" ]
program: [ "./pkg/amino/cmd/aminoscan", "./pkg/amino/cmd/goscan", "./pkg/autofile/cmd", "./pkg/iavl/cmd/iaviewer" ]
Expand All @@ -29,7 +31,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: go install
working-directory: tm2
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go install ${{ matrix.program }}
Expand All @@ -38,7 +40,9 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ "1.19.x", "1.20.x" ]
go-version:
- "1.20.x"
- "1.21.x"
args:
- _test.flappy
- _test.pkg.amino
Expand All @@ -50,7 +54,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: test
working-directory: tm2
run: |
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The gno repository is primarily based on Golang (Go), and Gnolang (Gno).

The primary tech stack for working on the repository:

- Go (version 1.19+)
- Go (version 1.20+)
- make (for using Makefile configurations)
- Docker (for using the official Docker setup files)

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# build
FROM golang:1.20 AS build
FROM golang:1.21 AS build
RUN mkdir -p /opt/gno/src /opt/build
WORKDIR /opt/build
ADD go.mod go.sum ./
Expand Down
1 change: 1 addition & 0 deletions gno.land/cmd/gnoland/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func makeGenesisDoc(
for _, pkg := range nonDraftPkgs {
// open files in directory as MemPackage.
memPkg := gno.ReadMemPackage(pkg.Dir, pkg.Name)

var tx std.Tx
tx.Msgs = []std.Msg{
vmm.MsgAddPackage{
Expand Down
5 changes: 5 additions & 0 deletions gno.land/pkg/sdk/vm/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func (vm *VMKeeper) initBuiltinPackagesAndTypes(store gno.Store) {
return nil, nil
}
memPkg := gno.ReadMemPackage(stdlibPath, pkgPath)
if memPkg.IsEmpty() {
// no gno files are present, skip this package
return nil, nil
}

m2 := gno.NewMachineWithOptions(gno.MachineOptions{
PkgPath: "gno.land/r/stdlibs/" + pkgPath,
// PkgPath: pkgPath,
Expand Down
2 changes: 1 addition & 1 deletion gnovm/cmd/gno/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error {

// go.mod
modPath := filepath.Join(tempdirRoot, "go.mod")
err = makeTestGoMod(modPath, gno.ImportPrefix, "1.19")
err = makeTestGoMod(modPath, gno.ImportPrefix, "1.20")
if err != nil {
return fmt.Errorf("write .mod file: %w", err)
}
Expand Down
9 changes: 7 additions & 2 deletions gnovm/pkg/gnolang/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,13 @@ func ReadMemPackage(dir string, pkgPath string) *std.MemPackage {
Body: string(bz),
})
}
validatePkgName(string(pkgName))
memPkg.Name = string(pkgName)

// If no .gno files are present, package simply does not exist.
if !memPkg.IsEmpty() {
validatePkgName(string(pkgName))
memPkg.Name = string(pkgName)
}

return memPkg
}

Expand Down
40 changes: 40 additions & 0 deletions gnovm/pkg/gnolang/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package gnolang

import (
"math/big"
"reflect"
"testing"

"github.com/jaekwon/testify/require"

"github.com/gnolang/gno/tm2/pkg/amino"
)

// Tries to reproduce the bug #1036 on all registered types
func TestAminoJSONRegisteredTypes(t *testing.T) {
for _, typ := range Package.Types {
// Instantiate registered type
x := reflect.New(typ.Type).Interface()

// Call MarshalAmino directly on 'x'
_, err := amino.MarshalJSON(x)
require.NoError(t, err, "marshal type %s", typ.Type.Name())

// Call MarshalAmino on a struct that embeds 'x' in a field of type any
xx := struct {
X any
}{X: x}
_, err = amino.MarshalJSON(xx)
require.NoError(t, err, "marshal type %s from struct", typ.Type.Name())
}

// Check unmarshaling (can't reuse package.Types because some internal values
// must be filled properly
bi := BigintValue{V: big.NewInt(1)}
bz := amino.MustMarshalJSON(bi)
amino.MustUnmarshalJSON(bz, &bi)
// Check unmarshaling with an embedding struct
x := struct{ X any }{X: bi}
bz = amino.MustMarshalJSON(x)
amino.MustUnmarshalJSON(bz, &x)
}
Loading

0 comments on commit 791c1ca

Please sign in to comment.