Skip to content

Commit

Permalink
Should ignore non-matching pubkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Oct 18, 2024
1 parent ee3681f commit 2e97daa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion service/adapters/sqlite/public_key_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (m *PublicKeyRepository) DeleteByPublicKey(publicKey domain.PublicKey) erro
err := row.Scan(&accountID)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return errors.New("no account found with the provided public key")
return nil
}
return errors.Wrap(err, "error retrieving account_id")
}
Expand Down
14 changes: 14 additions & 0 deletions service/adapters/sqlite/public_key_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,17 @@ func TestPublicKeyRepository_DeleteByPublicKey(t *testing.T) {
})
require.NoError(t, err)
}

func TestPublicKeyRepository_DeleteByPublicKey_NonExistent(t *testing.T) {
ctx := fixtures.TestContext(t)
adapters := NewTestAdapters(ctx, t)

publicKey := fixtures.SomePublicKey()

err := adapters.TransactionProvider.Transact(ctx, func(ctx context.Context, adapters sqlite.TestAdapters) error {
err := adapters.PublicKeyRepository.DeleteByPublicKey(publicKey)
require.NoError(t, err)
return nil
})
require.NoError(t, err)
}
4 changes: 2 additions & 2 deletions service/app/vanish_subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ func (f *VanishSubscriber) Run(ctx context.Context) error {
pubkey, err := domain.NewPublicKeyFromHex(entry.Values["pubkey"].(string))

if err != nil {
f.logger.Error().Message("Error parsing pubkey")
f.logger.Error().WithError(err).Message("Error parsing pubkey")
break
}

err = f.removePubkeyInfo(ctx, pubkey)
if err != nil {
f.logger.Error().WithField("streamId", streamID).Message("Failed to process entry")
f.logger.Error().WithError(err).WithField("streamId", streamID).Message("Failed to process entry")
continue
}

Expand Down

0 comments on commit 2e97daa

Please sign in to comment.