Skip to content

Commit

Permalink
fix: fix the cmd error that does not recognize wasmvm library version. (
Browse files Browse the repository at this point in the history
#14)

* fix: fix the cmd error that does not recognize wasmvm library version.

* chore: add unittest

* chore: remove unittest

* dump: dump up wasmvm v1.1.1-0.11.2

* doc: update changelog.

* chore: add more unittest
  • Loading branch information
zemyblue authored Mar 28, 2023
1 parent 962f37d commit 1d360e6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

### Bug Fixes
* [\#12](https://github.com/line/wasmd/pull/12) fix not to register wrong codec in `x/wasmplus`
* [\#14](https://github.com/line/wasmd/pull/14) fix the cmd error that does not recognize wasmvm library version

### Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/line/ibc-go/v3 v3.3.2-0.20230210040007-d855e1d87f26
github.com/line/lbm-sdk v0.46.1-0.20230209105703-b88647308597
github.com/line/ostracon v1.0.9-0.20230209043112-5aca894db3a6
github.com/line/wasmvm v1.1.1-0.11.1
github.com/line/wasmvm v1.1.1-0.11.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/rakyll/statik v0.1.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ github.com/line/lbm-sdk v0.46.1-0.20230209105703-b88647308597 h1:J0Pr378D5JmHNji
github.com/line/lbm-sdk v0.46.1-0.20230209105703-b88647308597/go.mod h1:Od+QeMi4JO4HB3HEdPTqzI7mAvn1w99PZ9pmKmtNDco=
github.com/line/ostracon v1.0.9-0.20230209043112-5aca894db3a6 h1:nuM0PTB04PCax35+u8LRpTufdmwoPZcBhhKjqbezMYA=
github.com/line/ostracon v1.0.9-0.20230209043112-5aca894db3a6/go.mod h1:iLRth/ryufyNePzJ1ULJ4S8SYGUD/lF+aIFUTRKY9tQ=
github.com/line/wasmvm v1.1.1-0.11.1 h1:W3fuNZyQYm+fyXV4n6Ds8pzmHLyYcgv5gXgQf42ofi8=
github.com/line/wasmvm v1.1.1-0.11.1/go.mod h1:Lq3FVvi/rb+OOlTxqtcqcao2GGESQ4hUpuXMcjdJbco=
github.com/line/wasmvm v1.1.1-0.11.2 h1:dkwlXSBXQR4aEP8B7RkN4TXqjFbsB2QHPYtsJKlNHmQ=
github.com/line/wasmvm v1.1.1-0.11.2/go.mod h1:Lq3FVvi/rb+OOlTxqtcqcao2GGESQ4hUpuXMcjdJbco=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func getExpectedLibwasmVersion() string {
panic("can't read build info")
}
for _, d := range buildInfo.Deps {
if d.Path != "github.com/CosmWasm/wasmvm" {
if d.Path != "github.com/line/wasmvm" {
continue
}
if d.Replace != nil {
Expand Down
40 changes: 40 additions & 0 deletions x/wasm/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"

"github.com/dvsekhvalnov/jose2go/base64url"
Expand All @@ -20,6 +24,7 @@ import (
stakingkeeper "github.com/line/lbm-sdk/x/staking/keeper"
"github.com/line/ostracon/crypto"
"github.com/line/ostracon/crypto/ed25519"
wasmvm "github.com/line/wasmvm"

"github.com/line/wasmd/x/wasm/keeper"
"github.com/line/wasmd/x/wasm/keeper/testdata"
Expand Down Expand Up @@ -592,3 +597,38 @@ func assertContractInfo(t *testing.T, q sdk.Querier, ctx sdk.Context, contractBe
assert.Equal(t, codeID, res.CodeID)
assert.Equal(t, creator.String(), res.Creator)
}

func TestCheckLibwasmVersion(t *testing.T) {
f, err := os.Open(filepath.Join(moduleBasePath(t), "go.mod"))
assert.NoError(t, err)

res, err := io.ReadAll(f)
assert.NoError(t, err)
parsed := strings.Split(string(res), "\n")
var expected string
for _, line := range parsed {
if strings.Contains(line, "github.com/line/wasmvm") {
expected = strings.Split(strings.TrimSpace(line), " ")[1]
}
}
got, err := wasmvm.LibwasmvmVersion()
assert.NoError(t, err)
assert.Contains(t, expected, got)
}

func moduleBasePath(t *testing.T) string {
t.Helper()

err := os.Setenv("GO111MODULE", "on")
if err != nil {
t.Fatalf("unable to set GO111MODULE env var: %v", err)
}

cmd := exec.Command("go", "list", "-f", "{{.Module.Dir}}")
out, err := cmd.Output()
if err != nil {
t.Fatalf("failed to evaluate Go module base path: %v", err)
}

return strings.TrimSpace(string(out))
}

0 comments on commit 1d360e6

Please sign in to comment.