kkrt-labs / kakarot-ssj

Kakarot zkEVM - rewrite in the latest version of Cairo
https://www.kakarot.org
MIT License
136 stars 82 forks source link

test: `fn get_starknet_address` #991

Closed enitrat closed 2 weeks ago

enitrat commented 3 weeks ago

test fn get_starknet_address to ensure

  1. if the address is registered in the mapping, it's returned
  2. if not, we return the result of the computation

the test will use starknet-foundry's "store" and "load" cheatcodes, as already used in: https://github.com/lordshashank/kakarot-ssj/blob/ed7e4145a0bb2517c60c6904fd317d11d1b00625/crates/contracts/tests/test_kakarot_core.cairo#L96-L131

The logic should be: for 1. you can just put any value in the mapping and verify it's returned for 2., make sure the mapping is empty, and that get_starknet_address returns the same as compute_starknet_address.

reserved for @saimeunt

Damilola145 commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello,I'm a front-end developer with a resolve to confront and solve new challenges. This alongside my experience will aid me in resolving this issue

How I plan on tackling this issue

I would carefully go through the github link highlighted to aid the implementation of the cheatcodes to resolve the issue, and also carry out the test as required

ScottyDavies commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchaindevelopereveloper

How I plan on tackling this issue

I would approach this issue with the following steps:

For Testing Address Registration: Add a value to the mapping. Verify that the expected value is returned when calling get_starknet_address.

For Testing Computation: Ensure the mapping is empty. Check that get_starknet_address returns the same value as compute_starknet_address.

saimeunt commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm a returning contributor and I have some experience in Cairo testing.

How I plan on tackling this issue

I will carefully implement the test as explained in the issue description.

akintewe commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have a degree in computer science and am a mobile developer with experience in TypeScript and Python, among other programming languages. Although I haven't worked with Cairo directly, I have a strong grasp of Starknet's architecture because to my experience developing smart contracts for other blockchain platforms. My background in test-driven development and unit testing in a variety of settings will be helpful in putting thorough tests for the get_starknet_address function in place.

How I plan on tackling this issue

I would begin by reviewing the current codebase, paying close attention to the test file you mentioned and the get_starknet_address method. With the cheatcodes from starknet-foundry, I would then write a new test function. In the first test case, I would use get_starknet_address and assert that it returns the stored value after adding a known address to the mapping using the "store" cheatcode. In order to validate that the results of get_starknet_address and compute_starknet_address are identical in the second scenario, I would first make sure the mapping is empty. Before submitting a pull request with the new test cases and any required documentation modifications, I would run the tests locally to make sure they pass.