Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable valid MockTx generation & move it's generation to mock crate (p…
…rivacy-scaling-explorations#701) * feat: Enable valid MockTx generation In order to be able to generate Tx objects with full customization possibilities and, at the same time, have consistent Txs with the correct hash and signatures, it was required an upgrade on the `MockTransaction` structure to allow for that. This includes the following: - Addition of `AddrOrWallet` enum to keep backwards compatibility and allow for simple Tx generations for Opcode testing purposes with just addresses or more complex cases where a Wallet is required so that the Tx can be correctly signed. - Refactor of the `MockTransaction` struct making some fields optional to preserve the compatibility with all other tests. - Refactor of the `MockTransaction::build` function to compute the signature and tx_hash only when it has not been specified and it is possible. This resolves privacy-scaling-explorations#677 bringing back the generation of Mock structures for testing to the mock crate and removing it from any other workspace member. * chore: Add docs for AddrOrWallet assoc methods * change: Replace Tx generations with rand_tx for MockTransaction * chore: Add ethers{signers,core} to mock deps * Update Cargo.lock * fix: hash & signature computation on build The computation of the hash and the signature params has to be done only if these params haven't been set already. This fixes it. Also, include & export 3 `MockTransaction`s correctly signed & hashed so that can be easily used by tests as it happens with the `MockAccount`s for example. * add: `MockWallet`s exported via mock crate * chore: Add rand_chacha & rand to deps * change: Update tests & benches to use mock's new methods * update: Cargo.lock * add: Conversion method from TxResponse and GethTransaction * fix: Fix sigdata params setting order in build fn * change: Use mock structs in tests instead of building them * fix: Clippy suggestions * fix: Do rlp for TransactionRequest instead of Transaction * fix: Remove unnecessary clone * fix: Complete the usage of From/Into for Transaction * fix: Address review comments * fix: Apply 2nd review round suggestions * feat: Enable valid MockTx generation In order to be able to generate Tx objects with full customization possibilities and, at the same time, have consistent Txs with the correct hash and signatures, it was required an upgrade on the `MockTransaction` structure to allow for that. This includes the following: - Addition of `AddrOrWallet` enum to keep backwards compatibility and allow for simple Tx generations for Opcode testing purposes with just addresses or more complex cases where a Wallet is required so that the Tx can be correctly signed. - Refactor of the `MockTransaction` struct making some fields optional to preserve the compatibility with all other tests. - Refactor of the `MockTransaction::build` function to compute the signature and tx_hash only when it has not been specified and it is possible. This resolves privacy-scaling-explorations#677 bringing back the generation of Mock structures for testing to the mock crate and removing it from any other workspace member. * chore: Add docs for AddrOrWallet assoc methods * change: Replace Tx generations with rand_tx for MockTransaction * chore: Add ethers{signers,core} to mock deps * Update Cargo.lock * fix: hash & signature computation on build The computation of the hash and the signature params has to be done only if these params haven't been set already. This fixes it. Also, include & export 3 `MockTransaction`s correctly signed & hashed so that can be easily used by tests as it happens with the `MockAccount`s for example. * add: `MockWallet`s exported via mock crate * chore: Add rand_chacha & rand to deps * change: Update tests & benches to use mock's new methods * update: Cargo.lock * add: Conversion method from TxResponse and GethTransaction * fix: Fix sigdata params setting order in build fn * change: Use mock structs in tests instead of building them * fix: Clippy suggestions * fix: Do rlp for TransactionRequest instead of Transaction * fix: Remove unnecessary clone * fix: Complete the usage of From/Into for Transaction * fix: Address review comments * fix: Apply 2nd review round suggestions * fix: Support SigData with all params set in MockTransaction::build
- Loading branch information