Skip to content

Commit

Permalink
fix: fix not use checkLibwasmVersion
Browse files Browse the repository at this point in the history
This is because the go command automatically converts the build metadata to the canonical version
and cannot compare the libwasmvm of wasmd and wasmvm
  • Loading branch information
da1suk8 committed Oct 18, 2023
1 parent 722c91d commit 587d59b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
2 changes: 0 additions & 2 deletions x/wasm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ func AddModuleInitFlags(startCmd *cobra.Command) {
startCmd.Flags().Uint32(flagWasmMemoryCacheSize, defaults.MemoryCacheSize, "Sets the size in MiB (NOT bytes) of an in-memory cache for Wasm modules. Set to 0 to disable.")
startCmd.Flags().Uint64(flagWasmQueryGasLimit, defaults.SmartQueryGasLimit, "Set the max gas that can be spent on executing a query with a Wasm contract")
startCmd.Flags().String(flagWasmSimulationGasLimit, "", "Set the max gas that can be spent when executing a simulation TX")

startCmd.PreRunE = chainPreRuns(checkLibwasmVersion, startCmd.PreRunE)
}

// ReadWasmConfig reads the wasm specifig configuration
Expand Down
40 changes: 0 additions & 40 deletions x/wasm/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"

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

"github.com/Finschia/wasmd/x/wasm/keeper"
"github.com/Finschia/wasmd/x/wasm/keeper/testdata"
Expand Down Expand Up @@ -586,38 +581,3 @@ 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/Finschia/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 587d59b

Please sign in to comment.