From a7feb3bfd794a86b9f0a0af6a0877634e78983df Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 30 Jun 2022 21:29:47 +0200 Subject: [PATCH 1/2] delete unused code and associated tests --- modules/core/04-channel/types/version.go | 27 ------- modules/core/04-channel/types/version_test.go | 77 ------------------- 2 files changed, 104 deletions(-) delete mode 100644 modules/core/04-channel/types/version.go delete mode 100644 modules/core/04-channel/types/version_test.go diff --git a/modules/core/04-channel/types/version.go b/modules/core/04-channel/types/version.go deleted file mode 100644 index a2696d291ed..00000000000 --- a/modules/core/04-channel/types/version.go +++ /dev/null @@ -1,27 +0,0 @@ -package types - -import "strings" - -const ChannelVersionDelimiter = ":" - -// SplitChannelVersion middleware version will split the channel version string -// into the outermost middleware version and the underlying app version. -// It will use the default delimiter `:` for middleware versions. -// In case there's no delimeter, this function returns an empty string for the middleware version (first return argument), -// and the full input as the second underlying app version. -func SplitChannelVersion(version string) (middlewareVersion, appVersion string) { - // only split out the first middleware version - splitVersions := strings.Split(version, ChannelVersionDelimiter) - if len(splitVersions) == 1 { - return "", version - } - middlewareVersion = splitVersions[0] - appVersion = strings.Join(splitVersions[1:], ChannelVersionDelimiter) - return -} - -// MergeChannelVersions merges the provided versions together with the channel version delimiter -// the versions should be passed in from the highest-level middleware to the base application -func MergeChannelVersions(versions ...string) string { - return strings.Join(versions, ChannelVersionDelimiter) -} diff --git a/modules/core/04-channel/types/version_test.go b/modules/core/04-channel/types/version_test.go deleted file mode 100644 index d735f162ae1..00000000000 --- a/modules/core/04-channel/types/version_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" -) - -func TestSplitVersions(t *testing.T) { - testCases := []struct { - name string - version string - mwVersion string - appVersion string - }{ - { - "single wrapped middleware", - "fee29-1:ics20-1", - "fee29-1", - "ics20-1", - }, - { - "multiple wrapped middleware", - "fee29-1:whitelist:ics20-1", - "fee29-1", - "whitelist:ics20-1", - }, - { - "no middleware", - "ics20-1", - "", - "ics20-1", - }, - } - - for _, tc := range testCases { - mwVersion, appVersion := types.SplitChannelVersion(tc.version) - require.Equal(t, tc.mwVersion, mwVersion, "middleware version is unexpected for case: %s", tc.name) - require.Equal(t, tc.appVersion, appVersion, "app version is unexpected for case: %s", tc.name) - } -} - -func TestMergeVersions(t *testing.T) { - testCases := []struct { - name string - versions []string - merged string - }{ - { - "single version", - []string{"ics20-1"}, - "ics20-1", - }, - { - "empty version", - []string{}, - "", - }, - { - "two versions", - []string{"fee29-1", "ics20-1"}, - "fee29-1:ics20-1", - }, - { - "multiple versions", - []string{"fee29-1", "whitelist", "ics20-1"}, - "fee29-1:whitelist:ics20-1", - }, - } - - for _, tc := range testCases { - actual := types.MergeChannelVersions(tc.versions...) - require.Equal(t, tc.merged, actual, "merged versions string does not equal expected value") - } -} From 038470502f88bcc0dd61affb3c54f14376272fb8 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 1 Jul 2022 11:52:42 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e7357459f4..766d232d43b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (apps/27-interchain-accounts)[\#1565](https://github.com/cosmos/ibc-go/pull/1565) Removing `NewErrorAcknowledgement` in favour of `channeltypes.NewErrorAcknowledgement`. * (transfer)[\#1565](https://github.com/cosmos/ibc-go/pull/1565) Removing `NewErrorAcknowledgement` in favour of `channeltypes.NewErrorAcknowledgement`. * (channel)[\#1565](https://github.com/cosmos/ibc-go/pull/1565) Updating `NewErrorAcknowledgement` to accept an error instead of a string and removing the possibility of non-deterministic writes to application state. +* (core/04-channel)[\#1636](https://github.com/cosmos/ibc-go/pull/1636) Removing `SplitChannelVersion` and `MergeChannelVersions` functions since they are not used. ### State Machine Breaking