diff --git a/dot/core/interface.go b/dot/core/interface.go index aadf9b908a..0e796360ca 100644 --- a/dot/core/interface.go +++ b/dot/core/interface.go @@ -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 { diff --git a/dot/core/messages.go b/dot/core/messages.go index 839e4df996..72a6b76722 100644 --- a/dot/core/messages.go +++ b/dot/core/messages.go @@ -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() diff --git a/dot/core/messages_integration_test.go b/dot/core/messages_integration_test.go index 1ebf679d25..a0f2775c8e 100644 --- a/dot/core/messages_integration_test.go +++ b/dot/core/messages_integration_test.go @@ -20,7 +20,6 @@ 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" @@ -28,7 +27,7 @@ import ( "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) diff --git a/dot/core/messages_test.go b/dot/core/messages_test.go index a918ffbf1c..e251988962 100644 --- a/dot/core/messages_test.go +++ b/dot/core/messages_test.go @@ -39,7 +39,7 @@ type mockBestHeader struct { } type mockGetRuntime struct { - runtime runtime.Instance + runtime RuntimeInstance err error } diff --git a/dot/core/mocks/network_mock.go b/dot/core/mocks/network_mock.go deleted file mode 100644 index 1f1314e3cb..0000000000 --- a/dot/core/mocks/network_mock.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ChainSafe/gossamer/dot/core (interfaces: Network) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - reflect "reflect" - - network "github.com/ChainSafe/gossamer/dot/network" - peerset "github.com/ChainSafe/gossamer/dot/peerset" - gomock "github.com/golang/mock/gomock" - peer "github.com/libp2p/go-libp2p-core/peer" -) - -// MockNetwork is a mock of Network interface. -type MockNetwork struct { - ctrl *gomock.Controller - recorder *MockNetworkMockRecorder -} - -// MockNetworkMockRecorder is the mock recorder for MockNetwork. -type MockNetworkMockRecorder struct { - mock *MockNetwork -} - -// NewMockNetwork creates a new mock instance. -func NewMockNetwork(ctrl *gomock.Controller) *MockNetwork { - mock := &MockNetwork{ctrl: ctrl} - mock.recorder = &MockNetworkMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockNetwork) EXPECT() *MockNetworkMockRecorder { - return m.recorder -} - -// GossipMessage mocks base method. -func (m *MockNetwork) GossipMessage(arg0 network.NotificationsMessage) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "GossipMessage", arg0) -} - -// GossipMessage indicates an expected call of GossipMessage. -func (mr *MockNetworkMockRecorder) GossipMessage(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GossipMessage", reflect.TypeOf((*MockNetwork)(nil).GossipMessage), arg0) -} - -// IsSynced mocks base method. -func (m *MockNetwork) IsSynced() bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsSynced") - ret0, _ := ret[0].(bool) - return ret0 -} - -// IsSynced indicates an expected call of IsSynced. -func (mr *MockNetworkMockRecorder) IsSynced() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSynced", reflect.TypeOf((*MockNetwork)(nil).IsSynced)) -} - -// ReportPeer mocks base method. -func (m *MockNetwork) ReportPeer(arg0 peerset.ReputationChange, arg1 peer.ID) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "ReportPeer", arg0, arg1) -} - -// ReportPeer indicates an expected call of ReportPeer. -func (mr *MockNetworkMockRecorder) ReportPeer(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportPeer", reflect.TypeOf((*MockNetwork)(nil).ReportPeer), arg0, arg1) -} diff --git a/dot/core/mocks/storage_state_mock.go b/dot/core/mocks/storage_state_mock.go deleted file mode 100644 index d3b8d5a715..0000000000 --- a/dot/core/mocks/storage_state_mock.go +++ /dev/null @@ -1,165 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ChainSafe/gossamer/dot/core (interfaces: StorageState) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - reflect "reflect" - - types "github.com/ChainSafe/gossamer/dot/types" - common "github.com/ChainSafe/gossamer/lib/common" - storage "github.com/ChainSafe/gossamer/lib/runtime/storage" - gomock "github.com/golang/mock/gomock" -) - -// MockStorageState is a mock of StorageState interface. -type MockStorageState struct { - ctrl *gomock.Controller - recorder *MockStorageStateMockRecorder -} - -// MockStorageStateMockRecorder is the mock recorder for MockStorageState. -type MockStorageStateMockRecorder struct { - mock *MockStorageState -} - -// NewMockStorageState creates a new mock instance. -func NewMockStorageState(ctrl *gomock.Controller) *MockStorageState { - mock := &MockStorageState{ctrl: ctrl} - mock.recorder = &MockStorageStateMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockStorageState) EXPECT() *MockStorageStateMockRecorder { - return m.recorder -} - -// GenerateTrieProof mocks base method. -func (m *MockStorageState) GenerateTrieProof(arg0 common.Hash, arg1 [][]byte) ([][]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GenerateTrieProof", arg0, arg1) - ret0, _ := ret[0].([][]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GenerateTrieProof indicates an expected call of GenerateTrieProof. -func (mr *MockStorageStateMockRecorder) GenerateTrieProof(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenerateTrieProof", reflect.TypeOf((*MockStorageState)(nil).GenerateTrieProof), arg0, arg1) -} - -// GetStateRootFromBlock mocks base method. -func (m *MockStorageState) GetStateRootFromBlock(arg0 *common.Hash) (*common.Hash, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStateRootFromBlock", arg0) - ret0, _ := ret[0].(*common.Hash) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetStateRootFromBlock indicates an expected call of GetStateRootFromBlock. -func (mr *MockStorageStateMockRecorder) GetStateRootFromBlock(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateRootFromBlock", reflect.TypeOf((*MockStorageState)(nil).GetStateRootFromBlock), arg0) -} - -// GetStorage mocks base method. -func (m *MockStorageState) GetStorage(arg0 *common.Hash, arg1 []byte) ([]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStorage", arg0, arg1) - ret0, _ := ret[0].([]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetStorage indicates an expected call of GetStorage. -func (mr *MockStorageStateMockRecorder) GetStorage(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorage", reflect.TypeOf((*MockStorageState)(nil).GetStorage), arg0, arg1) -} - -// LoadCode mocks base method. -func (m *MockStorageState) LoadCode(arg0 *common.Hash) ([]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LoadCode", arg0) - ret0, _ := ret[0].([]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// LoadCode indicates an expected call of LoadCode. -func (mr *MockStorageStateMockRecorder) LoadCode(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadCode", reflect.TypeOf((*MockStorageState)(nil).LoadCode), arg0) -} - -// LoadCodeHash mocks base method. -func (m *MockStorageState) LoadCodeHash(arg0 *common.Hash) (common.Hash, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LoadCodeHash", arg0) - ret0, _ := ret[0].(common.Hash) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// LoadCodeHash indicates an expected call of LoadCodeHash. -func (mr *MockStorageStateMockRecorder) LoadCodeHash(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadCodeHash", reflect.TypeOf((*MockStorageState)(nil).LoadCodeHash), arg0) -} - -// Lock mocks base method. -func (m *MockStorageState) Lock() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Lock") -} - -// Lock indicates an expected call of Lock. -func (mr *MockStorageStateMockRecorder) Lock() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Lock", reflect.TypeOf((*MockStorageState)(nil).Lock)) -} - -// StoreTrie mocks base method. -func (m *MockStorageState) StoreTrie(arg0 *storage.TrieState, arg1 *types.Header) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StoreTrie", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// StoreTrie indicates an expected call of StoreTrie. -func (mr *MockStorageStateMockRecorder) StoreTrie(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreTrie", reflect.TypeOf((*MockStorageState)(nil).StoreTrie), arg0, arg1) -} - -// TrieState mocks base method. -func (m *MockStorageState) TrieState(arg0 *common.Hash) (*storage.TrieState, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TrieState", arg0) - ret0, _ := ret[0].(*storage.TrieState) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// TrieState indicates an expected call of TrieState. -func (mr *MockStorageStateMockRecorder) TrieState(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TrieState", reflect.TypeOf((*MockStorageState)(nil).TrieState), arg0) -} - -// Unlock mocks base method. -func (m *MockStorageState) Unlock() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Unlock") -} - -// Unlock indicates an expected call of Unlock. -func (mr *MockStorageStateMockRecorder) Unlock() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unlock", reflect.TypeOf((*MockStorageState)(nil).Unlock)) -} diff --git a/dot/core/mocks_generate_test.go b/dot/core/mocks_generate_test.go index 784338ef23..9a33173f78 100644 --- a/dot/core/mocks_generate_test.go +++ b/dot/core/mocks_generate_test.go @@ -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 diff --git a/dot/core/mock_core_test.go b/dot/core/mocks_test.go similarity index 68% rename from dot/core/mock_core_test.go rename to dot/core/mocks_test.go index ee0d44a027..cffa3098c3 100644 --- a/dot/core/mock_core_test.go +++ b/dot/core/mocks_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ChainSafe/gossamer/dot/core (interfaces: BlockState,StorageState,TransactionState,Network,EpochState,CodeSubstitutedState) +// Source: github.com/ChainSafe/gossamer/dot/core (interfaces: BlockState,StorageState,TransactionState,Network,EpochState,CodeSubstitutedState,RuntimeInstance) // Package core is a generated GoMock package. package core @@ -11,6 +11,7 @@ import ( peerset "github.com/ChainSafe/gossamer/dot/peerset" types "github.com/ChainSafe/gossamer/dot/types" common "github.com/ChainSafe/gossamer/lib/common" + keystore "github.com/ChainSafe/gossamer/lib/keystore" runtime "github.com/ChainSafe/gossamer/lib/runtime" storage "github.com/ChainSafe/gossamer/lib/runtime/storage" transaction "github.com/ChainSafe/gossamer/lib/transaction" @@ -803,3 +804,376 @@ func (mr *MockCodeSubstitutedStateMockRecorder) StoreCodeSubstitutedBlockHash(ar mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreCodeSubstitutedBlockHash", reflect.TypeOf((*MockCodeSubstitutedState)(nil).StoreCodeSubstitutedBlockHash), arg0) } + +// MockRuntimeInstance is a mock of RuntimeInstance interface. +type MockRuntimeInstance struct { + ctrl *gomock.Controller + recorder *MockRuntimeInstanceMockRecorder +} + +// MockRuntimeInstanceMockRecorder is the mock recorder for MockRuntimeInstance. +type MockRuntimeInstanceMockRecorder struct { + mock *MockRuntimeInstance +} + +// NewMockRuntimeInstance creates a new mock instance. +func NewMockRuntimeInstance(ctrl *gomock.Controller) *MockRuntimeInstance { + mock := &MockRuntimeInstance{ctrl: ctrl} + mock.recorder = &MockRuntimeInstanceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRuntimeInstance) EXPECT() *MockRuntimeInstanceMockRecorder { + return m.recorder +} + +// ApplyExtrinsic mocks base method. +func (m *MockRuntimeInstance) ApplyExtrinsic(arg0 types.Extrinsic) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ApplyExtrinsic", arg0) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ApplyExtrinsic indicates an expected call of ApplyExtrinsic. +func (mr *MockRuntimeInstanceMockRecorder) ApplyExtrinsic(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyExtrinsic", reflect.TypeOf((*MockRuntimeInstance)(nil).ApplyExtrinsic), arg0) +} + +// BabeConfiguration mocks base method. +func (m *MockRuntimeInstance) BabeConfiguration() (*types.BabeConfiguration, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BabeConfiguration") + ret0, _ := ret[0].(*types.BabeConfiguration) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// BabeConfiguration indicates an expected call of BabeConfiguration. +func (mr *MockRuntimeInstanceMockRecorder) BabeConfiguration() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BabeConfiguration", reflect.TypeOf((*MockRuntimeInstance)(nil).BabeConfiguration)) +} + +// CheckInherents mocks base method. +func (m *MockRuntimeInstance) CheckInherents() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "CheckInherents") +} + +// CheckInherents indicates an expected call of CheckInherents. +func (mr *MockRuntimeInstanceMockRecorder) CheckInherents() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckInherents", reflect.TypeOf((*MockRuntimeInstance)(nil).CheckInherents)) +} + +// DecodeSessionKeys mocks base method. +func (m *MockRuntimeInstance) DecodeSessionKeys(arg0 []byte) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DecodeSessionKeys", arg0) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DecodeSessionKeys indicates an expected call of DecodeSessionKeys. +func (mr *MockRuntimeInstanceMockRecorder) DecodeSessionKeys(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecodeSessionKeys", reflect.TypeOf((*MockRuntimeInstance)(nil).DecodeSessionKeys), arg0) +} + +// Exec mocks base method. +func (m *MockRuntimeInstance) Exec(arg0 string, arg1 []byte) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Exec", arg0, arg1) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Exec indicates an expected call of Exec. +func (mr *MockRuntimeInstanceMockRecorder) Exec(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exec", reflect.TypeOf((*MockRuntimeInstance)(nil).Exec), arg0, arg1) +} + +// ExecuteBlock mocks base method. +func (m *MockRuntimeInstance) ExecuteBlock(arg0 *types.Block) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExecuteBlock", arg0) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ExecuteBlock indicates an expected call of ExecuteBlock. +func (mr *MockRuntimeInstanceMockRecorder) ExecuteBlock(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExecuteBlock", reflect.TypeOf((*MockRuntimeInstance)(nil).ExecuteBlock), arg0) +} + +// FinalizeBlock mocks base method. +func (m *MockRuntimeInstance) FinalizeBlock() (*types.Header, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FinalizeBlock") + ret0, _ := ret[0].(*types.Header) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FinalizeBlock indicates an expected call of FinalizeBlock. +func (mr *MockRuntimeInstanceMockRecorder) FinalizeBlock() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FinalizeBlock", reflect.TypeOf((*MockRuntimeInstance)(nil).FinalizeBlock)) +} + +// GenerateSessionKeys mocks base method. +func (m *MockRuntimeInstance) GenerateSessionKeys() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "GenerateSessionKeys") +} + +// GenerateSessionKeys indicates an expected call of GenerateSessionKeys. +func (mr *MockRuntimeInstanceMockRecorder) GenerateSessionKeys() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenerateSessionKeys", reflect.TypeOf((*MockRuntimeInstance)(nil).GenerateSessionKeys)) +} + +// GetCodeHash mocks base method. +func (m *MockRuntimeInstance) GetCodeHash() common.Hash { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCodeHash") + ret0, _ := ret[0].(common.Hash) + return ret0 +} + +// GetCodeHash indicates an expected call of GetCodeHash. +func (mr *MockRuntimeInstanceMockRecorder) GetCodeHash() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCodeHash", reflect.TypeOf((*MockRuntimeInstance)(nil).GetCodeHash)) +} + +// GrandpaAuthorities mocks base method. +func (m *MockRuntimeInstance) GrandpaAuthorities() ([]types.Authority, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GrandpaAuthorities") + ret0, _ := ret[0].([]types.Authority) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GrandpaAuthorities indicates an expected call of GrandpaAuthorities. +func (mr *MockRuntimeInstanceMockRecorder) GrandpaAuthorities() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GrandpaAuthorities", reflect.TypeOf((*MockRuntimeInstance)(nil).GrandpaAuthorities)) +} + +// InherentExtrinsics mocks base method. +func (m *MockRuntimeInstance) InherentExtrinsics(arg0 []byte) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InherentExtrinsics", arg0) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// InherentExtrinsics indicates an expected call of InherentExtrinsics. +func (mr *MockRuntimeInstanceMockRecorder) InherentExtrinsics(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InherentExtrinsics", reflect.TypeOf((*MockRuntimeInstance)(nil).InherentExtrinsics), arg0) +} + +// InitializeBlock mocks base method. +func (m *MockRuntimeInstance) InitializeBlock(arg0 *types.Header) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InitializeBlock", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// InitializeBlock indicates an expected call of InitializeBlock. +func (mr *MockRuntimeInstanceMockRecorder) InitializeBlock(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitializeBlock", reflect.TypeOf((*MockRuntimeInstance)(nil).InitializeBlock), arg0) +} + +// Keystore mocks base method. +func (m *MockRuntimeInstance) Keystore() *keystore.GlobalKeystore { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Keystore") + ret0, _ := ret[0].(*keystore.GlobalKeystore) + return ret0 +} + +// Keystore indicates an expected call of Keystore. +func (mr *MockRuntimeInstanceMockRecorder) Keystore() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Keystore", reflect.TypeOf((*MockRuntimeInstance)(nil).Keystore)) +} + +// Metadata mocks base method. +func (m *MockRuntimeInstance) Metadata() ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Metadata") + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Metadata indicates an expected call of Metadata. +func (mr *MockRuntimeInstanceMockRecorder) Metadata() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Metadata", reflect.TypeOf((*MockRuntimeInstance)(nil).Metadata)) +} + +// NetworkService mocks base method. +func (m *MockRuntimeInstance) NetworkService() runtime.BasicNetwork { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NetworkService") + ret0, _ := ret[0].(runtime.BasicNetwork) + return ret0 +} + +// NetworkService indicates an expected call of NetworkService. +func (mr *MockRuntimeInstanceMockRecorder) NetworkService() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkService", reflect.TypeOf((*MockRuntimeInstance)(nil).NetworkService)) +} + +// NodeStorage mocks base method. +func (m *MockRuntimeInstance) NodeStorage() runtime.NodeStorage { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NodeStorage") + ret0, _ := ret[0].(runtime.NodeStorage) + return ret0 +} + +// NodeStorage indicates an expected call of NodeStorage. +func (mr *MockRuntimeInstanceMockRecorder) NodeStorage() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NodeStorage", reflect.TypeOf((*MockRuntimeInstance)(nil).NodeStorage)) +} + +// OffchainWorker mocks base method. +func (m *MockRuntimeInstance) OffchainWorker() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "OffchainWorker") +} + +// OffchainWorker indicates an expected call of OffchainWorker. +func (mr *MockRuntimeInstanceMockRecorder) OffchainWorker() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OffchainWorker", reflect.TypeOf((*MockRuntimeInstance)(nil).OffchainWorker)) +} + +// PaymentQueryInfo mocks base method. +func (m *MockRuntimeInstance) PaymentQueryInfo(arg0 []byte) (*types.TransactionPaymentQueryInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PaymentQueryInfo", arg0) + ret0, _ := ret[0].(*types.TransactionPaymentQueryInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PaymentQueryInfo indicates an expected call of PaymentQueryInfo. +func (mr *MockRuntimeInstanceMockRecorder) PaymentQueryInfo(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PaymentQueryInfo", reflect.TypeOf((*MockRuntimeInstance)(nil).PaymentQueryInfo), arg0) +} + +// RandomSeed mocks base method. +func (m *MockRuntimeInstance) RandomSeed() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "RandomSeed") +} + +// RandomSeed indicates an expected call of RandomSeed. +func (mr *MockRuntimeInstanceMockRecorder) RandomSeed() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RandomSeed", reflect.TypeOf((*MockRuntimeInstance)(nil).RandomSeed)) +} + +// SetContextStorage mocks base method. +func (m *MockRuntimeInstance) SetContextStorage(arg0 runtime.Storage) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetContextStorage", arg0) +} + +// SetContextStorage indicates an expected call of SetContextStorage. +func (mr *MockRuntimeInstanceMockRecorder) SetContextStorage(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetContextStorage", reflect.TypeOf((*MockRuntimeInstance)(nil).SetContextStorage), arg0) +} + +// Stop mocks base method. +func (m *MockRuntimeInstance) Stop() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Stop") +} + +// Stop indicates an expected call of Stop. +func (mr *MockRuntimeInstanceMockRecorder) Stop() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockRuntimeInstance)(nil).Stop)) +} + +// UpdateRuntimeCode mocks base method. +func (m *MockRuntimeInstance) UpdateRuntimeCode(arg0 []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateRuntimeCode", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRuntimeCode indicates an expected call of UpdateRuntimeCode. +func (mr *MockRuntimeInstanceMockRecorder) UpdateRuntimeCode(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRuntimeCode", reflect.TypeOf((*MockRuntimeInstance)(nil).UpdateRuntimeCode), arg0) +} + +// ValidateTransaction mocks base method. +func (m *MockRuntimeInstance) ValidateTransaction(arg0 types.Extrinsic) (*transaction.Validity, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ValidateTransaction", arg0) + ret0, _ := ret[0].(*transaction.Validity) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ValidateTransaction indicates an expected call of ValidateTransaction. +func (mr *MockRuntimeInstanceMockRecorder) ValidateTransaction(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateTransaction", reflect.TypeOf((*MockRuntimeInstance)(nil).ValidateTransaction), arg0) +} + +// Validator mocks base method. +func (m *MockRuntimeInstance) Validator() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Validator") + ret0, _ := ret[0].(bool) + return ret0 +} + +// Validator indicates an expected call of Validator. +func (mr *MockRuntimeInstanceMockRecorder) Validator() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Validator", reflect.TypeOf((*MockRuntimeInstance)(nil).Validator)) +} + +// Version mocks base method. +func (m *MockRuntimeInstance) Version() (runtime.Version, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Version") + ret0, _ := ret[0].(runtime.Version) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Version indicates an expected call of Version. +func (mr *MockRuntimeInstanceMockRecorder) Version() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Version", reflect.TypeOf((*MockRuntimeInstance)(nil).Version)) +} diff --git a/dot/core/service.go b/dot/core/service.go index b2d69188d0..cbd0a4a79d 100644 --- a/dot/core/service.go +++ b/dot/core/service.go @@ -68,7 +68,7 @@ type Config struct { TransactionState TransactionState Network Network Keystore *keystore.GlobalKeystore - Runtime runtime.Instance + Runtime RuntimeInstance CodeSubstitutes map[common.Hash]string CodeSubstitutedState CodeSubstitutedState diff --git a/dot/core/service_integration_test.go b/dot/core/service_integration_test.go index 6d98b828f6..206af16751 100644 --- a/dot/core/service_integration_test.go +++ b/dot/core/service_integration_test.go @@ -49,7 +49,7 @@ func balanceKey(t *testing.T, pub []byte) (bKey []byte) { return } -func generateTestValidRemarkTxns(t *testing.T, pubKey []byte, accInfo types.AccountInfo) ([]byte, runtime.Instance) { +func generateTestValidRemarkTxns(t *testing.T, pubKey []byte, accInfo types.AccountInfo) ([]byte, RuntimeInstance) { t.Helper() projectRootPath := utils.GetGssmrV3SubstrateGenesisRawPathTest(t) gen, err := genesis.NewGenesisFromJSONRaw(projectRootPath) diff --git a/dot/rpc/modules/author_integration_test.go b/dot/rpc/modules/author_integration_test.go index 15c6619d37..ee799ac9df 100644 --- a/dot/rpc/modules/author_integration_test.go +++ b/dot/rpc/modules/author_integration_test.go @@ -13,7 +13,6 @@ import ( "testing" "github.com/ChainSafe/gossamer/dot/core" - coremocks "github.com/ChainSafe/gossamer/dot/core/mocks" "github.com/ChainSafe/gossamer/dot/network" "github.com/ChainSafe/gossamer/dot/state" telemetry "github.com/ChainSafe/gossamer/dot/telemetry" @@ -127,7 +126,7 @@ func TestAuthorModule_SubmitExtrinsic_Integration(t *testing.T) { extBytes := common.MustHexToBytes(extHex) - net2test := coremocks.NewMockNetwork(ctrl) + net2test := NewMockNetwork(ctrl) net2test.EXPECT().GossipMessage(&network.TransactionMessage{Extrinsics: []types.Extrinsic{extBytes}}) integrationTestController.network = net2test @@ -172,7 +171,7 @@ func TestAuthorModule_SubmitExtrinsic_invalid(t *testing.T) { integrationTestController.runtime, genesisHash, genesisHash, 0, "System.remark", []byte{}) ctrl := gomock.NewController(t) - net2test := coremocks.NewMockNetwork(ctrl) + net2test := NewMockNetwork(ctrl) net2test.EXPECT().GossipMessage(nil).MaxTimes(0) integrationTestController.network = net2test @@ -221,15 +220,8 @@ func TestAuthorModule_SubmitExtrinsic_AlreadyInPool(t *testing.T) { integrationTestController.runtime, genesisHash, genesisHash, 0, "System.remark", []byte{}) extBytes := common.MustHexToBytes(extHex) - storageState := coremocks.NewMockStorageState(ctrl) - // should not call storage.TrieState - storageState.EXPECT().TrieState(nil).MaxTimes(0) - integrationTestController.storageState = storageState - - net2test := coremocks.NewMockNetwork(ctrl) - // should not call network.GossipMessage - net2test.EXPECT().GossipMessage(nil).MaxTimes(0) - integrationTestController.network = net2test + integrationTestController.storageState = &state.StorageState{} + integrationTestController.network = NewMockNetwork(nil) // setup auth module auth := newAuthorModule(t, integrationTestController) @@ -529,7 +521,7 @@ func TestAuthorModule_SubmitExtrinsic_WithVersion_V0910(t *testing.T) { extHex = common.BytesToHex(extBytes) - net2test := coremocks.NewMockNetwork(ctrl) + net2test := NewMockNetwork(ctrl) net2test.EXPECT().GossipMessage(&network.TransactionMessage{Extrinsics: []types.Extrinsic{extBytes}}) integrationTestController.network = net2test @@ -610,7 +602,7 @@ func setupStateAndRuntime(t *testing.T, basepath string, useInstance useRuntimeI }) ks := keystore.NewGlobalKeystore() - net2test := coremocks.NewMockNetwork(nil) + net2test := NewMockNetwork(nil) integrationTestController := &integrationTestController{ genesis: gen, genesisTrie: genTrie, @@ -670,7 +662,7 @@ func setupStateAndPopulateTrieState(t *testing.T, basepath string, state2test.Stop() }) - net2test := coremocks.NewMockNetwork(nil) + net2test := NewMockNetwork(nil) ks := keystore.NewGlobalKeystore() integrationTestController := &integrationTestController{ genesis: gen,