Skip to content

Commit

Permalink
test(op-alt-da): fix MockDAClient.DeleteData decrement semantic
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Feb 12, 2025
1 parent 6cb0d3b commit cd92599
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions op-alt-da/damock.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ func (c *MockDAClient) DeleteData(key []byte) error {
c.mu.Lock()
defer c.mu.Unlock()
c.log.Debug("Deleting data", "key", key)
err := c.store.Delete(key)
if err == nil {
c.StoreCount--
// memorydb.Delete() returns nil even when the key doesn't exist, so we need to check if the key exists
// before decrementing StoreCount.
var err error
if _, err = c.store.Get(key); err == nil {
if err = c.store.Delete(key); err == nil {
c.StoreCount--
}
}
return err
}
Expand Down

0 comments on commit cd92599

Please sign in to comment.