Skip to content

Commit

Permalink
Remove SelectKeyPair from eth-nodes/types
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Pombeiro committed Dec 19, 2019
1 parent 6550316 commit 41a6502
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 33 deletions.
6 changes: 0 additions & 6 deletions eth-node/bridge/geth/whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ func (w *gethWhisperWrapper) DeleteKeyPair(key string) bool {
return w.whisper.DeleteKeyPair(key)
}

// SelectKeyPair adds cryptographic identity, and makes sure
// that it is the only private key known to the node.
func (w *gethWhisperWrapper) SelectKeyPair(key *ecdsa.PrivateKey) error {
return w.whisper.SelectKeyPair(key)
}

func (w *gethWhisperWrapper) AddSymKeyDirect(key []byte) (string, error) {
return w.whisper.AddSymKeyDirect(key)
}
Expand Down
6 changes: 0 additions & 6 deletions eth-node/bridge/nimbus/whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,6 @@ func (w *nimbusWhisperWrapper) DeleteKeyPair(key string) bool {
}).(bool)
}

// SelectKeyPair adds cryptographic identity, and makes sure
// that it is the only private key known to the node.
func (w *nimbusWhisperWrapper) SelectKeyPair(key *ecdsa.PrivateKey) error {
return errors.New("not implemented")
}

func (w *nimbusWhisperWrapper) AddSymKeyDirect(key []byte) (string, error) {
retVal := w.routineQueue.Send(func(c chan<- interface{}) {
keyC := C.CBytes(key)
Expand Down
3 changes: 0 additions & 3 deletions eth-node/types/whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ type Whisper interface {
AddKeyPair(key *ecdsa.PrivateKey) (string, error)
// DeleteKeyPair deletes the specified key if it exists.
DeleteKeyPair(key string) bool
// SelectKeyPair adds cryptographic identity, and makes sure
// that it is the only private key known to the node.
SelectKeyPair(key *ecdsa.PrivateKey) error
AddSymKeyDirect(key []byte) (string, error)
AddSymKeyFromPassword(password string) (string, error)
DeleteSymKey(id string) bool
Expand Down
21 changes: 12 additions & 9 deletions services/shhext/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ func TestShhExtSuite(t *testing.T) {
type ShhExtSuite struct {
suite.Suite

nodes []*node.Node
services []*Service
whisper []types.Whisper
nodes []*node.Node
services []*Service
whisperWrapper []types.Whisper
whisper []*whisper.Whisper
}

func (s *ShhExtSuite) SetupTest() {
s.nodes = make([]*node.Node, 2)
s.services = make([]*Service, 2)
s.whisper = make([]types.Whisper, 2)
s.whisper = make([]*whisper.Whisper, 2)
s.whisperWrapper = make([]types.Whisper, 2)

directory, err := ioutil.TempDir("", "status-go-testing")
s.Require().NoError(err)
Expand All @@ -115,15 +117,16 @@ func (s *ShhExtSuite) SetupTest() {
}
stack, err := node.New(cfg)
s.NoError(err)
s.whisper[i] = gethbridge.NewGethWhisperWrapper(whisper.New(nil))
s.whisper[i] = whisper.New(nil)
s.whisperWrapper[i] = gethbridge.NewGethWhisperWrapper(s.whisper[i])

privateKey, err := crypto.GenerateKey()
s.NoError(err)
err = s.whisper[i].SelectKeyPair(privateKey)
s.NoError(err)

s.NoError(stack.Register(func(n *node.ServiceContext) (node.Service, error) {
return gethbridge.GetGethWhisperFrom(s.whisper[i]), nil
return gethbridge.GetGethWhisperFrom(s.whisperWrapper[i]), nil
}))

config := params.ShhextConfig{
Expand All @@ -135,7 +138,7 @@ func (s *ShhExtSuite) SetupTest() {
}
db, err := leveldb.Open(storage.NewMemStorage(), nil)
s.Require().NoError(err)
nodeWrapper := &testNodeWrapper{w: s.whisper[i]}
nodeWrapper := &testNodeWrapper{w: s.whisperWrapper[i]}
s.services[i] = New(nodeWrapper, nil, nil, db, config)

tmpdir, err := ioutil.TempDir("", "test-shhext-service")
Expand Down Expand Up @@ -170,7 +173,7 @@ func (s *ShhExtSuite) TestInitProtocol() {
shh := gethbridge.NewGethWhisperWrapper(whisper.New(nil))
privateKey, err := crypto.GenerateKey()
s.Require().NoError(err)
err = shh.SelectKeyPair(privateKey)
err = gethbridge.GetGethWhisperFrom(shh).SelectKeyPair(privateKey)
s.Require().NoError(err)

nodeWrapper := &testNodeWrapper{w: shh}
Expand Down Expand Up @@ -298,7 +301,7 @@ func (s *ShhExtSuite) TestRequestMessagesSuccess() {
shh := gethbridge.NewGethWhisperWrapper(whisper.New(nil))
privateKey, err := crypto.GenerateKey()
s.Require().NoError(err)
err = shh.SelectKeyPair(privateKey)
err = gethbridge.GetGethWhisperFrom(shh).SelectKeyPair(privateKey)
s.Require().NoError(err)
aNode, err := node.New(&node.Config{
P2P: p2p.Config{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 41a6502

Please sign in to comment.