-
Notifications
You must be signed in to change notification settings - Fork 87
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
V3 transactions in outside execution tests for argent #1554
base: development
Are you sure you want to change the base?
V3 transactions in outside execution tests for argent #1554
Conversation
* Added new argent contract v0.4.0 that supports transactions v3 (casm, json and abi) * Registered new factory for argent v040 injection in tests * Updated tests logic * Added new test that checks for new type of errors (Reentrancy introduced in argent v0.4.0) * Refacttored account creation logic in tests. I tried to keep changes to minimum, but could not help myself to introduce refactoring of a test account creation logic. For some reason those accounts were populated through dependency injection factories, which is ok, but at some point one factory got responsible for all possible types of accounts through same factory which over time got bloated with crotches. I moved all the crotch logic into `AccountToBeDeployedDetailsFactory` and want to propose to get rid of that class completely (well not in this PR) replacing it with obvious calls, like create_specific_account(), prepay_account(), this will make code straighforward and easy to read. Currently to understand what is happening in a particular test one need to hop through 3-5 layers of constructor injection calls. Fixes: 1546
@franciszekjob there might a minor fix for test. It will be one line maximum. Besides that good for review. |
tests on networks do not work, still. 8 ( |
@pytest.mark.asyncio | ||
async def test_argent_account_outside_execution_compatibility( | ||
argent_account: BaseAccount, | ||
argent_account_v040: BaseAccount, | ||
): | ||
result = await argent_account.supports_interface(OutsideExecutionInterfaceID.V1) | ||
assert result is True | ||
result = await argent_account.supports_interface(OutsideExecutionInterfaceID.V2) | ||
assert result is False | ||
|
||
result = await argent_account_v040.supports_interface( | ||
OutsideExecutionInterfaceID.V1 | ||
) | ||
assert result is True | ||
result = await argent_account_v040.supports_interface( | ||
OutsideExecutionInterfaceID.V2 | ||
) | ||
assert result is True |
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.
Could we change this test to be parametrized?
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.
I'm afraid it's not trivial due to dependency injection. I attempted to reduce amount of statements. please check.
assert any( | ||
[ | ||
await argent_account_v040.supports_interface( | ||
OutsideExecutionInterfaceID.V1 | ||
), | ||
await argent_account_v040.supports_interface( | ||
OutsideExecutionInterfaceID.V2 | ||
), | ||
] | ||
) |
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.
Is this needed?
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.
I think yes. But I see your suggest. Removing.
caller=ANY_CALLER, | ||
) | ||
|
||
tx = await argent_account_v040.execute_v1(calls=[call], max_fee=MAX_FEE) |
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.
Please use execute_v3
.
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.
Huh! How did those sneak in?! Thank you for catching.
starknet_py/tests/e2e/utils.py
Outdated
@@ -16,13 +16,28 @@ | |||
AccountToBeDeployedDetails = Tuple[int, KeyPair, int, int] | |||
|
|||
|
|||
async def get_deploy_account_details( | |||
*, | |||
def new_address( |
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.
That should be private function, _new_address
.
@baitcode thanks for quick replies 😄 will respond later today. |
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.
@baitcode looking good! 😄
l1_resource_bounds=ResourceBounds( | ||
max_amount=int(1e5), max_price_per_unit=int(1e13) | ||
), |
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.
nit: We can use MAX_RESOURCE_BOUNDS_L1
(same for other occurrences).
l1_resource_bounds=ResourceBounds( | |
max_amount=int(1e5), max_price_per_unit=int(1e13) | |
), | |
l1_resource_bounds=MAX_RESOURCE_BOUNDS_L1, |
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.
Thank you! It's good to know.
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 like it's not applied
@@ -384,6 +384,25 @@ async def argent_account_class_hash( | |||
) | |||
|
|||
|
|||
@pytest_asyncio.fixture(scope="package") | |||
async def argent_account_class_hash_v040( |
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.
nit:
async def argent_account_class_hash_v040( | |
async def argent_account_v040_class_hash( |
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.
applied
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.
I think it's stil the same 😅
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.
Yeah. Somehow lost that change.
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.
Thank you!
l1_resource_bounds=ResourceBounds( | ||
max_amount=int(1e5), max_price_per_unit=int(1e13) | ||
), |
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.
Same as above
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.
replaced in whole changeset.
@franciszekjob all fixed. |
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.
@baitcode not all nits have been applied 😅
@@ -384,6 +384,25 @@ async def argent_account_class_hash( | |||
) | |||
|
|||
|
|||
@pytest_asyncio.fixture(scope="package") | |||
async def argent_account_class_hash_v040( |
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.
I think it's stil the same 😅
l1_resource_bounds=ResourceBounds( | ||
max_amount=int(1e5), max_price_per_unit=int(1e13) | ||
), |
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 like it's not applied
@franciszekjob |
I didn't use apply on github. As the last time I did I then needed to manually add additional changes so I put everything into the commit. |
I've checked the changeset all changes are there. I'm investigating tests now. |
Yep. Found problem. Somehow lost one line of changes. Should be good now. @franciszekjob |
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.
Could you please link where exactly is this file taken from? I mean branch/tag in argent repo
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.
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.
main, latest commit.
deployments/artifacts/account-0.4.0-0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f
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.
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.
ohhhhhhh.
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.
@franciszekjob
Oh yes! My bad. I compiled those myself with pythonic hints enabled. This is the only difference between those.
Closes: #1546
Introduced changes
I tried to keep changes to minimum, but could not help myself to introduce refactoring of a test account creation logic. For some reason those accounts were populated through dependency injection factories, which is ok, but at some point one factory got responsible for all possible types of accounts through same factory which over time got bloated with crotches.
I moved all the crotch logic into
AccountToBeDeployedDetailsFactory
and want to propose to get rid of that class completely (well not in this PR) replacing it with obvious calls, like create_specific_account(), prepay_account(), this will make code straighforward and easy to read. Currently to understand what is happening in a particular test one need to hop through 3-5 layers of constructor injection calls.