diff --git a/pkg/rpcclient/unwrap/unwrap.go b/pkg/rpcclient/unwrap/unwrap.go index de82e6121..fd1d27a90 100644 --- a/pkg/rpcclient/unwrap/unwrap.go +++ b/pkg/rpcclient/unwrap/unwrap.go @@ -155,6 +155,9 @@ func SessionIterator(r *result.Invoke, err error) (uuid.UUID, result.Iterator, e if !ok { return uuid.UUID{}, result.Iterator{}, errors.New("the item is InteropInterface, but not an Iterator") } + if (r.Session == uuid.UUID{}) && iter.ID != nil { + return uuid.UUID{}, result.Iterator{}, errors.New("server returned iterator ID, but no session ID") + } return r.Session, iter, nil } diff --git a/pkg/rpcclient/unwrap/unwrap_test.go b/pkg/rpcclient/unwrap/unwrap_test.go index 60fc60088..2f895a07e 100644 --- a/pkg/rpcclient/unwrap/unwrap_test.go +++ b/pkg/rpcclient/unwrap/unwrap_test.go @@ -197,8 +197,11 @@ func TestSessionIterator(t *testing.T) { require.Error(t, err) iid := uuid.New() - sid := uuid.New() iter := result.Iterator{ID: &iid} + _, _, err = SessionIterator(&result.Invoke{State: "HALT", Stack: []stackitem.Item{stackitem.NewInterop(iter)}}, nil) + require.Error(t, err) + + sid := uuid.New() rs, ri, err := SessionIterator(&result.Invoke{Session: sid, State: "HALT", Stack: []stackitem.Item{stackitem.NewInterop(iter)}}, nil) require.NoError(t, err) require.Equal(t, sid, rs)