Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Mar 28, 2023

Conversation

zemyblue
Copy link
Member

@zemyblue zemyblue commented Mar 13, 2023

Description

closes: #13

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

Motivation and context

When we run the wasmd cli, Error: wasmvm module not exist is always displayed.

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

Merging #14 (7cab94a) into main (962f37d) will not change coverage.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #14   +/-   ##
=======================================
  Coverage   60.83%   60.83%           
=======================================
  Files          80       80           
  Lines        9879     9879           
=======================================
  Hits         6010     6010           
  Misses       3553     3553           
  Partials      316      316           
Impacted Files Coverage Δ
x/wasm/module.go 33.07% <0.00%> (ø)

@zemyblue zemyblue marked this pull request as draft March 14, 2023 00:47
@zemyblue zemyblue self-assigned this Mar 20, 2023
@tkxkd0159
Copy link
Member

@zemyblue BuildInfo is not populated when go test. So this test can't be passed

@zemyblue
Copy link
Member Author

@zemyblue BuildInfo is not populated when go test. So this test can't be passed

I know. But without this test, the coverage ci is not satisfied.
I think we need to ignore the coverage error in this case.

@tkxkd0159
Copy link
Member

tkxkd0159 commented Mar 28, 2023

@zemyblue BuildInfo is not populated when go test. So this test can't be passed

I know. But without this test, the coverage ci is not satisfied. I think we need to ignore the coverage error in this case.

Okay! But If we really want to test this version sync, we can try like this

func TestCheckLlibwasmVersion(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))
}

@zemyblue zemyblue marked this pull request as ready for review March 28, 2023 06:57
@zemyblue zemyblue merged commit 1d360e6 into Finschia:main Mar 28, 2023
@zemyblue zemyblue deleted the fix/cli_warning branch April 2, 2023 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wasmvm module not exist
3 participants