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

Test contract state after failing submsg #1540

Merged
merged 11 commits into from
Nov 13, 2023

Conversation

eshelB
Copy link
Contributor

@eshelB eshelB commented Sep 19, 2023

I wanted to make sure that submessages in contracts behave in the way stated by cosmwasm, in particular that the state of a contract A is saved even if it issues a submessage to contract B, which fails. only contract B's state should be reverted (edit: as long as the caller handles the reply).
There was no such test so I added one.
The flow of the test is as follows:
(contract:message)

  1. A:increment_and_send_submessage() # increments internal counter, sends quick_fail submessage to A
  2. A:quick_fail() # increments internal counter, fails.
  3. A:reply # returns internal counter in response data
    the response should be the original counter incremented by 1, as the first increment should take effect, but not the second one.

Edit: Second case: No handling of reply
Now the final result should be that of the submessage so everything should revert. But the revert of the main call does not happen in tests, because we create our own keeper. we check for presence of error, which tells sdk to revert in reality.

eshelB and others added 5 commits November 9, 2023 16:44
…tract-state-after-failing-bank-submsg

 Conflicts:
	cosmwasm/contracts/v1/compute-tests/test-compute-contract/src/contract.rs
…ing-bank-submsg

added another test where the submsg issues a failing bank message
@eshelB eshelB merged commit b098f51 into master Nov 13, 2023
@eshelB eshelB deleted the test-contract-state-after-failing-submsg branch November 13, 2023 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants