-
Notifications
You must be signed in to change notification settings - Fork 625
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
feat(tests): add helper functions, keeper test suite. #7052
Conversation
testing/path.go
Outdated
@@ -162,6 +162,20 @@ func (path *Path) SetupClients() { | |||
} | |||
} | |||
|
|||
// SetupEurekaClients is a helper function to create clients supporting ibc-eureka on both | |||
// chains. It assumes the caller does not anticipate any errors. | |||
func (path *Path) SetupEurekaClients() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to reduce overall diffs, just named this with Eureka
, think we just rename old function to Classic
and change occurrences afterwards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like naming suggestion below SetupCounterparties
, nice to avoid introducing Eureka
when possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, Aditya will push that suggestion, ideally wanted a single setup function to get things ready but fair counterpoint re Eureka getting disseminated through-out code
} | ||
|
||
// TODO: Remove, just testing the testing setup. | ||
func (suite *KeeperTestSuite) TestCreateEurekaClients() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will rm before merge
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) | ||
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably be fine with two chains for handler testing. can be changed if necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restructuring suggestion.
Also let's remove reference to Eureka in function names and use V2 instead
testing/path.go
Outdated
@@ -162,6 +162,20 @@ func (path *Path) SetupClients() { | |||
} | |||
} | |||
|
|||
// SetupEurekaClients is a helper function to create clients supporting ibc-eureka on both | |||
// chains. It assumes the caller does not anticipate any errors. | |||
func (path *Path) SetupEurekaClients() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than doing this all in one step, let's keep SetupClients unchanged, and add a new function called SetupCounterparties
that does the provide counterparty for each side.
Then in our tests, we can setup like so:
path.SetupClients()
path.SetupCounterparties()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventually path.Setup()
will just do both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a SetupV2 that does both
Also we need the Packet-server keeper to be wired up in the app and made a public field so we can call it from We can modify |
@@ -165,6 +165,18 @@ func (endpoint *Endpoint) UpdateClient() (err error) { | |||
return endpoint.Chain.sendMsgs(msg) | |||
} | |||
|
|||
// ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. | |||
func (endpoint *Endpoint) ProvideCounterparty() (err error) { | |||
merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Endpoint
should probably be modified to have the merkle prefix now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, let's create an issue and do this later.
Think it should be added as a new field but this should be the default value that can then be malleated later by test writer
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) | ||
|
||
// commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) | ||
suite.coordinator.CommitNBlocks(suite.chainA, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? I think it might be legacy code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, good question, I see this through-out, might make sense to trim off through-out later in single PR.
@@ -8,14 +8,14 @@ import ( | |||
|
|||
type Keeper struct { | |||
cdc codec.BinaryCodec | |||
channelKeeper types.ChannelKeeper | |||
clientKeeper types.ClientKeeper | |||
ChannelKeeper types.ChannelKeeper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made this public so they were retrievable in testchains through the packetserver.
We already do this with IBCKeeper
@@ -16,7 +16,7 @@ type ChannelKeeper interface { | |||
GetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) []byte | |||
|
|||
// DeletePacketCommitment deletes the packet commitment hash under the commitment path | |||
DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) | |||
// DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this for now. Can be readded in future PR that needs it
@@ -370,6 +372,9 @@ func NewSimApp( | |||
appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), ibctm.NewConsensusHost(app.StakingKeeper), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), | |||
) | |||
|
|||
// Setup packet server to call on Eureka tests | |||
app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed this so that we can call into these functions from the TestChain struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we could also always create the PacketServer.Keeper struct on the fly using the IBCKeeper fields...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea but think this is perfectly fine for now, lets just add the testing boilerplate and refactor it later when needed
Quality Gate passed for 'ibc-go'Issues Measures |
@@ -162,6 +169,18 @@ func (path *Path) SetupClients() { | |||
} | |||
} | |||
|
|||
// SetupCounterparties is a helper function to set the counterparties supporting ibc-eureka on both | |||
// chains. It assumes the caller does not anticipate any errors. | |||
func (path *Path) SetupCounterparties() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this make sense as standalone func? I.e can't see where we'd invoke it separately without it being preceded by SetupClients
. We could possibly inline in SetupV2
, leaving as potential follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... yea I did it in case you wanted to SetupClients
, test X, Y, Z, then call SetCounterparties
after and do some more testing
thanks for follow up tweaks @AdityaSripal! Gonna merge this in a bit so we have it in handler branches. Think any follow ups can be addressed later to not block. |
Description
should probably do trick for keeper funcs for time being, testing package should need additional tweaks in future
closes: #XXXX
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.