Skip to content

Instantly share code, notes, and snippets.

@valvesss
Created July 18, 2018 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valvesss/c3ac06a597bf25d466271275dd478fb3 to your computer and use it in GitHub Desktop.
Save valvesss/c3ac06a597bf25d466271275dd478fb3 to your computer and use it in GitHub Desktop.
package tests
import (
"testing"
"io/ioutil"
"log"
"bytes"
"github.com/go-interpreter/wagon/wasm"
"github.com/go-interpreter/wagon/exec"
"github.com/go-interpreter/wagon/validate"
)
func TestExports(*testing.T) {
raw, err := ioutil.ReadFile("helloworld.wasm")
if err != nil {
log.Fatal("Could not read wasm file.")
}
m, err := wasm.ReadModule(bytes.NewReader(raw), nil)
if err != nil {
log.Fatalf("could not read module: %v", err)
}
val := validate.VerifyModule(m)
if val == nil {
log.Fatalf("could not verify module: %v", err)
}
vm, err := exec.NewVM(m)
if err != nil {
log.Fatalf("could not create VM: %v", err)
}
_ = vm
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment