swarm/pss: Fix test in notify

This commit is contained in:
lash 2018-10-19 19:01:24 +02:00
parent be084fc4f4
commit bc2a4b866f
3 changed files with 5 additions and 5 deletions

View file

@ -486,7 +486,7 @@ func (api *HandshakeAPI) Handshake(pubkeyid string, topic Topic, sync bool, flus
// Activate handshake functionality on a topic // Activate handshake functionality on a topic
func (api *HandshakeAPI) AddHandshake(topic Topic) error { func (api *HandshakeAPI) AddHandshake(topic Topic) error {
api.ctrl.deregisterFuncs[topic] = api.ctrl.pss.Register(&topic, &handler{f: api.ctrl.handler}) api.ctrl.deregisterFuncs[topic] = api.ctrl.pss.Register(&topic, NewHandler(api.ctrl.handler))
return nil return nil
} }

View file

@ -113,7 +113,7 @@ func NewController(ps *pss.Pss) *Controller {
notifiers: make(map[string]*notifier), notifiers: make(map[string]*notifier),
subscriptions: make(map[string]*subscription), subscriptions: make(map[string]*subscription),
} }
ctrl.pss.Register(&controlTopic, ctrl.Handler) ctrl.pss.Register(&controlTopic, pss.NewHandler(ctrl.Handler))
return ctrl return ctrl
} }
@ -336,7 +336,7 @@ func (c *Controller) handleNotifyWithKeyMsg(msg *Msg) error {
// \TODO keep track of and add actual address // \TODO keep track of and add actual address
updaterAddr := pss.PssAddress([]byte{}) updaterAddr := pss.PssAddress([]byte{})
c.pss.SetSymmetricKey(symkey, topic, &updaterAddr, true) c.pss.SetSymmetricKey(symkey, topic, &updaterAddr, true)
c.pss.Register(&topic, c.Handler) c.pss.Register(&topic, pss.NewHandler(c.Handler))
return c.subscriptions[msg.namestring].handler(msg.namestring, msg.Payload[:len(msg.Payload)-symKeyLength]) return c.subscriptions[msg.namestring].handler(msg.namestring, msg.Payload[:len(msg.Payload)-symKeyLength])
} }

View file

@ -121,7 +121,7 @@ func TestStart(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
defer cancel() defer cancel()
rmsgC := make(chan *pss.APIMsg) rmsgC := make(chan *pss.APIMsg)
rightSub, err := rightRpc.Subscribe(ctx, "pss", rmsgC, "receive", controlTopic) rightSub, err := rightRpc.Subscribe(ctx, "pss", rmsgC, "receive", controlTopic, false)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -174,7 +174,7 @@ func TestStart(t *testing.T) {
t.Fatalf("expected payload length %d, have %d", len(updateMsg)+symKeyLength, len(dMsg.Payload)) t.Fatalf("expected payload length %d, have %d", len(updateMsg)+symKeyLength, len(dMsg.Payload))
} }
rightSubUpdate, err := rightRpc.Subscribe(ctx, "pss", rmsgC, "receive", rsrcTopic) rightSubUpdate, err := rightRpc.Subscribe(ctx, "pss", rmsgC, "receive", rsrcTopic, false)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }