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

Update the test wasm tx_write_storage_key to be able to write any arbitrary value #894

Merged
merged 12 commits into from
Feb 7, 2023

Conversation

james-chf
Copy link
Contributor

@james-chf james-chf commented Dec 14, 2022

This PR:

  • adds a namada_test_utils crate and a TxWriteData struct which contains a storage key and a value
  • renames tx_write_storage_key.wasm to tx_write.wasm
  • makes it so that tx_write.wasm can write any value to any key as specified in a TxWriteData

Motivation for this PR is to use it in #886, for writing arbitrary token::Amount values to balance keys in e2e tests.

Comment on lines 21 to 26
pub struct TxWriteData {
/// The storage key to be written to.
pub key: storage::Key,
/// The bytes to be written.
pub value: Vec<u8>,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where best to put this, it needs to be importable into both the namada_wasm_for_tests and namada_tests crates. Maybe a namada_test_utils crate like in #893, but have put this here for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the crate looks like a good idea! In the interim, I think you could put it behind cfg(feature = "testing"), but it's not enabled from wasm_tests yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this and having to use namada_core/testing in the namada_wasm_for_tests crate seems to break the wasm build somehow - probably via the pulling in of the rand crate. e.g.

 > make -C wasm_for_tests/wasm_source tx_write
cargo build --release --target wasm32-unknown-unknown --target-dir 'target' --features tx_write && \
        cp "./target/wasm32-unknown-unknown/release/namada_wasm_for_tests.wasm" ../tx_write.wasm
   Compiling num-traits v0.2.15
   Compiling tempfile v3.3.0
   Compiling wait-timeout v0.2.0
error[E0433]: failed to resolve: use of undeclared crate or module `imp`
  --> /Users/main/.cargo/registry/src/github.com-1ecc6299db9ec823/wait-timeout-0.2.0/src/lib.rs:66:9
   |
66 |         imp::wait_timeout(self, dur)
   |         ^^^ use of undeclared crate or module `imp`

For more information about this error, try `rustc --explain E0433`.

I can try out putting this in a namada_test_utils crate now since that should ultimately be less hacky.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put this in a namada_test_utils crate now

@james-chf
Copy link
Contributor Author

pls update wasm

@james-chf james-chf marked this pull request as ready for review December 16, 2022 13:22
@james-chf james-chf marked this pull request as draft January 3, 2023 10:48
@james-chf james-chf force-pushed the james/mainline/tx-write-storage-key branch 3 times, most recently from 6eeae29 to a3e50e7 Compare January 3, 2023 15:20
@james-chf james-chf marked this pull request as ready for review January 9, 2023 12:30
@juped juped added this to the 0.14 milestone Jan 10, 2023
@juped juped force-pushed the james/mainline/tx-write-storage-key branch from a3e50e7 to aee7ed3 Compare February 7, 2023 00:18
@juped juped merged commit 3050a14 into main Feb 7, 2023
@juped juped deleted the james/mainline/tx-write-storage-key branch February 7, 2023 01:49
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 this pull request may close these issues.

3 participants