-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dot/rpc: Implement RPC author_insertKey (#765)
* add InsertKey interface * implement author_insertKey * lint issues * added tests for author_insertKey * remove unnecessary logging * fix imports merge conflict * move newTestSerice to test_helper.go and make public
- Loading branch information
1 parent
4b58caa
commit 2bf5a7e
Showing
9 changed files
with
202 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2020 ChainSafe Systems (ON) Corp. | ||
// This file is part of gossamer. | ||
// | ||
// The gossamer library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The gossamer library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the gossamer library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package core | ||
|
||
import ( | ||
"math/big" | ||
"testing" | ||
|
||
"github.com/ChainSafe/gossamer/dot/network" | ||
"github.com/ChainSafe/gossamer/dot/state" | ||
"github.com/ChainSafe/gossamer/dot/types" | ||
"github.com/ChainSafe/gossamer/lib/genesis" | ||
"github.com/ChainSafe/gossamer/lib/keystore" | ||
"github.com/ChainSafe/gossamer/lib/runtime" | ||
"github.com/ChainSafe/gossamer/lib/trie" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// testGenesisHeader is a test block header | ||
var testGenesisHeader = &types.Header{ | ||
Number: big.NewInt(0), | ||
StateRoot: trie.EmptyHash, | ||
} | ||
|
||
// NewTestService creates a new test core service | ||
func NewTestService(t *testing.T, cfg *Config) *Service { | ||
if cfg == nil { | ||
rt := runtime.NewTestRuntime(t, runtime.POLKADOT_RUNTIME_c768a7e4c70e) | ||
cfg = &Config{ | ||
Runtime: rt, | ||
IsBabeAuthority: false, | ||
} | ||
} | ||
|
||
if cfg.Keystore == nil { | ||
cfg.Keystore = keystore.NewKeystore() | ||
} | ||
|
||
if cfg.NewBlocks == nil { | ||
cfg.NewBlocks = make(chan types.Block) | ||
} | ||
|
||
if cfg.MsgRec == nil { | ||
cfg.MsgRec = make(chan network.Message, 10) | ||
} | ||
|
||
if cfg.MsgSend == nil { | ||
cfg.MsgSend = make(chan network.Message, 10) | ||
} | ||
|
||
if cfg.SyncChan == nil { | ||
cfg.SyncChan = make(chan *big.Int, 10) | ||
} | ||
|
||
stateSrvc := state.NewService("") | ||
stateSrvc.UseMemDB() | ||
|
||
genesisData := new(genesis.Data) | ||
|
||
err := stateSrvc.Initialize(genesisData, testGenesisHeader, trie.NewEmptyTrie()) | ||
require.Nil(t, err) | ||
|
||
err = stateSrvc.Start() | ||
require.Nil(t, err) | ||
|
||
if cfg.BlockState == nil { | ||
cfg.BlockState = stateSrvc.Block | ||
} | ||
|
||
if cfg.StorageState == nil { | ||
cfg.StorageState = stateSrvc.Storage | ||
} | ||
|
||
s, err := NewService(cfg) | ||
require.Nil(t, err) | ||
|
||
return s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.