From a4113220bedb0efaad5c12eda252737f12e75f18 Mon Sep 17 00:00:00 2001 From: Rado M Date: Mon, 15 Jan 2024 10:29:27 +0200 Subject: [PATCH] reuse metadata helper --- gossamer | 2 +- runtime/benchmark_runtime_test.go | 33 ------------------------- runtime/benchmark_timestamp_set_test.go | 2 +- runtime/runtime_test.go | 7 +++++- tinygo | 2 +- 5 files changed, 9 insertions(+), 37 deletions(-) delete mode 100644 runtime/benchmark_runtime_test.go diff --git a/gossamer b/gossamer index d16027aa..9f6e042b 160000 --- a/gossamer +++ b/gossamer @@ -1 +1 @@ -Subproject commit d16027aa68b3ae468a38996af5ad400fdebde4d9 +Subproject commit 9f6e042b7ebfdedf1c4a2dfb33f663a71228f47c diff --git a/runtime/benchmark_runtime_test.go b/runtime/benchmark_runtime_test.go deleted file mode 100644 index 2a2c7473..00000000 --- a/runtime/benchmark_runtime_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "testing" - - "github.com/ChainSafe/gossamer/lib/runtime" - wazero_runtime "github.com/ChainSafe/gossamer/lib/runtime/wazero" - "github.com/ChainSafe/gossamer/lib/trie" - "github.com/ChainSafe/gossamer/pkg/scale" - ctypes "github.com/centrifuge/go-substrate-rpc-client/v4/types" - "github.com/centrifuge/go-substrate-rpc-client/v4/types/codec" - "github.com/stretchr/testify/assert" -) - -func newBenchmarkingRuntime(b *testing.B) (*wazero_runtime.Instance, *runtime.Storage) { - runtime := wazero_runtime.NewBenchInstanceWithTrie(b, WASM_RUNTIME, trie.NewEmptyTrie()) - return runtime, &runtime.Context.Storage -} - -func newBenchmarkingRuntimeMetadata(b *testing.B, instance *wazero_runtime.Instance) *ctypes.Metadata { - bMetadata, err := instance.Metadata() - assert.NoError(b, err) - - var decoded []byte - err = scale.Unmarshal(bMetadata, &decoded) - assert.NoError(b, err) - - metadata := &ctypes.Metadata{} - err = codec.Decode(decoded, metadata) - assert.NoError(b, err) - - return metadata -} diff --git a/runtime/benchmark_timestamp_set_test.go b/runtime/benchmark_timestamp_set_test.go index 29ba119a..7c259380 100644 --- a/runtime/benchmark_timestamp_set_test.go +++ b/runtime/benchmark_timestamp_set_test.go @@ -21,7 +21,7 @@ func BenchmarkTimestampSetStep1(b *testing.B) { func benchmarkTimestampSet(b *testing.B) { rt, storage := newBenchmarkingRuntime(b) - metadata := newBenchmarkingRuntimeMetadata(b, rt) + metadata := runtimeMetadata(b, rt) // Setup the input params now := uint64(time.Now().UnixMilli()) diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index fcabeb3d..8caf1ba2 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -123,7 +123,12 @@ func newTestRuntime(t *testing.T) (*wazero_runtime.Instance, *runtime.Storage) { return runtime, &runtime.Context.Storage } -func runtimeMetadata(t *testing.T, instance *wazero_runtime.Instance) *ctypes.Metadata { +func newBenchmarkingRuntime(b *testing.B) (*wazero_runtime.Instance, *runtime.Storage) { + runtime := wazero_runtime.NewBenchInstanceWithTrie(b, WASM_RUNTIME, trie.NewEmptyTrie()) + return runtime, &runtime.Context.Storage +} + +func runtimeMetadata(t assert.TestingT, instance *wazero_runtime.Instance) *ctypes.Metadata { bMetadata, err := instance.Metadata() assert.NoError(t, err) diff --git a/tinygo b/tinygo index 68308aae..e9015848 160000 --- a/tinygo +++ b/tinygo @@ -1 +1 @@ -Subproject commit 68308aae5f4d724595487d3bee584d5687ae3c9f +Subproject commit e9015848aeceda2df77f745466e5e76ff342dc16