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

Add tests for the claims controller #514

Merged
merged 3 commits into from
Oct 29, 2021
Merged

Conversation

sgoya
Copy link
Contributor

@sgoya sgoya commented Oct 26, 2021

Added unit tests for all functions defined in the claims controller.

@CLAassistant
Copy link

CLAassistant commented Oct 26, 2021

CLA assistant check
All committers have signed the CLA.

@ethanfrey
Copy link
Member

Thanks for the contribution. @maurolacy could you review this?

Copy link
Contributor

@maurolacy maurolacy 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.

A couple more checks, and we are good to merge.

packages/controllers/src/claim.rs Show resolved Hide resolved
packages/controllers/src/claim.rs Show resolved Hide resolved
packages/controllers/src/claim.rs Show resolved Hide resolved
packages/controllers/src/claim.rs Show resolved Hide resolved
assert_eq!(saved_claims.len(), 1);
assert_eq!(saved_claims[0].amount, (TEST_AMOUNT + 100).into());
assert_eq!(saved_claims[0].release_at, Expiration::AtHeight(10));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼

Copy link
Contributor

@maurolacy maurolacy Oct 28, 2021

Choose a reason for hiding this comment

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

Similar to this, add a test where the cap allows to release only part of a claim (i.e. test_claim_tokens_with_cap_only_partial_amount_released()).

Let's say you have a mature claim for 100, but cap is 75.

Confirm / check that claim amounts are properly adjusted, and completed claims are removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the code partial claims are not claimed at all. So in the case when the cap is less than either of the claims nothing will be claimed. Adding a test case based on that.

packages/controllers/src/claim.rs Outdated Show resolved Hide resolved
packages/controllers/src/claim.rs Outdated Show resolved Hide resolved
packages/controllers/src/claim.rs Outdated Show resolved Hide resolved
@sgoya
Copy link
Contributor Author

sgoya commented Oct 28, 2021

@maurolacy Fixed the tests! Thanks for taking a look.

deps.as_mut().storage,
&Addr::unchecked("addr"),
&env.block,
Some((TEST_AMOUNT - 50).into()),
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼

Copy link
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

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

LGTM.

@maurolacy maurolacy merged commit 2401128 into CosmWasm:main Oct 29, 2021
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.

5 participants