Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjbrettj committed Mar 23, 2023
1 parent 33aeca6 commit 86b2299
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 147 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ WORKDIR /go/src/github.com/ChainSafe/gossamer
COPY go.mod go.sum ./
RUN go mod download

# Prepare libwasmer.so for COPY
#RUN cp /go/pkg/mod/github.com/wasmerio/go-ext-wasm@*/wasmer/libwasmer.so libwasmer.so

# Copy gossamer sources
COPY . .

Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2022 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2022 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/exports.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2021 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer
Expand Down
40 changes: 11 additions & 29 deletions lib/runtime/wasmer/exports_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2021 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer

import (
"bytes"
"encoding/json"
"fmt"
"math/big"
"os"
"testing"
Expand All @@ -33,8 +32,7 @@ import (
var testKeyOwnershipProof types.OpaqueKeyOwnershipProof = types.OpaqueKeyOwnershipProof([]byte{64, 138, 252, 29, 127, 102, 189, 129, 207, 47, 157, 60, 17, 138, 194, 121, 139, 92, 176, 175, 224, 16, 185, 93, 175, 251, 224, 81, 209, 61, 0, 71}) //nolint:lll

func Test_Instance_Version(t *testing.T) {
//t.Parallel()

t.Parallel()
type instanceVersioner interface {
Version() (version runtime.Version)
}
Expand Down Expand Up @@ -282,8 +280,7 @@ func Test_Instance_Version(t *testing.T) {
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
//t.Parallel()

t.Parallel()
instance := testCase.instanceBuilder(t)
version := instance.Version()
assert.Equal(t, testCase.expectedVersion, version)
Expand Down Expand Up @@ -366,7 +363,6 @@ func TestNodeRuntime_ValidateTransaction(t *testing.T) {

func TestInstance_GrandpaAuthorities_NodeRuntime(t *testing.T) {
tt := trie.NewEmptyTrie()

value, err := common.HexToBytes("0x0108eea1eabcac7d2c8a6459b7322cf997874482bfc3d2ec7a80888a3a7d714103640100000000000000b64994460e59b30364cad3c92e3df6052f9b0ebbb8f88460c194dc5794d6d7170100000000000000") //nolint:lll
require.NoError(t, err)

Expand Down Expand Up @@ -394,7 +390,6 @@ func TestInstance_GrandpaAuthorities_NodeRuntime(t *testing.T) {

func TestInstance_GrandpaAuthorities_PolkadotRuntime(t *testing.T) {
tt := trie.NewEmptyTrie()

value, err := common.HexToBytes("0x0108eea1eabcac7d2c8a6459b7322cf997874482bfc3d2ec7a80888a3a7d714103640100000000000000b64994460e59b30364cad3c92e3df6052f9b0ebbb8f88460c194dc5794d6d7170100000000000000") //nolint:lll
require.NoError(t, err)

Expand All @@ -416,13 +411,11 @@ func TestInstance_GrandpaAuthorities_PolkadotRuntime(t *testing.T) {
{Key: authA, Weight: 1},
{Key: authB, Weight: 1},
}

require.Equal(t, expected, auths)
}

func TestInstance_BabeGenerateKeyOwnershipProof(t *testing.T) {
//t.Parallel()

t.Parallel()
testCases := []struct {
name string
targetRuntime string
Expand All @@ -439,10 +432,9 @@ func TestInstance_BabeGenerateKeyOwnershipProof(t *testing.T) {
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
//t.Parallel()
t.Parallel()

tt := trie.NewEmptyTrie()

randomnessValue, err := common.HexToHash("0x01")
require.NoError(t, err)
key := common.MustHexToBytes(genesis.BABERandomnessKeyHex)
Expand Down Expand Up @@ -471,8 +463,7 @@ func TestInstance_BabeGenerateKeyOwnershipProof(t *testing.T) {
}

func TestInstance_BabeSubmitReportEquivocationUnsignedExtrinsic(t *testing.T) {
//t.Parallel()

t.Parallel()
testCases := []struct {
name string
targetRuntime string
Expand All @@ -489,7 +480,7 @@ func TestInstance_BabeSubmitReportEquivocationUnsignedExtrinsic(t *testing.T) {
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
//t.Parallel()
t.Parallel()

tt := trie.NewEmptyTrie()
rt := NewTestInstanceWithTrie(t, testCase.targetRuntime, tt)
Expand Down Expand Up @@ -540,7 +531,6 @@ func TestInstance_BabeConfiguration_DevRuntime_NoAuthorities(t *testing.T) {
Randomness: [32]byte{},
SecondarySlots: 1,
}

require.Equal(t, expected, cfg)
}

Expand Down Expand Up @@ -580,13 +570,11 @@ func TestInstance_BabeConfiguration_NodeRuntime_WithAuthorities(t *testing.T) {
Randomness: [32]byte{1},
SecondarySlots: 1,
}

require.Equal(t, expected, cfg)
}

func TestInstance_InitializeBlock_NodeRuntime(t *testing.T) {
rt := NewTestInstance(t, runtime.NODE_RUNTIME)

header := &types.Header{
Number: 1,
Digest: types.NewDigest(),
Expand All @@ -598,7 +586,6 @@ func TestInstance_InitializeBlock_NodeRuntime(t *testing.T) {

func TestInstance_InitializeBlock_PolkadotRuntime(t *testing.T) {
rt := NewTestInstance(t, runtime.POLKADOT_RUNTIME)

header := &types.Header{
Number: 1,
Digest: types.NewDigest(),
Expand Down Expand Up @@ -664,7 +651,6 @@ func TestInstance_ApplyExtrinsic_WestendRuntime(t *testing.T) {

func TestInstance_ExecuteBlock_PolkadotRuntime(t *testing.T) {
DefaultTestLogLvl = 0

instance := NewTestInstance(t, runtime.POLKADOT_RUNTIME)

block := runtime.InitializeRuntimeToTest(t, instance, &types.Header{})
Expand Down Expand Up @@ -1124,10 +1110,6 @@ func TestInstance_PaymentQueryInfo(t *testing.T) {
continue
}
require.NoError(t, err)

fmt.Println(info.PartialFee.String())
fmt.Println(test.expect.PartialFee.String())

require.NoError(t, err)
require.NotNil(t, info)
require.Equal(t, test.expect, info)
Expand Down Expand Up @@ -1155,7 +1137,7 @@ func newTrieFromPairs(t *testing.T, filename string) *trie.Trie {
}

func TestInstance_TransactionPaymentCallApi_QueryCallInfo(t *testing.T) {
//t.Parallel()
t.Parallel()
ins := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)
tests := []struct {
callHex string
Expand Down Expand Up @@ -1213,7 +1195,7 @@ func TestInstance_TransactionPaymentCallApi_QueryCallInfo(t *testing.T) {
}

func TestInstance_TransactionPaymentCallApi_QueryCallFeeDetails(t *testing.T) {
//t.Parallel()
t.Parallel()
ins := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)
tests := []struct {
callHex string
Expand Down Expand Up @@ -1274,7 +1256,7 @@ func TestInstance_TransactionPaymentCallApi_QueryCallFeeDetails(t *testing.T) {
}

func TestInstance_GrandpaGenerateKeyOwnershipProof(t *testing.T) {
//t.Parallel()
t.Parallel()
instance := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)
identity := common.MustHexToBytes("0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee")
identityPubKey, _ := ed25519.NewPublicKey(identity)
Expand All @@ -1287,7 +1269,7 @@ func TestInstance_GrandpaGenerateKeyOwnershipProof(t *testing.T) {
}

func TestInstance_GrandpaSubmitReportEquivocationUnsignedExtrinsic(t *testing.T) {
//t.Parallel()
t.Parallel()
identity := common.MustHexToBytes("0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee")
identityPubKey, _ := ed25519.NewPublicKey(identity)
runtime := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/genesis.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2022 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer
Expand Down
6 changes: 3 additions & 3 deletions lib/runtime/wasmer/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2022 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer
Expand All @@ -13,7 +13,7 @@ import (
)

func Test_NewTrieFromGenesis(t *testing.T) {
//t.Parallel()
t.Parallel()

testCases := map[string]struct {
genesis genesis.Genesis
Expand Down Expand Up @@ -64,7 +64,7 @@ func Test_NewTrieFromGenesis(t *testing.T) {
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
//t.Parallel()
t.Parallel()

tr, err := NewTrieFromGenesis(testCase.genesis)

Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2022 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2022 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer
Expand Down
5 changes: 2 additions & 3 deletions lib/runtime/wasmer/imports.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 ChainSafe Systems (ON)
// Copyright 2021 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer
Expand Down Expand Up @@ -925,7 +925,6 @@ func ext_misc_runtime_version_version_1(env interface{}, args []wasmer.Value) ([

instanceContext := env.(*runtime.Context)
dataSpan := args[0].I64()
//data := asMemorySlice(ctx, dataSpan)
code := asMemorySlice(instanceContext, dataSpan)

version, err := GetRuntimeVersion(code)
Expand Down Expand Up @@ -1246,7 +1245,7 @@ func ext_default_child_storage_storage_kill_version_3(env interface{}, args []wa
deleted, all, err := storage.DeleteChildLimit(childStorageKey, limit)
if err != nil {
logger.Warnf("cannot get child storage: %s", err)
return []wasmer.Value{wasmer.NewI64(0)}, err
return []wasmer.Value{wasmer.NewI64(0)}, nil
}

vdt, err := scale.NewVaryingDataType(noneRemain(0), someRemain(0))
Expand Down
Loading

0 comments on commit 86b2299

Please sign in to comment.