-
Notifications
You must be signed in to change notification settings - Fork 1
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
26 use runtime managed erc20 tokens in tests #27
26 use runtime managed erc20 tokens in tests #27
Conversation
3a8f809
to
bdd03de
Compare
bdd03de
to
480962f
Compare
51d35f6
to
fe01d54
Compare
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.
Looks good to me overall but left some comments.
@@ -118,17 +120,30 @@ export default async function (environment: TestSuiteEnvironment) { | |||
await backstop.addSwapPool(address(swapPool1), 0); | |||
await backstop.addSwapPool(address(swapPool2), 0); | |||
|
|||
|
|||
await asset1.burn(tester, await asset1.balanceOf(tester)); |
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.
Why do we have to burn
before we mint
?
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.
If this is related to
Specifically cleaning token balances before execution of the tests and modifying time delay for swapExecution.
Maybe we should find a clearer way to do this? How about a teardown function, or we add cleanup-related code to the end of each test? Otherwise we should maybe at least add a comment that explains why we burn before we mint.
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.
Indeed this is just to ensure that the balance of the tokens for the relevant accounts is 0 before the mint and at the end of this setUp()
function we have only the expected minted amount.
I will add some comments to clarify this, but I don't think we should add another function since we are already in the setUp()
function and this is the cleanup for a test that came before (if any), let me know it makes sense @ebma.
BTW, it is true that perhaps a teardown at the end also makes sense, but given that the tests stops if there is an error, as of now I don't think there is a way to actually make sure that the teardown actually runs. That's why I think for now cleaning just in case in the setUp makes more sense.
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.
Right, I see your point. Although we don't support 'teardown' functions yet, we could just try to execute them (if any) in a new finally {}
block at the end of the try-catch here. This way it will be executed in any case.
I'm also fine with your existing implementation actually, the only thing that bothers me a bit is that the comment reasoning why we need to burn before minting is only included in one file. And I see why since copy-pasting it into any file is annoying. But with a teardown function for each test, it might be self-explanatory enough that we don't even need a comment in the first place. WDYT?
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.
Yes I agree that would be the better approach. Could we perhaps open a separate issue and wait for this one? Since it would be touching a separate part of the code logic not just the tests but also how they run.
In the meantime if you are okay with it I can just copy the comment to all the setups so we don't forget what is going on.
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.
Sounds good 👍 could you create that follow-up ticket?
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.
Sure!
@@ -118,17 +120,30 @@ export default async function (environment: TestSuiteEnvironment) { | |||
await backstop.addSwapPool(address(swapPool1), 0); | |||
await backstop.addSwapPool(address(swapPool2), 0); | |||
|
|||
|
|||
await asset1.burn(tester, await asset1.balanceOf(tester)); |
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.
Right, I see your point. Although we don't support 'teardown' functions yet, we could just try to execute them (if any) in a new finally {}
block at the end of the try-catch here. This way it will be executed in any case.
I'm also fine with your existing implementation actually, the only thing that bothers me a bit is that the comment reasoning why we need to burn before minting is only included in one file. And I see why since copy-pasting it into any file is annoying. But with a teardown function for each test, it might be self-explanatory enough that we don't even need a comment in the first place. WDYT?
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
@gianfra-t you can merge this now if you don't want to add anything. Usually, the author of the PR merges it once approved, because sometimes it might be that the author still wants to add something after it got approved by someone else which would be missed if the reviewer merges it. |
Issue: #26.
Replaced the dependency on MockERC20 for TestableERC20 contract that interacts with the standalone chain during tests.
The tests were modified accordingly to work in this manner. Specifically cleaning token balances before execution of the tests and modifying time delay for swapExecution. Also added a test specific to the TestableERC20Wrapper.
The corresponding modifications for foucococo-standalone and pendulum-wrappers for this to work were made here and here respectively.