Skip to content

Commit

Permalink
Merge branch 'master' into p/merkle
Browse files Browse the repository at this point in the history
  • Loading branch information
thehowl authored Mar 28, 2023
2 parents 993ad21 + 808a694 commit c24273b
Show file tree
Hide file tree
Showing 61 changed files with 583 additions and 225 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/db-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- boltdb
steps:
# golang
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
Expand Down
35 changes: 33 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19.x

Expand All @@ -24,4 +24,35 @@ jobs:
with:
version: v1.51
args:
--config=./.golangci.yaml
--config=./.golangci.yaml
fmt:
name: Format checker
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.19.x

- name: Install make
run: sudo apt-get install -y make

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

# prefill dependencies so that mod messages don't show up in make output
- name: Fetch dependencies
run: go mod download -modfile ./misc/devdeps/go.mod -x

# inspired by:
# https://github.com/Jerome1337/gofmt-action/blob/d5eabd189843f1d568286a54578159978b7c0fb1/entrypoint.sh
- name: Check gofumpt
run: |
output="$(GOFMT_FLAGS=-l make -s fmt)"
if [ ! -z "$output" ]; then
echo "The following files are not properly formatted; run 'make fmt' to format them."
echo "$output"
exit 1
else
echo 'Succeeded.'
fi
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
Expand Down
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ examples.build: install_gnodev examples.precompile
########################################
# Formatting, linting.

rundep=go run -modfile ./misc/devdeps/go.mod

.PHONY: fmt
GOFMT_FLAGS ?= -w
fmt_cmd=$(rundep) mvdan.cc/gofumpt $(GOFMT_FLAGS)
fmt:
go run -modfile ./misc/devdeps/go.mod mvdan.cc/gofumpt -w .
go run -modfile ./misc/devdeps/go.mod mvdan.cc/gofumpt -w `find stdlibs examples -name "*.gno"`
$(fmt_cmd) .
$(fmt_cmd) `find stdlibs examples stdlibs -name "*.gno"`

.PHONY: lint
lint:
Expand All @@ -105,7 +109,7 @@ test.docker-integration:

test.flappy:
# flappy tests should work "sometimes" (at least once)
TEST_STABILITY=flappy go run -modfile ./misc/devdeps/go.mod moul.io/testman test -test.v -timeout=20m -retry=10 -run ^TestFlappy \
TEST_STABILITY=flappy $(rundep) moul.io/testman test -test.v -timeout=20m -retry=10 -run ^TestFlappy \
./pkgs/bft/consensus ./pkgs/bft/blockchain ./pkgs/bft/mempool ./pkgs/p2p ./pkgs/bft/privval

test.go: test.go1 test.go2 test.go3 test.go4
Expand Down Expand Up @@ -160,13 +164,14 @@ test.examples.sync:
go run ./cmd/gnodev test --verbose --update-golden-tests ./examples

# Code gen
stringer_cmd=$(rundep) golang.org/x/tools/cmd/stringer
stringer:
stringer -type=Kind
stringer -type=Op
stringer -type=TransCtrl
stringer -type=TransField
stringer -type=VPType
stringer -type=Word
$(stringer_cmd) -type=Kind ./pkgs/gnolang
$(stringer_cmd) -type=Op ./pkgs/gnolang
$(stringer_cmd) -type=TransCtrl ./pkgs/gnolang
$(stringer_cmd) -type=TransField ./pkgs/gnolang
$(stringer_cmd) -type=VPType ./pkgs/gnolang
$(stringer_cmd) -type=Word ./pkgs/gnolang

genproto:
rm -rf proto/*
Expand Down
2 changes: 1 addition & 1 deletion cmd/gnodev/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func execModDownload(cfg *modDownloadCfg, args []string, io *commands.IO) error
}

// fetch dependencies
if err := gnoMod.FetchDeps(cfg.remote); err != nil {
if err := gnoMod.FetchDeps(gnomod.GetGnoModPath(), cfg.remote); err != nil {
return fmt.Errorf("fetch: %w", err)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/gnodev/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ func gnoTestPkg(

if !verbose {
// TODO: speedup by ignoring if filter is file/*?
stdout = commands.WriteNopCloser(nil)
mockOut := bytes.NewBufferString("")
stdout = commands.WriteNopCloser(mockOut)
}

// testing with *_test.gno
Expand Down
90 changes: 60 additions & 30 deletions cmd/gnodev/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,112 +11,142 @@ func TestTest(t *testing.T) {
{
args: []string{"test", "../../examples/gno.land/p/demo/rand"},
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/rand \t",
}, {
},
{
args: []string{"test", "../../tests/integ/no-such-dir"},
errShouldContain: "no such file or directory",
}, {
},
{
args: []string{"test", "../../tests/integ/empty-dir"},
}, {
},
{
// FIXME: should have an output
args: []string{"test", "../../tests/integ/minimalist-gno1"},
stderrShouldBe: "? ./../../tests/integ/minimalist-gno1 \t[no test files]\n",
}, {
},
{
args: []string{"test", "../../tests/integ/minimalist-gno2"},
stderrShouldContain: "ok ",
}, {
},
{
args: []string{"test", "../../tests/integ/minimalist-gno3"},
stderrShouldContain: "ok ",
}, {
},
{
args: []string{"test", "--verbose", "../../tests/integ/valid1"},
stderrShouldContain: "ok ",
}, {
},
{
args: []string{"test", "../../tests/integ/valid2"},
stderrShouldContain: "ok ",
}, {
},
{
args: []string{"test", "--verbose", "../../tests/integ/valid2"},
stderrShouldContain: "ok ",
}, {
},
{
args: []string{"test", "../../tests/integ/empty-gno1"},
stderrShouldBe: "? ./../../tests/integ/empty-gno1 \t[no test files]\n",
}, {
},
{
args: []string{"test", "--precompile", "../../tests/integ/empty-gno1"},
errShouldBe: "FAIL: 1 build errors, 0 test errors",
stderrShouldContain: "../../tests/integ/empty-gno1/empty.gno: parse: tmp.gno:1:1: expected 'package', found 'EOF'",
}, {
},
{
args: []string{"test", "../../tests/integ/empty-gno2"},
recoverShouldBe: "empty.gno:1:1: expected 'package', found 'EOF'",
}, {
},
{
// FIXME: better error handling + rename dontcare.gno with actual test file
args: []string{"test", "--precompile", "../../tests/integ/empty-gno2"},
errShouldContain: "FAIL: 1 build errors, 0 test errors",
stderrShouldContain: "../../tests/integ/empty-gno2/empty.gno: parse: tmp.gno:1:1: expected 'package', found 'EOF'",
}, {
},
{
args: []string{"test", "../../tests/integ/empty-gno3"},
recoverShouldBe: "../../tests/integ/empty-gno3/empty_filetest.gno:1:1: expected 'package', found 'EOF'",
}, {
},
{
// FIXME: better error handling
args: []string{"test", "--precompile", "../../tests/integ/empty-gno3"},
errShouldContain: "FAIL: 1 build errors, 0 test errors",
stderrShouldContain: "../../tests/integ/empty-gno3/empty.gno: parse: tmp.gno:1:1: expected 'package', found 'EOF'",
}, {
},
{
args: []string{"test", "--verbose", "../../tests/integ/failing1"},
errShouldBe: "FAIL: 0 build errors, 1 test errors",
stderrShouldContain: "FAIL: TestAlwaysFailing",
}, {
},
{
args: []string{"test", "--verbose", "--precompile", "../../tests/integ/failing1"},
errShouldBe: "FAIL: 0 build errors, 1 test errors",
stderrShouldContain: "FAIL: TestAlwaysFailing",
}, {
},
{
args: []string{"test", "--verbose", "../../tests/integ/failing2"},
recoverShouldBe: "fail on ../../tests/integ/failing2/failing_filetest.gno: got unexpected error: beep boop",
stderrShouldContain: "== RUN file/failing_filetest.gno",
}, {
},
{
args: []string{"test", "--verbose", "--precompile", "../../tests/integ/failing2"},
stderrShouldBe: "=== PREC ./../../tests/integ/failing2\n=== BUILD ./../../tests/integ/failing2\n=== RUN file/failing_filetest.gno\n",
recoverShouldBe: "fail on ../../tests/integ/failing2/failing_filetest.gno: got unexpected error: beep boop",
}, {
},
{
args: []string{"test", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", ".*", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", "NoExists", "../../examples/gno.land/p/demo/ufmt"},
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", ".*/hello", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", ".*/hi", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", ".*/NoExists", "../../examples/gno.land/p/demo/ufmt"},
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", ".*/hello/NoExists", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", "Sprintf/", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", "Sprintf/.*", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--run", "Sprintf/hello", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
}, {
},
{
args: []string{"test", "--verbose", "--timeout", "1000000s", "../../examples/gno.land/p/demo/ufmt"},
stdoutShouldContain: "RUN TestSprintf",
stderrShouldContain: "ok ./../../examples/gno.land/p/demo/ufmt",
Expand Down
4 changes: 2 additions & 2 deletions cmd/gnodev/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func WriteDirFile(pathWithName string, data []byte) error {
// absolute to ensure consistent behavior.
func copyDir(src, dst string) error {
if !filepath.IsAbs(src) || !filepath.IsAbs(dst) {
return fmt.Errorf("src or dst path not abosulte, src: %s dst: %s", src, dst)
return fmt.Errorf("src or dst path not absolute, src: %s dst: %s", src, dst)
}

entries, err := os.ReadDir(src)
Expand Down Expand Up @@ -200,7 +200,7 @@ func copyDir(src, dst string) error {
// to be absolute to ensure consistent behavior.
func copyFile(src, dst string) error {
if !filepath.IsAbs(src) || !filepath.IsAbs(dst) {
return fmt.Errorf("src or dst path not abosulte, src: %s dst: %s", src, dst)
return fmt.Errorf("src or dst path not absolute, src: %s dst: %s", src, dst)
}

// verify if it's regular flile
Expand Down
2 changes: 1 addition & 1 deletion cmd/gnofaucet/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func execServe(cfg *config, args []string, io *commands.IO) error {
r.ParseForm()

// only when command line argument 'captcha-secret' has entered > captcha are enabled.
// veryify captcha
// verify captcha
if cfg.CaptchaSecret != "" {
passedMsg := r.Form["g-recaptcha-response"]
if passedMsg == nil {
Expand Down
Loading

0 comments on commit c24273b

Please sign in to comment.