github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/modules/wasm/runtime/wasmtime/vm_test.go (about)

     1  package wasmtime_test
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/google/uuid"
     8  	. "github.com/onsi/gomega"
     9  
    10  	"github.com/machinefi/w3bstream/pkg/modules/wasm/runtime/wasmtime"
    11  )
    12  
    13  func TestNewWasmtimeVM(t *testing.T) {
    14  	vmid := uuid.NewString()
    15  	vm := wasmtime.NewWasmtimeVM(vmid)
    16  
    17  	NewWithT(t).Expect(vm.ID()).To(Equal(vmid))
    18  
    19  	wasmCode, err := os.ReadFile("../../testdata/log.wasm")
    20  	NewWithT(t).Expect(err).To(BeNil())
    21  
    22  	mod, err := vm.NewModule(wasmCode)
    23  	NewWithT(t).Expect(err).To(BeNil())
    24  
    25  	t.Log(mod.GetABINameList())
    26  
    27  	_ = wasmtime.NewWasmtimeInstance(vm.(*wasmtime.VM), mod.(*wasmtime.Module))
    28  }