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

replace TestHandleSlashPacketDistribution w/ TestSlashUndelegation #633

Merged
merged 4 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,38 @@ func (s *CCVTestSuite) setupValidatorPowers() {
}
s.Require().Equal(int64(4000), stakingKeeper.GetLastTotalPower(s.providerCtx()).Int64())
}

// getHeightOfVSCPacketRecv returns the height of when the consumer received a VSCPacket.
// If expectedMaturityTimesLen > 0, then it's expected to find expectedMaturityTimesLen
// maturity times (i.e., VSCPakcets not yet matured). The vscID of the VSCPacket is retrieved
// from the maturity time with maturityTimesIndex.
func (s *CCVTestSuite) getHeightOfVSCPacketRecv(
bundle icstestingutils.ConsumerBundle,
expectedMaturityTimesLen int,
maturityTimesIndex int,
msgAndArgs ...interface{},
) (height uint64) {
maturityTimes := bundle.GetKeeper().GetAllPacketMaturityTimes(bundle.GetCtx())
if expectedMaturityTimesLen > 0 {
s.Require().Len(
maturityTimes,
expectedMaturityTimesLen,
fmt.Sprintf("unexpected number of maturity times; %s", msgAndArgs...),
)
}
vscID := maturityTimes[maturityTimesIndex].VscId
hToVSCids := bundle.GetKeeper().GetAllHeightToValsetUpdateIDs(bundle.GetCtx())
found := false
for _, hToVSCid := range hToVSCids {
if hToVSCid.ValsetUpdateId == vscID {
height = hToVSCid.Height
found = true
break
}
}
s.Require().True(
found,
fmt.Sprintf("cannot find height mapped to vscID; %s", msgAndArgs...),
)
return
}
Loading