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

Use module accounts in MsgSend and MsgMultiSend tests in bank module #9075

Merged
merged 19 commits into from
May 13, 2021

Conversation

cyberbono3
Copy link
Contributor

Description

My idea is to implement two methods TestSimulateModuleAccountMsgSend and TestSimulateModuleAccountMsgMultiSend() .
Instead of using getTestingAccounts I use getModuleAccounts to generate multiple module accounts. Then I use them here and catch an non nil error .

closes: #8818


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.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@cyberbono3 cyberbono3 requested a review from anilcse April 8, 2021 01:49
@amaury1093
Copy link
Contributor

amaury1093 commented Apr 16, 2021

@cyberbono3 Is there any progress on this PR? Do you need any help?

@codecov
Copy link

codecov bot commented Apr 19, 2021

Codecov Report

Merging #9075 (69f80ec) into master (e79157c) will increase coverage by 0.03%.
The diff coverage is 86.84%.

❗ Current head 69f80ec differs from pull request most recent head e726f9f. Consider uploading reports for the commit e726f9f to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9075      +/-   ##
==========================================
+ Coverage   60.33%   60.37%   +0.03%     
==========================================
  Files         585      585              
  Lines       36789    36851      +62     
==========================================
+ Hits        22195    22247      +52     
- Misses      12624    12630       +6     
- Partials     1970     1974       +4     
Impacted Files Coverage Δ
x/bank/simulation/operations.go 81.39% <86.84%> (+0.75%) ⬆️
simapp/simd/cmd/root.go 62.87% <0.00%> (+0.57%) ⬆️

@cyberbono3
Copy link
Contributor Author

@cyberbono3 Is there any progress on this PR? Do you need any help?

No, thanks. We had a pairing session with @anilcse , so I move forward.

var addr sdk.AccAddress

switch {
case r.Int()%2 == 0:
Copy link
Contributor Author

@cyberbono3 cyberbono3 Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added for loop here for simplicity and pick ModuleName in GetModuleAddress at random, depending on moduleAccCount. I am not quite sure if it makes sense.

@cyberbono3
Copy link
Contributor Author

cyberbono3 commented Apr 19, 2021

@anilcse Following our today discussion I tried to refactor SimulateMsgSend to handle both cases(recipient: ModuleAccount, Account). Unfortunately, my findings showed this would cause a lot of modifications in other modules. I have to add additional bool argument in Operation and apply these modifications in other modules which would take a lot of time. From my perspective, it does not make a lot of sense. What do u think?

@cyberbono3
Copy link
Contributor Author

@anilcse so should I introduce SimulateMsgMultiSendToModuleAccount based on logic of SimulateMsgSendToModuleAccount?

accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
simAccount := accs[0]
toSimAcc := accs[1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who and where defines accs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setupAccounts defines accs.

@cyberbono3 cyberbono3 self-assigned this Apr 22, 2021
@cyberbono3 cyberbono3 marked this pull request as ready for review April 22, 2021 01:18
Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@amaury1093
Copy link
Contributor

@robert-zaremba Would you have time to give another review to this PR? cc @anilcse @aleem1314 too, if you have bandwidth

Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. Added few cosmetic change suggestions. Also - let's use more variable seed for rand generator.

for i < len(outputs) {
if outputs[i].Coins.Empty() {
outputs[i] = outputs[len(outputs)-1]
outputs = outputs[:len(outputs)-1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice trick

return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
from := accs[0]
to := accs[1]

to := getModuleAccounts(ak, ctx, moduleAccCount)[0]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robert-zaremba I have implemented getModuleAccounts to generate module accounts. i hope it make sense for you.

@cyberbono3 cyberbono3 requested a review from robert-zaremba May 10, 2021 18:35
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK, left few minor comments / suggestions.

@aaronc aaronc added the A:automerge Automatically merge PR once all prerequisites pass. label May 11, 2021
@aaronc
Copy link
Member

aaronc commented May 11, 2021

Looks like there are some failing checks here @cyberbono3

@mergify mergify bot merged commit 8997074 into master May 13, 2021
@mergify mergify bot deleted the cyberbono3/8818-use-module-accs branch May 13, 2021 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:Simulations C:x/bank
Projects
None yet
Development

Successfully merging this pull request may close these issues.

simulation: use module accounts
7 participants