Skip to content

Commit

Permalink
added back in core ibc testing files
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs committed Jan 9, 2024
1 parent 2d3fb27 commit d324bf4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
48 changes: 48 additions & 0 deletions legacy_ibc_testing/core/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package core

import (
"strconv"

abci "github.com/cometbft/cometbft/abci/types"

Check failure on line 6 in legacy_ibc_testing/core/events.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos/interchain-security) --custom-order (gci)

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"

Check failure on line 9 in legacy_ibc_testing/core/events.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos/interchain-security) --custom-order (gci)
)

/*
TODO: Remove after upgrading to ibc-go v5
legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only.
The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on.
These files will be deprecated once ICS is able to upgrade to ibc-go v5.
*/

// ReconstructPacketFromEvent recreates a packet from an appropriate provided event
func ReconstructPacketFromEvent(event abci.Event) (packet types.Packet, err error) {
attrMap := make(map[string][]byte)
for _, attr := range event.Attributes {
attrMap[string(attr.Key)] = []byte(attr.Value)
}

sequence, err := strconv.Atoi(string(attrMap[string(types.AttributeKeySequence)]))
if err != nil {
return packet, err
}
timeoutTimestamp, err := strconv.Atoi(string(attrMap[string(types.AttributeKeyTimeoutTimestamp)]))
if err != nil {
return packet, err
}
timeoutHeight, err := clienttypes.ParseHeight(string(attrMap[string(types.AttributeKeyTimeoutHeight)]))
if err != nil {
return packet, err
}
return types.NewPacket(
attrMap[string(types.AttributeKeyData)], // data
uint64(sequence),
string(attrMap[string(types.AttributeKeySrcPort)]), // sourcePort,
string(attrMap[string(types.AttributeKeySrcChannel)]), // sourceChannel,
string(attrMap[string(types.AttributeKeyDstPort)]), // destinationPort,
string(attrMap[string(types.AttributeKeyDstChannel)]), // destinationChannel string,
timeoutHeight,
uint64(timeoutTimestamp),
), nil
}
20 changes: 20 additions & 0 deletions legacy_ibc_testing/core/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package core

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

/*
TODO: Remove after upgrading to ibc-go v5
legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only.
The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on.
These files will be deprecated once ICS is able to upgrade to ibc-go v5.
*/

type StakingKeeper interface {
GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)
UnbondingTime(ctx sdk.Context) time.Duration
}

0 comments on commit d324bf4

Please sign in to comment.