forked from cosmos/interchain-security
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added back in core ibc testing files
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 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
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 GitHub Actions / lint
|
||
|
||
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 GitHub Actions / lint
|
||
) | ||
|
||
/* | ||
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 | ||
} |
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,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 | ||
} |