Skip to content
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

Add tests with ambiguous enum to data transformer #2553

Open
integraledelebesgue opened this issue Oct 3, 2024 · 2 comments · May be fixed by #2872
Open

Add tests with ambiguous enum to data transformer #2553

integraledelebesgue opened this issue Oct 3, 2024 · 2 comments · May be fixed by #2872

Comments

@integraledelebesgue
Copy link
Member

integraledelebesgue commented Oct 3, 2024

Component the issue is related to

Cast - data transformer

Issue

Data transformer should throw an error in case of passing an ambiguous struct or enum name.
We test this behaviour for structs but tests for enums are lacking.
One need to create a new contract which uses an external enum and defines its own with identical name at the same time.

There is already an existing test for structs that can be seen here

async fn test_external_struct_function_ambiguous_struct_name_cairo_expression_input() {

Create a new test that tests ambigous enums, in similar manner as the test linked above.

Example and explanation:

Suppose we use Alexandria's BitArray type in our contract. We define our own struct with the same name and use it to.

#[starknet::contract]
mod Contract {
    /* ... */

    use alexandria_data_structures;

    pub struct BitArray { };

    fn method(
        self: @ContractState,
        external_type_array: alexandria_data_structures::bit_array::BitArray,
        our_own_type_array: BitArray
    ) { }
}

When calling method from CLI, we need to refer to these structures using paths:

sncast [...] --calldata "alexandria_data_structures::bit_array::BitArray { ... }" "data_transformer_contract::BitArray{ ... }"

When called without paths, Cast will throw an error:

Error while processing Cairo-like calldata:

Caused by:
    Found more than one struct "BitArray" in ABI, please specify a full path to the item
@danielrobotz
Copy link

I'd love to give this a go.

@khayss
Copy link
Contributor

khayss commented Jan 22, 2025

Could I take over this issue?

@khayss khayss linked a pull request Jan 24, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

4 participants