Skip to content

Commit

Permalink
feat(BUX-648): change logic for updating PubKey
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Mar 29, 2024
1 parent 91b596b commit 81d1511
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions engine/contact_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ func TestClientService_AddContactRequest(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, contact)

// mark request as accepted
contact.Status = ContactNotConfirmed
// mark request as confirmed
contact.Status = ContactConfirmed
err = contact.Save(ctx)
require.NoError(t, err)

Expand All @@ -295,7 +295,7 @@ func TestClientService_AddContactRequest(t *testing.T) {
require.Equal(t, updatedPki, updatedContact.PubKey)

// status should back to awaiting
require.Equal(t, ContactAwaitAccept, updatedContact.Status)
require.Equal(t, ContactNotConfirmed, updatedContact.Status)
})
}

Expand Down
6 changes: 4 additions & 2 deletions engine/model_contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ func (c *Contact) Confirm() error {

func (c *Contact) UpdatePubKey(pk string) (updated bool) {
if c.PubKey != pk {
// update and back to awaiting if pub key has changed
c.Status = ContactAwaitAccept
c.PubKey = pk

if c.Status == ContactConfirmed {
c.Status = ContactNotConfirmed
}

updated = true
}

Expand Down

0 comments on commit 81d1511

Please # to comment.