Skip to content

Commit

Permalink
[Functions] Fix bug in comparing subscriptions (#12379) (#12576)
Browse files Browse the repository at this point in the history
Co-authored-by: Sneha Agnihotri <[email protected]>
  • Loading branch information
bolekk and snehaagni authored Mar 27, 2024
1 parent 61d0f28 commit 47eb373
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package subscriptions

import (
"math/big"
"reflect"

"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
Expand Down Expand Up @@ -54,7 +55,7 @@ func (us *userSubscriptions) UpdateSubscription(subscriptionId uint64, subscript
}

// there is no change to the subscription
if us.userSubscriptionsMap[subscription.Owner][subscriptionId] == subscription {
if reflect.DeepEqual(us.userSubscriptionsMap[subscription.Owner][subscriptionId], subscription) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ func TestUserSubscriptions_UpdateSubscription(t *testing.T) {

t.Run("no actual changes", func(t *testing.T) {
us := subscriptions.NewUserSubscriptions()
subscription := &functions_router.IFunctionsSubscriptionsSubscription{
subscription := functions_router.IFunctionsSubscriptionsSubscription{
Owner: utils.RandomAddress(),
Balance: big.NewInt(25),
BlockedBalance: big.NewInt(25),
}
updated := us.UpdateSubscription(5, subscription)
identicalSubscription := subscription
updated := us.UpdateSubscription(5, &subscription)
assert.True(t, updated)

updated = us.UpdateSubscription(5, subscription)
updated = us.UpdateSubscription(5, &identicalSubscription)
assert.False(t, updated)
})
}

0 comments on commit 47eb373

Please sign in to comment.