aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/testing/protocolsession.go
diff options
context:
space:
mode:
authorkiel barry <kiel.j.barry@gmail.com>2018-05-08 19:08:43 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-05-08 19:08:43 +0800
commit864e80a48fd18fda89b80b11f9116c4e11cb835d (patch)
tree1eb9aa6bbae718b9505e67f4464c6750c08e51eb /p2p/testing/protocolsession.go
parenta42be3b78dcb70ea3c44ba46c277cf41ef0bba23 (diff)
downloadgo-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.gz
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.bz2
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.lz
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.xz
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.zst
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.zip
p2p: fix some golint warnings (#16577)
Diffstat (limited to 'p2p/testing/protocolsession.go')
-rw-r--r--p2p/testing/protocolsession.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/p2p/testing/protocolsession.go b/p2p/testing/protocolsession.go
index 361285f06..8f73bfa03 100644
--- a/p2p/testing/protocolsession.go
+++ b/p2p/testing/protocolsession.go
@@ -78,10 +78,10 @@ type Disconnect struct {
}
// trigger sends messages from peers
-func (self *ProtocolSession) trigger(trig Trigger) error {
- simNode, ok := self.adapter.GetNode(trig.Peer)
+func (s *ProtocolSession) trigger(trig Trigger) error {
+ simNode, ok := s.adapter.GetNode(trig.Peer)
if !ok {
- return fmt.Errorf("trigger: peer %v does not exist (1- %v)", trig.Peer, len(self.IDs))
+ return fmt.Errorf("trigger: peer %v does not exist (1- %v)", trig.Peer, len(s.IDs))
}
mockNode, ok := simNode.Services()[0].(*mockNode)
if !ok {
@@ -107,7 +107,7 @@ func (self *ProtocolSession) trigger(trig Trigger) error {
}
// expect checks an expectation of a message sent out by the pivot node
-func (self *ProtocolSession) expect(exps []Expect) error {
+func (s *ProtocolSession) expect(exps []Expect) error {
// construct a map of expectations for each node
peerExpects := make(map[discover.NodeID][]Expect)
for _, exp := range exps {
@@ -120,9 +120,9 @@ func (self *ProtocolSession) expect(exps []Expect) error {
// construct a map of mockNodes for each node
mockNodes := make(map[discover.NodeID]*mockNode)
for nodeID := range peerExpects {
- simNode, ok := self.adapter.GetNode(nodeID)
+ simNode, ok := s.adapter.GetNode(nodeID)
if !ok {
- return fmt.Errorf("trigger: peer %v does not exist (1- %v)", nodeID, len(self.IDs))
+ return fmt.Errorf("trigger: peer %v does not exist (1- %v)", nodeID, len(s.IDs))
}
mockNode, ok := simNode.Services()[0].(*mockNode)
if !ok {
@@ -202,9 +202,9 @@ func (self *ProtocolSession) expect(exps []Expect) error {
}
// TestExchanges tests a series of exchanges against the session
-func (self *ProtocolSession) TestExchanges(exchanges ...Exchange) error {
+func (s *ProtocolSession) TestExchanges(exchanges ...Exchange) error {
for i, e := range exchanges {
- if err := self.testExchange(e); err != nil {
+ if err := s.testExchange(e); err != nil {
return fmt.Errorf("exchange #%d %q: %v", i, e.Label, err)
}
log.Trace(fmt.Sprintf("exchange #%d %q: run successfully", i, e.Label))
@@ -214,14 +214,14 @@ func (self *ProtocolSession) TestExchanges(exchanges ...Exchange) error {
// testExchange tests a single Exchange.
// Default timeout value is 2 seconds.
-func (self *ProtocolSession) testExchange(e Exchange) error {
+func (s *ProtocolSession) testExchange(e Exchange) error {
errc := make(chan error)
done := make(chan struct{})
defer close(done)
go func() {
for _, trig := range e.Triggers {
- err := self.trigger(trig)
+ err := s.trigger(trig)
if err != nil {
errc <- err
return
@@ -229,7 +229,7 @@ func (self *ProtocolSession) testExchange(e Exchange) error {
}
select {
- case errc <- self.expect(e.Expects):
+ case errc <- s.expect(e.Expects):
case <-done:
}
}()
@@ -250,7 +250,7 @@ func (self *ProtocolSession) testExchange(e Exchange) error {
// TestDisconnected tests the disconnections given as arguments
// the disconnect structs describe what disconnect error is expected on which peer
-func (self *ProtocolSession) TestDisconnected(disconnects ...*Disconnect) error {
+func (s *ProtocolSession) TestDisconnected(disconnects ...*Disconnect) error {
expects := make(map[discover.NodeID]error)
for _, disconnect := range disconnects {
expects[disconnect.Peer] = disconnect.Error
@@ -259,7 +259,7 @@ func (self *ProtocolSession) TestDisconnected(disconnects ...*Disconnect) error
timeout := time.After(time.Second)
for len(expects) > 0 {
select {
- case event := <-self.events:
+ case event := <-s.events:
if event.Type != p2p.PeerEventTypeDrop {
continue
}