diff --git a/documents/service.go b/documents/service.go index 19c496c94..fd6298456 100644 --- a/documents/service.go +++ b/documents/service.go @@ -397,17 +397,11 @@ func (s service) UpdateModel(ctx context.Context, payload UpdatePayload) (Model, // Derive looks for specific document type service based in the schema and delegates the Derivation to that service.˜ func (s service) Derive(ctx context.Context, payload UpdatePayload) (Model, error) { if len(payload.DocumentID) == 0 { - did, err := contextutil.AccountDID(ctx) - if err != nil { - return nil, ErrDocumentConfigAccountID - } - doc, err := s.New(payload.Scheme) if err != nil { return nil, err } - payload.Collaborators.ReadWriteCollaborators = append(payload.Collaborators.ReadWriteCollaborators, did) if err := doc.(Deriver).DeriveFromCreatePayload(ctx, payload.CreatePayload); err != nil { return nil, errors.NewTypedError(ErrDocumentInvalid, err) } diff --git a/documents/service_test.go b/documents/service_test.go index c9bcd2674..40e2c6e59 100644 --- a/documents/service_test.go +++ b/documents/service_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/centrifuge/go-centrifuge/errors" + "github.com/centrifuge/go-centrifuge/identity" "github.com/centrifuge/go-centrifuge/jobs" testingconfig "github.com/centrifuge/go-centrifuge/testingutils/config" "github.com/centrifuge/go-centrifuge/testingutils/testingjobs" @@ -160,20 +161,20 @@ func TestService_Derive(t *testing.T) { attrs := map[AttrKey]Attribute{ attr.Key: attr, } + cid, err := identity.NewDIDFromString("0xBAEb33a61f05e6F269f1c4b4CFF91A901B54DaF7") + assert.NoError(t, err) payload := UpdatePayload{CreatePayload: CreatePayload{ Scheme: scheme, Attributes: attrs, + Collaborators: CollaboratorsAccess{ + ReadCollaborators: nil, + ReadWriteCollaborators: []identity.DID{cid}, + }, }} s := service{} - // missing account ctx - ctx := context.Background() - _, err = s.Derive(ctx, payload) - assert.Error(t, err) - assert.True(t, errors.IsOfType(ErrDocumentConfigAccountID, err)) - // unknown scheme - ctx = testingconfig.CreateAccountContext(t, cfg) + ctx := testingconfig.CreateAccountContext(t, cfg) s.registry = NewServiceRegistry() _, err = s.Derive(ctx, payload) assert.Error(t, err) diff --git a/testworld/rules_test.go b/testworld/rules_test.go index 0c88b083b..5a3260fb9 100644 --- a/testworld/rules_test.go +++ b/testworld/rules_test.go @@ -19,7 +19,7 @@ func setupTransitionRuleForCharlie(t *testing.T) (string, string) { charlie := doctorFord.getHostTestSuite(t, "Charlie") // Alice prepares document to share with Bob - docPayload := genericCoreAPICreate([]string{bob.id.String()}) + docPayload := genericCoreAPICreate([]string{bob.id.String(), alice.id.String()}) res := createDocumentV2(alice.httpExpect, alice.id.String(), "documents", http.StatusCreated, docPayload) status := getDocumentStatus(t, res) assert.Equal(t, status, "pending") diff --git a/testworld/v2_documents_test.go b/testworld/v2_documents_test.go index 9f6fc61e8..63169738e 100644 --- a/testworld/v2_documents_test.go +++ b/testworld/v2_documents_test.go @@ -224,7 +224,7 @@ func TestDocument_ComputeFields(t *testing.T) { alice := doctorFord.getHostTestSuite(t, "Alice") bob := doctorFord.getHostTestSuite(t, "Bob") - payload := genericCoreAPICreate(nil) + payload := genericCoreAPICreate([]string{alice.id.String()}) res := createDocumentV2(alice.httpExpect, alice.id.String(), "documents", http.StatusCreated, payload) status := getDocumentStatus(t, res) assert.Equal(t, status, "pending")