-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…4019) * WIP: adding fee upgrade cbs and testing * imp: allow failure expectations when using chain.SendMsgs * fixing import errors from cherry-pick * updating tests and rm try code * rm diff onChanUpgradeTry * Update modules/apps/29-fee/ibc_middleware.go * adding MetadataFromVersion func to pkg types * addressing pr feedback, disable fees on err, rename args, adding testcase * Update modules/apps/29-fee/ibc_middleware_test.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * abstract out expIsFeeEnabled check in tests * adding additional error context to MetadataFromVersion --------- Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
- Loading branch information
1 parent
8e53c77
commit f731de5
Showing
6 changed files
with
199 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package types | ||
|
||
import errorsmod "cosmossdk.io/errors" | ||
|
||
// MetadataFromVersion attempts to parse the given string into a fee version Metadata, | ||
// an error is returned if it fails to do so. | ||
func MetadataFromVersion(version string) (Metadata, error) { | ||
var metadata Metadata | ||
err := ModuleCdc.UnmarshalJSON([]byte(version), &metadata) | ||
if err != nil { | ||
return Metadata{}, errorsmod.Wrapf(ErrInvalidVersion, "failed to unmarshal metadata from version: %s", version) | ||
} | ||
|
||
return metadata, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" | ||
ibcmock "github.com/cosmos/ibc-go/v7/testing/mock" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMetadataFromVersion(t *testing.T) { | ||
testMetadata := types.Metadata{ | ||
AppVersion: ibcmock.Version, | ||
FeeVersion: types.Version, | ||
} | ||
|
||
versionBz, err := types.ModuleCdc.MarshalJSON(&testMetadata) | ||
require.NoError(t, err) | ||
|
||
metadata, err := types.MetadataFromVersion(string(versionBz)) | ||
require.NoError(t, err) | ||
require.Equal(t, ibcmock.Version, metadata.AppVersion) | ||
require.Equal(t, types.Version, metadata.FeeVersion) | ||
|
||
metadata, err = types.MetadataFromVersion("") | ||
require.Error(t, err) | ||
require.ErrorIs(t, err, types.ErrInvalidVersion) | ||
require.Empty(t, metadata) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters