diff --git a/event.go b/event.go index a7fd1ff..b9aa399 100644 --- a/event.go +++ b/event.go @@ -8,10 +8,10 @@ import ( type EventExt struct { Name string `gv:"name"` State string `gv:"state"` - Parent *NodeID `gv:"parent"` + Parent NodeID `gv:"parent"` } -func NewEventExt(parent *NodeID, name string) *EventExt { +func NewEventExt(parent NodeID, name string) *EventExt { return &EventExt{ Name: name, State: "init", @@ -80,8 +80,8 @@ func (ext *EventExt) Process(ctx *Context, node *Node, source NodeID, signal Sig var messages Messages = nil var changes Changes = nil - if signal.Direction() == Up && ext.Parent != nil { - messages = messages.Add(ctx, *ext.Parent, node, nil, signal) + if signal.Direction() == Up && ext.Parent != node.ID { + messages = messages.Add(ctx, ext.Parent, node, nil, signal) } return messages, changes diff --git a/event_test.go b/event_test.go index 4fcd8cc..c6f3d66 100644 --- a/event_test.go +++ b/event_test.go @@ -1,9 +1,11 @@ package graphvent import ( - "reflect" - "testing" - "time" + "crypto/ed25519" + "reflect" + "testing" + "time" + "crypto/rand" ) func TestEvent(t *testing.T) { @@ -12,8 +14,9 @@ func TestEvent(t *testing.T) { fatalErr(t, err) + event_public, event_private, err := ed25519.GenerateKey(rand.Reader) event_listener := NewListenerExt(100) - event, err := NewNode(ctx, nil, BaseNodeType, 100, nil, NewEventExt(nil, "Test Event"), &TestEventExt{time.Second}, event_listener) + event, err := NewNode(ctx, event_private, BaseNodeType, 100, nil, NewEventExt(KeyID(event_public), "Test Event"), &TestEventExt{time.Second}, event_listener) fatalErr(t, err) response, signals := testSend(t, ctx, NewEventControlSignal("ready?"), event, event) diff --git a/listener.go b/listener.go index e80b63a..9fcbb76 100644 --- a/listener.go +++ b/listener.go @@ -29,8 +29,8 @@ func (listener *ListenerExt) Type() ExtType { // Send the signal to the channel, logging an overflow if it occurs func (ext *ListenerExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) (Messages, Changes) { - ctx.Log.Logf("listener", "LISTENER_PROCESS: %s - %+v", node.ID, reflect.TypeOf(signal)) - ctx.Log.Logf("listener_debug", "LISTENER_DETAIL %+v", signal) + ctx.Log.Logf("listener", "%s - %+v", node.ID, reflect.TypeOf(signal)) + ctx.Log.Logf("listener_debug", "%s->%s - %+v", source, node.ID, signal) select { case ext.Chan <- signal: default: diff --git a/signal.go b/signal.go index 1b4a1c4..c1b157f 100644 --- a/signal.go +++ b/signal.go @@ -208,7 +208,7 @@ type SuccessSignal struct { } func (signal SuccessSignal) String() string { - return fmt.Sprintf("SuccessSignal(%s)", signal.SignalHeader) + return fmt.Sprintf("SuccessSignal(%s)", signal.ResponseHeader) } func (signal SuccessSignal) Permission() Tree { @@ -229,7 +229,7 @@ type ErrorSignal struct { Error string } func (signal ErrorSignal) String() string { - return fmt.Sprintf("ErrorSignal(%s, %s)", signal.SignalHeader, signal.Error) + return fmt.Sprintf("ErrorSignal(%s, %s)", signal.ResponseHeader, signal.Error) } func (signal ErrorSignal) Permission() Tree { return Tree{ @@ -371,7 +371,7 @@ type ReadResultSignal struct { } func (signal ReadResultSignal) String() string { - return fmt.Sprintf("ReadResultSignal(%s, %s, %+v, %+v)", signal.SignalHeader, signal.NodeID, signal.NodeType, signal.Extensions) + return fmt.Sprintf("ReadResultSignal(%s, %s, %+v, %+v)", signal.ResponseHeader, signal.NodeID, signal.NodeType, signal.Extensions) } func (signal ReadResultSignal) Permission() Tree {