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

Improve simulation tests #771

Open
RiccardoM opened this issue Mar 9, 2022 · 0 comments
Open

Improve simulation tests #771

RiccardoM opened this issue Mar 9, 2022 · 0 comments
Labels
quality/tests Improves the test suite

Comments

@RiccardoM
Copy link
Contributor

Currently all the simulation tests are returning functions that implement the simtypes.Operation type:

// Operation runs a state machine transition, and ensures the transition
// happened as expected.  The operation could be running and testing a fuzzed
// transaction, or doing the same for a message.
//
// For ease of debugging, an operation returns a descriptive message "action",
// which details what this fuzzed state machine transition actually did.
//
// Operations can optionally provide a list of "FutureOperations" to run later
// These will be ran at the beginning of the corresponding block.
type Operation func(r *rand.Rand, app *baseapp.BaseApp,
	ctx sdk.Context, accounts []Account, chainID string) (
	OperationMsg OperationMsg, futureOps []FutureOperation, err error)

Even thought this type works properly the amount of parameters that requires is extremely large and causes the sim tests to look ugly and hard to maintain in the case some other data should be passed there instead. In order to solve this, I think we can encapsulate those values into a new Context type that can later be passed as the single parameter to the Operation type:

type Context struct {
  R *rand.Rand
  App *baseapp.BaseApp
  Ctx sdk.Context
  Accounts []Account
 ChainID string
}

type Operation func(ctx Context) (OperationMsg OperationMsg, futureOps []FutureOperation, err error)

This can be implemented directly inside the Cosmos SDK so that everyone can benefit from this

@RiccardoM RiccardoM added the quality/tests Improves the test suite label Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quality/tests Improves the test suite
Projects
None yet
Development

No branches or pull requests

1 participant