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

implement store_code_with_id helper #22

Closed
Art3miX opened this issue Jan 18, 2023 · 3 comments · Fixed by #117
Closed

implement store_code_with_id helper #22

Art3miX opened this issue Jan 18, 2023 · 3 comments · Fixed by #117
Assignees
Milestone

Comments

@Art3miX
Copy link

Art3miX commented Jan 18, 2023

I'm working on a migrator contract which handles migrations of different contracts from V1 to V2, the V1 code ids are known and can be static inside the contract and I need to compare those with the given contracts to make sure im talking only with our modules, but with current store_code I can't test it with multi-test. (as a work around I am providing both code id sets from the front-end)

It can be done in 2 ways, either create another function store_code_with_id that will handle it specifically, or add an optional field of id to current store_code.

pub fn store_code_with_id(code, id)

We can store the highest provided code id in self.last_code_id, so "original" store_code() will be able to work, instead of using self.codes.len(), it will use the last_code_id.
Add a test that will check if the provided code id already exists results in an error.

It will cater to a specific use cases of testing contract code id against a static code id provided inside the contract, but those cases might increase as time pass on.

@DariuszDepta
Copy link
Member

Hi @Art3miX, is your case still relevant? If yes, would it be possible to take a look at your tests? Thanks in advance.

@DariuszDepta DariuszDepta added the question Further information is requested label Oct 5, 2023
@DariuszDepta
Copy link
Member

Hi @Art3miX, could you provide a link to your tests where you use this technique, just to have better understanding of your use-case? Maybe we can provide more general solution? Thanks in advance.

@DariuszDepta DariuszDepta removed the question Further information is requested label Dec 4, 2023
@DariuszDepta DariuszDepta added this to the 0.21.0 milestone Dec 4, 2023
@DariuszDepta DariuszDepta self-assigned this Dec 15, 2023
@DariuszDepta DariuszDepta modified the milestones: 0.21.0, 1.0.0 Dec 19, 2023
@Art3miX
Copy link
Author

Art3miX commented Dec 26, 2023

Hey @DariuszDepta, sorry for the late reply, totally missed this.

Here is the contract in question: https://github.com/DA0-DA0/dao-contracts/tree/development/contracts/external/dao-migrator
It is a migrator from v1 to v2 of Dao Dao, the v1 code ids are known and can be hardcoded into the code instead of passing any extra data.

Allowing setting a code id in test can make it possible to test those cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants