Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion dot/core/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,40 @@ import (
"github.com/ChainSafe/gossamer/dot/peerset"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/keystore"
"github.com/ChainSafe/gossamer/lib/runtime"
rtstorage "github.com/ChainSafe/gossamer/lib/runtime/storage"
"github.com/ChainSafe/gossamer/lib/transaction"
)

//go:generate mockgen -destination=mock_core_test.go -package $GOPACKAGE . BlockState,StorageState,TransactionState,Network,EpochState,CodeSubstitutedState
// RuntimeInstance for runtime methods
type RuntimeInstance interface {
UpdateRuntimeCode([]byte) error
Stop()
NodeStorage() runtime.NodeStorage
NetworkService() runtime.BasicNetwork
Keystore() *keystore.GlobalKeystore
Validator() bool
Exec(function string, data []byte) ([]byte, error)
SetContextStorage(s runtime.Storage)
GetCodeHash() common.Hash
Version() (runtime.Version, error)
Metadata() ([]byte, error)
BabeConfiguration() (*types.BabeConfiguration, error)
GrandpaAuthorities() ([]types.Authority, error)
ValidateTransaction(e types.Extrinsic) (*transaction.Validity, error)
InitializeBlock(header *types.Header) error
InherentExtrinsics(data []byte) ([]byte, error)
ApplyExtrinsic(data types.Extrinsic) ([]byte, error)
FinalizeBlock() (*types.Header, error)
ExecuteBlock(block *types.Block) ([]byte, error)
DecodeSessionKeys(enc []byte) ([]byte, error)
PaymentQueryInfo(ext []byte) (*types.TransactionPaymentQueryInfo, error)
CheckInherents()
RandomSeed()
OffchainWorker()
GenerateSessionKeys()
}

// BlockState interface for block state methods
type BlockState interface {
Expand Down
2 changes: 1 addition & 1 deletion dot/core/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
)

func (s *Service) validateTransaction(peerID peer.ID, head *types.Header, rt runtime.Instance,
func (s *Service) validateTransaction(peerID peer.ID, head *types.Header, rt RuntimeInstance,
tx types.Extrinsic) (validity *transaction.Validity, valid bool, err error) {
s.storageState.Lock()

Expand Down
3 changes: 1 addition & 2 deletions dot/core/messages_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import (
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/crypto/sr25519"
"github.com/ChainSafe/gossamer/lib/keystore"
"github.com/ChainSafe/gossamer/lib/runtime"
"github.com/ChainSafe/gossamer/pkg/scale"

"github.com/golang/mock/gomock"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/stretchr/testify/require"
)

func createExtrinsic(t *testing.T, rt runtime.Instance, genHash common.Hash, nonce uint64) types.Extrinsic {
func createExtrinsic(t *testing.T, rt RuntimeInstance, genHash common.Hash, nonce uint64) types.Extrinsic {
t.Helper()
rawMeta, err := rt.Metadata()
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion dot/core/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type mockBestHeader struct {
}

type mockGetRuntime struct {
runtime runtime.Instance
runtime RuntimeInstance
err error
}

Expand Down
75 changes: 0 additions & 75 deletions dot/core/mocks/network_mock.go

This file was deleted.

165 changes: 0 additions & 165 deletions dot/core/mocks/storage_state_mock.go

This file was deleted.

2 changes: 1 addition & 1 deletion dot/core/mocks_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

package core

//go:generate mockgen -destination=mocks_runtime_test.go -package $GOPACKAGE github.com/ChainSafe/gossamer/lib/runtime Instance
//go:generate mockgen -destination=mocks_test.go -package $GOPACKAGE . BlockState,StorageState,TransactionState,Network,EpochState,CodeSubstitutedState,RuntimeInstance
Loading