Skip to content
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ run:
skip-files:
- .*mock_.*\.go
- .*mocks\/.*\.go
- author_integration_test\.go # TODO remove once fixed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!


# all available settings of specific linters
linters-settings:
Expand Down
6 changes: 4 additions & 2 deletions dot/rpc/modules/api_mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import (
func NewMockStorageAPI() *modulesmocks.StorageAPI {
m := new(modulesmocks.StorageAPI)
m.On("GetStorage", mock.AnythingOfType("*common.Hash"), mock.AnythingOfType("[]uint8")).Return(nil, nil)
m.On("GetStorageFromChild", mock.AnythingOfType("*common.Hash"), mock.AnythingOfType("[]uint8"), mock.AnythingOfType("[]uint8")).Return(nil, nil)
m.On("GetStorageFromChild", mock.AnythingOfType("*common.Hash"), mock.AnythingOfType("[]uint8"),
mock.AnythingOfType("[]uint8")).Return(nil, nil)
m.On("Entries", mock.AnythingOfType("*common.Hash")).Return(nil, nil)
m.On("GetStorageByBlockHash", mock.AnythingOfType("common.Hash"), mock.AnythingOfType("[]uint8")).Return(nil, nil)
m.On("RegisterStorageObserver", mock.Anything)
Expand All @@ -41,7 +42,8 @@ func NewMockBlockAPI() *modulesmocks.BlockAPI {
m.On("FreeFinalisedNotifierChannel", mock.AnythingOfType("chan *types.FinalisationInfo"))
m.On("GetJustification", mock.AnythingOfType("common.Hash")).Return(make([]byte, 10), nil)
m.On("HasJustification", mock.AnythingOfType("common.Hash")).Return(true, nil)
m.On("SubChain", mock.AnythingOfType("common.Hash"), mock.AnythingOfType("common.Hash")).Return(make([]common.Hash, 0), nil)
m.On("SubChain", mock.AnythingOfType("common.Hash"), mock.AnythingOfType("common.Hash")).
Return(make([]common.Hash, 0), nil)
m.On("RegisterRuntimeUpdatedChannel", mock.AnythingOfType("chan<- runtime.Version")).Return(uint32(0), nil)

return m
Expand Down
26 changes: 18 additions & 8 deletions dot/rpc/modules/author_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/internal/log"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/crypto/ed25519"
"github.com/ChainSafe/gossamer/lib/crypto/sr25519"
"github.com/ChainSafe/gossamer/lib/keystore"
"github.com/ChainSafe/gossamer/lib/runtime"
"github.com/ChainSafe/gossamer/lib/runtime/wasmer"
Expand All @@ -33,7 +35,7 @@ var testInvalidExt = []byte{1, 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26,
func TestMain(m *testing.M) {
wasmFilePaths, err := runtime.GenerateRuntimeWasmFile()
if err != nil {
log.Error("failed to generate runtime wasm file", err)
log.Errorf("failed to generate runtime wasm file %s", err)
os.Exit(1)
}

Expand All @@ -46,7 +48,7 @@ func TestMain(m *testing.M) {

func TestAuthorModule_Pending(t *testing.T) {
txQueue := state.NewTransactionState()
auth := NewAuthorModule(nil, nil, nil, txQueue)
auth := NewAuthorModule(nil, nil, txQueue)

res := new(PendingExtrinsicsResponse)
err := auth.PendingExtrinsics(nil, nil, res)
Expand Down Expand Up @@ -178,19 +180,27 @@ func TestAuthorModule_SubmitExtrinsic_InQueue(t *testing.T) {
}

func TestAuthorModule_InsertKey_Valid(t *testing.T) {
seed := "0xb7e9185065667390d2ad952a5324e8c365c9bf503dcf97c67a5ce861afe97309"
kp, err := sr25519.NewKeypairFromSeed(common.MustHexToBytes(seed))
require.NoError(t, err)

auth := setupAuthModule(t, nil)
req := &KeyInsertRequest{"babe", "0xb7e9185065667390d2ad952a5324e8c365c9bf503dcf97c67a5ce861afe97309", "0x6246ddf254e0b4b4e7dffefc8adf69d212b98ac2b579c362b473fec8c40b4c0a"}
req := &KeyInsertRequest{"babe", seed, kp.Public().Hex()}
res := &KeyInsertResponse{}
err := auth.InsertKey(nil, req, res)
err = auth.InsertKey(nil, req, res)
require.Nil(t, err)
require.Len(t, *res, 0) // zero len result on success
}

func TestAuthorModule_InsertKey_Valid_gran_keytype(t *testing.T) {
func TestAuthorModule_InsertKey_Valid_Gran_Keytype(t *testing.T) {
seed := "0xb7e9185065667390d2ad952a5324e8c365c9bf503dcf97c67a5ce861afe97309"
kp, err := ed25519.NewKeypairFromSeed(common.MustHexToBytes(seed))
require.NoError(t, err)

auth := setupAuthModule(t, nil)
req := &KeyInsertRequest{"gran", "0xb7e9185065667390d2ad952a5324e8c365c9bf503dcf97c67a5ce861afe97309b7e9185065667390d2ad952a5324e8c365c9bf503dcf97c67a5ce861afe97309", "0xb7e9185065667390d2ad952a5324e8c365c9bf503dcf97c67a5ce861afe97309"}
req := &KeyInsertRequest{"gran", seed, kp.Public().Hex()}
res := &KeyInsertResponse{}
err := auth.InsertKey(nil, req, res)
err = auth.InsertKey(nil, req, res)
require.Nil(t, err)

require.Len(t, *res, 0) // zero len result on success
Expand Down Expand Up @@ -267,5 +277,5 @@ func setupAuthModule(t *testing.T, txq *state.TransactionState) *AuthorModule {
t.Cleanup(func() {
rt.Stop()
})
return NewAuthorModule(nil, cs, rt, txq)
return NewAuthorModule(nil, cs, txq)
}
Loading