-
Notifications
You must be signed in to change notification settings - Fork 592
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
chore: Refactor and Add tests for AddToExistingLock
#1979
Conversation
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.
Nice work. I worry that we might be returning an old lock from AddToExistingLock
. Could you please confirm if that is the case?
We should make assertions on the contents of the lock returned by AddToExistingLock
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.
New return with lock id LGTM, nice work!
On another look, thought about adding an extra check. Let me know what you think
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.
All my comments/questions have been addressed – LGTM!
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.
LGTM - thanks for fighting all the weird edge cases!
I think that it makes sense to return an error when there are no locks in AddToExistingLock
, despite this change being state-breaking. However, leaving the final call to you @mattverse 👍
agreed with you on adding error when there's no lock druing |
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
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.
LGTM. Thanks for working out all edge cases here @mattverse
// curBalance := suite.App.BankKeeper.GetAllBalances(cacheCtx, addr1) | ||
_, err = suite.App.LockupKeeper.AddTokensToLockByID(cacheCtx, 1111, addr1, addCoins) | ||
suite.Require().Error(err) | ||
if tc.expectAddTokensToLockSuccess { |
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.
What is the difference between expectError
and expectAddTokensToLockSuccess
? Can we use only expectError
?
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.
good catch, the original intent was to create a separate case for lock failing and adding to lock failing, but these can be grouped to one. Changed to removing the field!
Co-authored-by: Roman <roman@osmosis.team>
…-labs/osmosis into mattverse/lock-testing-2
sub-component of: #1838
What is the purpose of the change
AddToExistingLock
had a bad design of returning array of locks, and then only using the first index out of the given array.There's no need to return an array here, but simply return the lock that we've added the token to. This PR changes the returning values of
AddToExistingLock
from an array to a single lock(not pointer referenced).This PR also includes changing tests for
AddToExistingLock
to be TDD, adding some edge cases to the tests.Brief Changelog
AddToExistingLock
AddToExistingLock
to be TDDTesting and Verifying
This change added tests
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? no