Skip to content

Commit

Permalink
feat: test compute starknet address (#506)
Browse files Browse the repository at this point in the history
<!--- Please provide a general summary of your changes in the title
above -->
Resolves #477 
<!-- Give an estimate of the time you spent on this PR in terms of work
days. Did you spend 0.5 days on this PR or rather 2 days? -->

Time spent on this PR: 1.5 days

## Pull request type

<!-- Please try to limit your pull request to one type, submit multiple
pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->

Resolves #<Issue number>

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

-
-
-

## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

---------

Co-authored-by: Dragan Pilipovic <draganpilipovic@Dragans-MacBook-Pro.local>
  • Loading branch information
dragan2234 and Dragan Pilipovic committed Feb 23, 2023
1 parent e918a31 commit 3782780
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
extract_memory_from_execute,
extract_stack_from_execute,
hex_string_to_bytes_array,
generate_random_private_key,
)
from tests.utils.reporting import traceit

Expand Down Expand Up @@ -50,3 +51,25 @@ async def test_execute(
]
for event in sorted(res.call_info.events, key=lambda x: x.order)
] == events

class TestComputeStarknetAddress:
async def test_should_return_same_as_deployed_address(
self, kakarot: StarknetContract
):
private_key = generate_random_private_key()
evm_address = private_key.public_key.to_checksum_address()
eoa_deploy_tx = await kakarot.deploy_externally_owned_account(
int(evm_address, 16)
).execute()

kakarot_starknet_address = eoa_deploy_tx.call_info.internal_calls[
0
].contract_address

computed_starknet_address = (
await kakarot.compute_starknet_address(
evm_address=int(evm_address, 16)
).call()
).result[0]

assert kakarot_starknet_address == computed_starknet_address

0 comments on commit 3782780

Please sign in to comment.