diff --git a/pkg/services/rpcsrv/server.go b/pkg/services/rpcsrv/server.go index 83a192a01..c0b68c686 100644 --- a/pkg/services/rpcsrv/server.go +++ b/pkg/services/rpcsrv/server.go @@ -2429,7 +2429,7 @@ func (s *Server) subscribe(reqParams params.Params, sub *subscriber) (interface{ case neorpc.ExecutionEventID: flt := new(neorpc.ExecutionFilter) err = jd.Decode(flt) - if err == nil && (flt.State != nil && (*flt.State == "HALT" || *flt.State == "FAULT")) { + if err == nil && (flt.State == nil || (*flt.State == "HALT" || *flt.State == "FAULT")) { filter = *flt } else if err == nil { err = errors.New("invalid state") diff --git a/pkg/services/rpcsrv/subscription_test.go b/pkg/services/rpcsrv/subscription_test.go index 41a8191dc..d7f2a2100 100644 --- a/pkg/services/rpcsrv/subscription_test.go +++ b/pkg/services/rpcsrv/subscription_test.go @@ -228,7 +228,7 @@ func TestFilteredSubscriptions(t *testing.T) { require.Equal(t, "my_pretty_notification", n) }, }, - "execution matching": { + "execution matching state": { params: `["transaction_executed", {"state":"HALT"}]`, check: func(t *testing.T, resp *neorpc.Notification) { rmap := resp.Payload[0].(map[string]interface{}) @@ -237,6 +237,26 @@ func TestFilteredSubscriptions(t *testing.T) { require.Equal(t, "HALT", st) }, }, + "execution matching container": { + params: `["transaction_executed", {"container":"` + deploymentTxHash + `"}]`, + check: func(t *testing.T, resp *neorpc.Notification) { + rmap := resp.Payload[0].(map[string]interface{}) + require.Equal(t, neorpc.ExecutionEventID, resp.Event) + tx := rmap["container"].(string) + require.Equal(t, "0x"+deploymentTxHash, tx) + }, + }, + "execution matching state and container": { + params: `["transaction_executed", {"state":"HALT", "container":"` + deploymentTxHash + `"}]`, + check: func(t *testing.T, resp *neorpc.Notification) { + rmap := resp.Payload[0].(map[string]interface{}) + require.Equal(t, neorpc.ExecutionEventID, resp.Event) + tx := rmap["container"].(string) + require.Equal(t, "0x"+deploymentTxHash, tx) + st := rmap["vmstate"].(string) + require.Equal(t, "HALT", st) + }, + }, "tx non-matching": { params: `["transaction_added", {"sender":"00112233445566778899aabbccddeeff00112233"}]`, check: func(t *testing.T, _ *neorpc.Notification) {