Skip to content

Commit

Permalink
chore: Integrate scale package into runtime (ChainSafe#1824)
Browse files Browse the repository at this point in the history
* revise APIItems

* update scale integration for version

* rm lib/runtime/extrinsic

* lib/runtime/life updates

* update wasmer

* wip

* update skipped test

* cr feedback, fixed storageAppend

* update test
  • Loading branch information
timwu20 committed Dec 6, 2021
1 parent 4977d06 commit 1b3ad8d
Show file tree
Hide file tree
Showing 19 changed files with 466 additions and 1,406 deletions.
7 changes: 4 additions & 3 deletions dot/core/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ import (
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/keystore"
"github.com/ChainSafe/gossamer/lib/runtime"
"github.com/ChainSafe/gossamer/lib/runtime/extrinsic"
runtimemocks "github.com/ChainSafe/gossamer/lib/runtime/mocks"
"github.com/ChainSafe/gossamer/lib/runtime/storage"
"github.com/ChainSafe/gossamer/lib/runtime/wasmer"
"github.com/ChainSafe/gossamer/lib/transaction"
"github.com/ChainSafe/gossamer/lib/trie"
"github.com/ChainSafe/gossamer/pkg/scale"
log "github.com/ChainSafe/log15"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -287,9 +287,10 @@ func TestHandleChainReorg_WithReorg_Transactions(t *testing.T) {
addTestBlocksToState(t, height, s.blockState.(*state.BlockState))

// create extrinsic
ext := extrinsic.NewIncludeDataExt([]byte("nootwashere"))
tx, err := ext.Encode()
enc, err := scale.Marshal([]byte("nootwashere"))
require.NoError(t, err)
// we prefix with []byte{2} here since that's the enum index for the old IncludeDataExt extrinsic
tx := append([]byte{2}, enc...)

bhash := s.blockState.BestBlockHash()
rt, err := s.blockState.GetRuntime(&bhash)
Expand Down
4 changes: 2 additions & 2 deletions dot/rpc/modules/api_mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func NewMockCoreAPI() *modulesmocks.MockCoreAPI {
}

// NewMockVersion creates and returns an runtime Version interface mock
func NewMockVersion() *runtimemocks.MockVersion {
m := new(runtimemocks.MockVersion)
func NewMockVersion() *runtimemocks.Version {
m := new(runtimemocks.Version)
m.On("SpecName").Return([]byte(`mock-spec`))
m.On("ImplName").Return(nil)
m.On("AuthoringVersion").Return(uint32(0))
Expand Down
2 changes: 1 addition & 1 deletion dot/rpc/modules/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func (*StateModule) SubscribeStorage(_ *http.Request, _ *StateStorageQueryRangeR
}

// ConvertAPIs runtime.APIItems to []interface
func ConvertAPIs(in []*runtime.APIItem) []interface{} {
func ConvertAPIs(in []runtime.APIItem) []interface{} {
ret := make([]interface{}, 0)
for _, item := range in {
encStr := hex.EncodeToString(item.Name[:])
Expand Down
4 changes: 2 additions & 2 deletions dot/state/block_notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ func TestService_RegisterUnRegisterConcurrentCalls(t *testing.T) {
}

// NewMockVersion creates and returns an runtime Version interface mock
func NewMockVersion(specVer uint32) *runtimemocks.MockVersion {
m := new(runtimemocks.MockVersion)
func NewMockVersion(specVer uint32) *runtimemocks.Version {
m := new(runtimemocks.Version)
m.On("SpecName").Return([]byte(`mock-spec`))
m.On("ImplName").Return(nil)
m.On("AuthoringVersion").Return(uint32(0))
Expand Down
Loading

0 comments on commit 1b3ad8d

Please sign in to comment.