From f3a8cbf072325e37ab21010790b8ee2cdacf3e98 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Fri, 5 Aug 2022 13:58:41 +0000 Subject: [PATCH] `CheckRuntimeVersion` uses `NewInstance` --- lib/runtime/wasmer/instance.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/runtime/wasmer/instance.go b/lib/runtime/wasmer/instance.go index a57f71b175..f1423a938c 100644 --- a/lib/runtime/wasmer/instance.go +++ b/lib/runtime/wasmer/instance.go @@ -159,21 +159,14 @@ func (in *Instance) UpdateRuntimeCode(code []byte) (err error) { // CheckRuntimeVersion finds the runtime version by initiating a temporary // runtime instance using the WASM code provided, and querying it. func CheckRuntimeVersion(code []byte) (version runtime.Version, err error) { - wasmInstance, allocator, err := setupVM(code) - if err != nil { - return nil, fmt.Errorf("setting up VM: %w", err) + config := runtime.InstanceConfig{ + LogLvl: log.DoNotChange, } - - ctx := &runtime.Context{ - Allocator: allocator, - } - wasmInstance.SetContextData(ctx) - - instance := Instance{ - vm: wasmInstance, - ctx: ctx, + instance, err := NewInstance(code, config) + if err != nil { + return version, fmt.Errorf("creating runtime instance: %w", err) } - defer instance.close() + defer instance.Stop() version, err = instance.Version() if err != nil {