dojoengine / dojo

Dojo is a toolchain for building provable games and autonomous worlds with Cairo
https://dojoengine.org
Apache License 2.0
390 stars 148 forks source link

Unit tests for hash computations #1942

Open kariy opened 2 months ago

kariy commented 2 months ago

Write unit tests for all the hash computation functions in this module like so:

https://github.com/dojoengine/dojo/blob/5a7ecd8624a235c2b4e365d73612a952c0611716/crates/katana/primitives/src/utils/transaction.rs#L318-L323

The tests should use actual values from the live network (eg mainnet).

We need unit tests for:

Jonatan-Chaverri commented 2 months ago

Will like to take care of this one!

kariy commented 2 months ago

Will like to take care of this one!

assigned!

Jonatan-Chaverri commented 1 month ago

@kariy @glihm (or anybody who knows) I need help with this... how can I find real transactions on Voyager that match the criteria for every test? Deploy account, Declare and Invoke transactions, for v1, v2 and v3 for each... I'm I supposed to create those transactions?

kariy commented 1 month ago

@kariy @glihm (or anybody who knows) I need help with this... how can I find real transactions on Voyager that match the criteria for every test? Deploy account, Declare and Invoke transactions, for v1, v2 and v3 for each... I'm I supposed to create those transactions?

You can just pick any txs (of each type) on Voyager then take their hash and the tx data that are used as inputs for the tx hash computation.

For example, to compute a invoke tx hash you'd need these data:

https://github.com/dojoengine/dojo/blob/5a7ecd8624a235c2b4e365d73612a952c0611716/crates/katana/primitives/src/utils/transaction.rs#L187-L194

starknet docs for extra reference: https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/