CosmWasm / cw-multi-test

CosmWasm multi-contract testing framework
Apache License 2.0
48 stars 42 forks source link

Improved simple address generator #125

Closed DariuszDepta closed 9 months ago

DariuszDepta commented 9 months ago

Improved default implementation of AddressGenerator. Now the predictable address is constructed using creator address and salt. Please note, that this default simplistic implementation does not simulate the real blockchain address generator. Please consult this article to learn about other possibilities.

closes #122

kulikthebird commented 9 months ago

It's worth that the multi-test API would simulate the real chain's behavior. When it comes to predictible address, there's a method in cosmwasm-std that produces the address based on:

    checksum: &[u8],
    creator: &CanonicalAddr,
    salt: &[u8],

It means that we should not depend on instance counter to produce the predictable address. Other than that we should allow to produce conflicting addresses if the contract feeds the method with the identical input twice. Perhaps the solution to avoid conflicting addresses would be to encourage users to use random salt in contracts implementations..

DariuszDepta commented 9 months ago

Based this simple predictable address generator on creator address and salt.