Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix bug when updating allowance inside AllowedMsgAllowance #10564

Merged
merged 16 commits into from
Jan 5, 2022
Merged
Prev Previous commit
Next Next commit
fix newgrant into loadedgrant and add comments
  • Loading branch information
0Tech committed Jan 4, 2022
commit 092d219f5e16343af36d04e426920fc8f21efab3
10 changes: 8 additions & 2 deletions x/feegrant/filtered_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,19 @@ func TestFilteredFeeValidAllow(t *testing.T) {

require.Equal(t, tc.remove, removed)
if !removed {
// save the new grant
// mimic save & load process (#10564)
// the cached allowance was correct even before the fix,
// however, the saved value was not.
// so we need this to catch the bug.

// create a new updated grant
newGrant, err := feegrant.NewGrant(
sdk.AccAddress(grant.Granter),
sdk.AccAddress(grant.Grantee),
allowance)
require.NoError(t, err)

// save the grant
cdc := simapp.MakeTestEncodingConfig().Codec
bz, err := cdc.Marshal(&newGrant)
require.NoError(t, err)
Expand All @@ -175,7 +181,7 @@ func TestFilteredFeeValidAllow(t *testing.T) {
err = cdc.Unmarshal(bz, &loadedGrant)
require.NoError(t, err)

newAllowance, err := newGrant.GetGrant()
newAllowance, err := loadedGrant.GetGrant()
require.NoError(t, err)
feeAllowance, err := newAllowance.(*feegrant.AllowedMsgAllowance).GetAllowance()
require.NoError(t, err)
Expand Down