diff --git a/.changelog/unreleased/testing/893-namada-test-utils-wasms.md b/.changelog/unreleased/testing/893-namada-test-utils-wasms.md new file mode 100644 index 0000000000..a345f0b8e5 --- /dev/null +++ b/.changelog/unreleased/testing/893-namada-test-utils-wasms.md @@ -0,0 +1,2 @@ +- Add utility code for working with test wasms + ([#893](https://github.com/anoma/namada/pull/893)) \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 8aba5b5646..849378d1b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2518,6 +2518,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -3647,6 +3653,7 @@ dependencies = [ "masp_proofs", "namada_core", "namada_proof_of_stake", + "namada_test_utils", "parity-wasm", "paste", "pretty_assertions", @@ -3714,6 +3721,7 @@ dependencies = [ "masp_primitives", "masp_proofs", "namada", + "namada_test_utils", "num-derive", "num-traits 0.2.15", "num_cpus", @@ -3862,6 +3870,7 @@ version = "0.14.0" dependencies = [ "borsh", "namada_core", + "strum", ] [[package]] @@ -4720,7 +4729,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5" dependencies = [ "bytes 1.2.1", - "heck", + "heck 0.3.3", "itertools", "lazy_static", "log 0.4.17", @@ -6001,6 +6010,28 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "subproductdomain" version = "0.1.0" diff --git a/apps/Cargo.toml b/apps/Cargo.toml index f1bf95a05d..e4e42c68d3 100644 --- a/apps/Cargo.toml +++ b/apps/Cargo.toml @@ -154,6 +154,7 @@ rust_decimal_macros = "1.26.1" [dev-dependencies] namada = {path = "../shared", default-features = false, features = ["testing", "wasm-runtime"]} +namada_test_utils = {path = "../test_utils"} bit-set = "0.5.2" # A fork with state machime testing proptest = {git = "https://github.com/heliaxdev/proptest", branch = "tomas/sm"} diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index e37f7bb27b..d03a27a729 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -472,6 +472,7 @@ mod test_finalize_block { InitProposalData, VoteProposalData, }; use namada::types::transaction::{EncryptionKey, Fee, WrapperTx, MIN_FEE}; + use namada_test_utils::TestWasms; use super::*; use crate::node::ledger::shell::test_utils::*; @@ -703,10 +704,7 @@ mod test_finalize_block { .unwrap(); // create two decrypted txs - let mut wasm_path = top_level_directory(); - wasm_path.push("wasm_for_tests/tx_no_op.wasm"); - let tx_code = std::fs::read(wasm_path) - .expect("Expected a file at given code path"); + let tx_code = TestWasms::TxNoOp.read_bytes(); for i in 0..2 { let raw_tx = Tx::new( tx_code.clone(), diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 91e8fee219..20f297a457 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -135,6 +135,7 @@ assert_matches = "1.5.0" async-trait = {version = "0.1.51"} byte-unit = "4.0.13" libsecp256k1 = {git = "https://github.com/heliaxdev/libsecp256k1", rev = "bbb3bd44a49db361f21d9db80f9a087c194c0ae9"} +namada_test_utils = {path = "../test_utils"} pretty_assertions = "0.7.2" # A fork with state machine testing proptest = {git = "https://github.com/heliaxdev/proptest", branch = "tomas/sm"} diff --git a/shared/src/ledger/queries/shell.rs b/shared/src/ledger/queries/shell.rs index 43a51a1b0f..b81c0542c4 100644 --- a/shared/src/ledger/queries/shell.rs +++ b/shared/src/ledger/queries/shell.rs @@ -344,6 +344,7 @@ where #[cfg(test)] mod test { use borsh::BorshDeserialize; + use namada_test_utils::TestWasms; use crate::ledger::queries::testing::TestClient; use crate::ledger::queries::RPC; @@ -351,8 +352,6 @@ mod test { use crate::proto::Tx; use crate::types::{address, token}; - const TX_NO_OP_WASM: &str = "../wasm_for_tests/tx_no_op.wasm"; - #[test] fn test_shell_queries_router_paths() { let path = RPC.shell().epoch_path(); @@ -386,7 +385,7 @@ mod test { assert_eq!(current_epoch, read_epoch); // Request dry run tx - let tx_no_op = std::fs::read(TX_NO_OP_WASM).expect("cannot load wasm"); + let tx_no_op = TestWasms::TxNoOp.read_bytes(); let tx = Tx::new(tx_no_op, None); let tx_bytes = tx.to_bytes(); let result = RPC diff --git a/shared/src/vm/wasm/compilation_cache/common.rs b/shared/src/vm/wasm/compilation_cache/common.rs index 9f25d573c4..9aa34b0601 100644 --- a/shared/src/vm/wasm/compilation_cache/common.rs +++ b/shared/src/vm/wasm/compilation_cache/common.rs @@ -557,23 +557,18 @@ mod test { use std::cmp::max; use byte_unit::Byte; + use namada_test_utils::TestWasms; use tempfile::{tempdir, TempDir}; use test_log::test; use super::*; use crate::vm::WasmCacheRwAccess; - const TX_NO_OP: &str = "../wasm_for_tests/tx_no_op.wasm"; - const TX_READ_STORAGE_KEY: &str = - "../wasm_for_tests/tx_read_storage_key.wasm"; - const VP_ALWAYS_TRUE: &str = "../wasm_for_tests/vp_always_true.wasm"; - const VP_EVAL: &str = "../wasm_for_tests/vp_eval.wasm"; - #[test] fn test_fetch_or_compile_valid_wasm() { // Load some WASMs and find their hashes and in-memory size - let tx_read_storage_key = load_wasm(TX_READ_STORAGE_KEY); - let tx_no_op = load_wasm(TX_NO_OP); + let tx_read_storage_key = load_wasm(TestWasms::TxReadStorageKey.path()); + let tx_no_op = load_wasm(TestWasms::TxNoOp.path()); // Create a new cache with the limit set to // `max(tx_read_storage_key.size, tx_no_op.size) + 1` @@ -789,8 +784,8 @@ mod test { #[test] fn test_pre_compile_valid_wasm() { // Load some WASMs and find their hashes and in-memory size - let vp_always_true = load_wasm(VP_ALWAYS_TRUE); - let vp_eval = load_wasm(VP_EVAL); + let vp_always_true = load_wasm(TestWasms::VpAlwaysTrue.path()); + let vp_eval = load_wasm(TestWasms::VpEval.path()); // Create a new cache with the limit set to // `max(vp_always_true.size, vp_eval.size) + 1 + extra_bytes` @@ -933,7 +928,7 @@ mod test { } /// Get the WASM code bytes, its hash and find the compiled module's size - fn load_wasm(file: impl AsRef) -> WasmWithMeta { + fn load_wasm(file: impl AsRef) -> WasmWithMeta { // When `WeightScale` calls `loupe::size_of_val` in the cache, for some // reason it returns 8 bytes more than the same call in here. let extra_bytes = 8; @@ -952,7 +947,7 @@ mod test { }; println!( "Compiled module {} size including the hash: {} ({})", - file, + file.to_string_lossy(), Byte::from_bytes(size as u128).get_appropriate_unit(true), size, ); diff --git a/shared/src/vm/wasm/run.rs b/shared/src/vm/wasm/run.rs index 0efdac499c..5bb33441c1 100644 --- a/shared/src/vm/wasm/run.rs +++ b/shared/src/vm/wasm/run.rs @@ -409,6 +409,7 @@ fn get_gas_rules() -> rules::Set { mod tests { use borsh::BorshSerialize; use itertools::Either; + use namada_test_utils::TestWasms; use test_log::test; use wasmer_vm::TrapCode; @@ -417,16 +418,6 @@ mod tests { use crate::types::validity_predicate::EvalVp; use crate::vm::wasm; - const TX_MEMORY_LIMIT_WASM: &str = "../wasm_for_tests/tx_memory_limit.wasm"; - const TX_NO_OP_WASM: &str = "../wasm_for_tests/tx_no_op.wasm"; - const TX_READ_STORAGE_KEY_WASM: &str = - "../wasm_for_tests/tx_read_storage_key.wasm"; - const VP_ALWAYS_TRUE_WASM: &str = "../wasm_for_tests/vp_always_true.wasm"; - const VP_EVAL_WASM: &str = "../wasm_for_tests/vp_eval.wasm"; - const VP_MEMORY_LIMIT_WASM: &str = "../wasm_for_tests/vp_memory_limit.wasm"; - const VP_READ_STORAGE_KEY_WASM: &str = - "../wasm_for_tests/vp_read_storage_key.wasm"; - /// Test that when a transaction wasm goes over the stack-height limit, the /// execution is aborted. #[test] @@ -477,8 +468,7 @@ mod tests { let tx_index = TxIndex::default(); // This code will allocate memory of the given size - let tx_code = - std::fs::read(TX_MEMORY_LIMIT_WASM).expect("cannot load wasm"); + let tx_code = TestWasms::TxMemoryLimit.read_bytes(); // Assuming 200 pages, 12.8 MiB limit assert_eq!(memory::TX_MEMORY_MAX_PAGES, 200); @@ -534,10 +524,9 @@ mod tests { let tx_index = TxIndex::default(); // This code will call `eval` with the other VP below - let vp_eval = std::fs::read(VP_EVAL_WASM).expect("cannot load wasm"); + let vp_eval = TestWasms::VpEval.read_bytes(); // This code will allocate memory of the given size - let vp_memory_limit = - std::fs::read(VP_MEMORY_LIMIT_WASM).expect("cannot load wasm"); + let vp_memory_limit = TestWasms::VpMemoryLimit.read_bytes(); // Assuming 200 pages, 12.8 MiB limit assert_eq!(memory::VP_MEMORY_MAX_PAGES, 200); @@ -615,8 +604,7 @@ mod tests { let tx_index = TxIndex::default(); // This code will allocate memory of the given size - let vp_code = - std::fs::read(VP_MEMORY_LIMIT_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpMemoryLimit.read_bytes(); // Assuming 200 pages, 12.8 MiB limit assert_eq!(memory::VP_MEMORY_MAX_PAGES, 200); @@ -674,7 +662,7 @@ mod tests { let mut gas_meter = BlockGasMeter::default(); let tx_index = TxIndex::default(); - let tx_no_op = std::fs::read(TX_NO_OP_WASM).expect("cannot load wasm"); + let tx_no_op = TestWasms::TxNoOp.read_bytes(); // Assuming 200 pages, 12.8 MiB limit assert_eq!(memory::TX_MEMORY_MAX_PAGES, 200); @@ -728,8 +716,7 @@ mod tests { let verifiers = BTreeSet::new(); let tx_index = TxIndex::default(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Assuming 200 pages, 12.8 MiB limit assert_eq!(memory::VP_MEMORY_MAX_PAGES, 200); @@ -785,8 +772,7 @@ mod tests { let mut gas_meter = BlockGasMeter::default(); let tx_index = TxIndex::default(); - let tx_read_key = - std::fs::read(TX_READ_STORAGE_KEY_WASM).expect("cannot load wasm"); + let tx_read_key = TestWasms::TxReadStorageKey.read_bytes(); // Allocating `2^24` (16 MiB) for a value in storage that the tx // attempts to read should be above the memory limit and should @@ -832,8 +818,7 @@ mod tests { let verifiers = BTreeSet::new(); let tx_index = TxIndex::default(); - let vp_read_key = - std::fs::read(VP_READ_STORAGE_KEY_WASM).expect("cannot load wasm"); + let vp_read_key = TestWasms::VpReadStorageKey.read_bytes(); // Allocating `2^24` (16 MiB) for a value in storage that the tx // attempts to read should be above the memory limit and should @@ -883,10 +868,9 @@ mod tests { let tx_index = TxIndex::default(); // This code will call `eval` with the other VP below - let vp_eval = std::fs::read(VP_EVAL_WASM).expect("cannot load wasm"); + let vp_eval = TestWasms::VpEval.read_bytes(); // This code will read value from the storage - let vp_read_key = - std::fs::read(VP_READ_STORAGE_KEY_WASM).expect("cannot load wasm"); + let vp_read_key = TestWasms::VpReadStorageKey.read_bytes(); // Allocating `2^24` (16 MiB) for a value in storage that the tx // attempts to read should be above the memory limit and should diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index f75733663b..febb98cddb 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -9,3 +9,4 @@ version = "0.14.0" [dependencies] borsh = "0.9.0" namada_core = { path = "../core" } +strum = {version = "0.24", features = ["derive"]} diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index c2a3b13653..6b0352bcc7 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -1 +1,96 @@ +//! Utilities for use in tests. + pub mod tx_data; + +use std::env; +use std::path::PathBuf; + +use strum::EnumIter; + +/// Path from the root of the Git repo to the directory under which built test +/// wasms can be found. +pub const WASM_FOR_TESTS_DIR: &str = "wasm_for_tests"; + +/// Corresponds to wasms that we build for tests, under [`WASM_FOR_TESTS_DIR`]. +/// See the `wasm_for_tests/wasm_source` crate for documentation on what these +/// wasms do. +#[allow(missing_docs)] +#[derive(Debug, Clone, Copy, EnumIter)] +pub enum TestWasms { + TxMemoryLimit, + TxMintTokens, + TxNoOp, + TxProposalCode, + TxReadStorageKey, + TxWriteStorageKey, + VpAlwaysFalse, + VpAlwaysTrue, + VpEval, + VpMemoryLimit, + VpReadStorageKey, +} + +impl TestWasms { + /// Get the path to where this test wasm is expected to be, or panic if not + /// able to. + pub fn path(&self) -> PathBuf { + let filename = match self { + TestWasms::TxMemoryLimit => "tx_memory_limit.wasm", + TestWasms::TxMintTokens => "tx_mint_tokens.wasm", + TestWasms::TxNoOp => "tx_no_op.wasm", + TestWasms::TxProposalCode => "tx_proposal_code.wasm", + TestWasms::TxReadStorageKey => "tx_read_storage_key.wasm", + TestWasms::TxWriteStorageKey => "tx_write.wasm", + TestWasms::VpAlwaysFalse => "vp_always_false.wasm", + TestWasms::VpAlwaysTrue => "vp_always_true.wasm", + TestWasms::VpEval => "vp_eval.wasm", + TestWasms::VpMemoryLimit => "vp_memory_limit.wasm", + TestWasms::VpReadStorageKey => "vp_read_storage_key.wasm", + }; + let cwd = + env::current_dir().expect("Couldn't get current working directory"); + // crudely find the root of the repo, we can't rely on the `.git` + // directory being present, so look instead for the presence of a + // CHANGELOG.md file + let repo_root = cwd + .ancestors() + .find(|path| path.join("CHANGELOG.md").exists()) + .unwrap_or_else(|| { + panic!( + "Couldn't find the root of the repository for the current \ + working directory {}", + cwd.to_string_lossy() + ) + }); + repo_root.join(WASM_FOR_TESTS_DIR).join(filename) + } + + /// Attempts to read the contents of this test wasm. Panics if it is not + /// able to for any reason. + pub fn read_bytes(&self) -> Vec { + let path = self.path(); + std::fs::read(&path).unwrap_or_else(|err| { + panic!( + "Could not read wasm at path {}: {:?}", + path.to_string_lossy(), + err + ) + }) + } +} + +#[cfg(test)] +mod tests { + use strum::IntoEnumIterator; + + use super::*; + + #[test] + /// Tests that all expected test wasms are present on disk. + fn test_wasms_path() { + for test_wasm in TestWasms::iter() { + let path = test_wasm.path(); + assert!(path.exists()); + } + } +} diff --git a/tests/src/e2e/eth_bridge_tests.rs b/tests/src/e2e/eth_bridge_tests.rs index fe97731b22..f6c14ad3d1 100644 --- a/tests/src/e2e/eth_bridge_tests.rs +++ b/tests/src/e2e/eth_bridge_tests.rs @@ -3,10 +3,11 @@ use namada::ledger::eth_bridge; use namada_core::types::storage; use namada_core::types::storage::KeySeg; use namada_test_utils::tx_data::TxWriteData; +use namada_test_utils::TestWasms; use crate::e2e::helpers::get_actor_rpc; use crate::e2e::setup; -use crate::e2e::setup::constants::{wasm_abs_path, ALBERT, TX_WRITE_WASM}; +use crate::e2e::setup::constants::ALBERT; use crate::e2e::setup::{Bin, Who}; use crate::{run, run_as}; @@ -49,7 +50,7 @@ fn everything() { ) .unwrap(); - let tx_code_path = wasm_abs_path(TX_WRITE_WASM); + let tx_code_path = TestWasms::TxWriteStorageKey.path(); let tx_data_path = tx_data_path.to_string_lossy().to_string(); let tx_code_path = tx_code_path.to_string_lossy().to_string(); diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index 9437103546..361c0ecfed 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -26,6 +26,7 @@ use namada_apps::client::tx::ShieldedContext; use namada_apps::config::genesis::genesis_config::{ GenesisConfig, ParametersConfig, PosParamsConfig, }; +use namada_test_utils::TestWasms; use serde_json::json; use setup::constants::*; @@ -292,7 +293,7 @@ fn ledger_txs_and_queries() -> Result<()> { let vp_user = wasm_abs_path(VP_USER_WASM); let vp_user = vp_user.to_string_lossy(); - let tx_no_op = wasm_abs_path(TX_NO_OP_WASM); + let tx_no_op = TestWasms::TxNoOp.path(); let tx_no_op = tx_no_op.to_string_lossy(); let validator_one_rpc = get_actor_rpc(&test, &Who::Validator(0)); @@ -1674,7 +1675,7 @@ fn invalid_transactions() -> Result<()> { let data = transfer .try_to_vec() .expect("Encoding unsigned transfer shouldn't fail"); - let tx_wasm_path = wasm_abs_path(TX_MINT_TOKENS_WASM); + let tx_wasm_path = TestWasms::TxMintTokens.path(); std::fs::write(&tx_data_path, data).unwrap(); let tx_wasm_path = tx_wasm_path.to_string_lossy(); let tx_data_path = tx_data_path.to_string_lossy(); @@ -3437,7 +3438,7 @@ fn implicit_account_reveal_pk() -> Result<()> { /// Prepare proposal data in the test's temp dir from the given source address. /// This can be submitted with "init-proposal" command. fn prepare_proposal_data(test: &setup::Test, source: Address) -> PathBuf { - let proposal_code = wasm_abs_path(TX_PROPOSAL_CODE); + let proposal_code = TestWasms::TxProposalCode.path(); let valid_proposal_json = json!( { "content": { diff --git a/tests/src/e2e/multitoken_tests/helpers.rs b/tests/src/e2e/multitoken_tests/helpers.rs index fb1138ca82..7008910b5e 100644 --- a/tests/src/e2e/multitoken_tests/helpers.rs +++ b/tests/src/e2e/multitoken_tests/helpers.rs @@ -8,13 +8,14 @@ use eyre::Context; use namada_core::types::address::Address; use namada_core::types::{storage, token}; use namada_test_utils::tx_data::TxWriteData; +use namada_test_utils::TestWasms; use namada_tx_prelude::storage::KeySeg; use rand::Rng; use regex::Regex; -use super::setup::constants::{wasm_abs_path, NAM, VP_ALWAYS_TRUE_WASM}; +use super::setup::constants::NAM; use super::setup::{Bin, NamadaCmd, Test}; -use crate::e2e::setup::constants::{ALBERT, TX_WRITE_WASM}; +use crate::e2e::setup::constants::ALBERT; use crate::run; const MULTITOKEN_KEY_SEGMENT: &str = "tokens"; @@ -29,9 +30,8 @@ pub fn init_multitoken_vp(test: &Test, rpc_addr: &str) -> Result { // we use a VP that always returns true for the multitoken VP here, as we // are testing out the VPs of the sender and receiver of multitoken // transactions here - not any multitoken VP itself - let multitoken_vp_wasm_path = wasm_abs_path(VP_ALWAYS_TRUE_WASM) - .to_string_lossy() - .to_string(); + let multitoken_vp_wasm_path = + TestWasms::VpAlwaysTrue.path().to_string_lossy().to_string(); let multitoken_alias = "multitoken"; let init_account_args = vec![ @@ -99,7 +99,7 @@ pub fn mint_red_tokens( .push(&BALANCE_KEY_SEGMENT.to_owned())? .push(owner)?; - let tx_code_path = wasm_abs_path(TX_WRITE_WASM); + let tx_code_path = TestWasms::TxWriteStorageKey.path(); let tx_data_path = write_test_file( test, TxWriteData { diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index daa4db4dd7..d79f75a8cb 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -832,15 +832,7 @@ pub mod constants { // Paths to the WASMs used for tests pub const TX_TRANSFER_WASM: &str = "wasm/tx_transfer.wasm"; pub const VP_USER_WASM: &str = "wasm/vp_user.wasm"; - pub const TX_NO_OP_WASM: &str = "wasm_for_tests/tx_no_op.wasm"; - pub const TX_INIT_PROPOSAL: &str = "wasm_for_tests/tx_init_proposal.wasm"; - pub const TX_WRITE_WASM: &str = "wasm_for_tests/tx_write.wasm"; pub const TX_IBC_WASM: &str = "wasm/tx_ibc.wasm"; - pub const VP_ALWAYS_TRUE_WASM: &str = "wasm_for_tests/vp_always_true.wasm"; - pub const VP_ALWAYS_FALSE_WASM: &str = - "wasm_for_tests/vp_always_false.wasm"; - pub const TX_MINT_TOKENS_WASM: &str = "wasm_for_tests/tx_mint_tokens.wasm"; - pub const TX_PROPOSAL_CODE: &str = "wasm_for_tests/tx_proposal_code.wasm"; /// Find the absolute path to one of the WASM files above pub fn wasm_abs_path(file_name: &str) -> PathBuf { diff --git a/tests/src/vm_host_env/ibc.rs b/tests/src/vm_host_env/ibc.rs index 1e60480186..beeee511ed 100644 --- a/tests/src/vm_host_env/ibc.rs +++ b/tests/src/vm_host_env/ibc.rs @@ -68,11 +68,11 @@ use namada::types::ibc::data::{FungibleTokenPacketData, PacketAck}; use namada::types::storage::{self, BlockHash, BlockHeight, Key, TxIndex}; use namada::types::token::{self, Amount}; use namada::vm::{wasm, WasmCacheRwAccess}; +use namada_test_utils::TestWasms; use namada_tx_prelude::StorageWrite; use crate::tx::{self, *}; -const VP_ALWAYS_TRUE_WASM: &str = "../wasm_for_tests/vp_always_true.wasm"; const ADDRESS: Address = Address::Internal(InternalAddress::Ibc); pub struct TestIbcVp<'a> { @@ -196,7 +196,7 @@ pub fn init_storage() -> (Address, Address) { }); // initialize a token - let code = std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let code = TestWasms::VpAlwaysTrue.read_bytes(); let token = tx::ctx().init_account(code.clone()).unwrap(); // initialize an account diff --git a/tests/src/vm_host_env/mod.rs b/tests/src/vm_host_env/mod.rs index 04a545e8b1..cbdfe08342 100644 --- a/tests/src/vm_host_env/mod.rs +++ b/tests/src/vm_host_env/mod.rs @@ -35,6 +35,7 @@ mod tests { use namada::types::time::DateTimeUtc; use namada::types::token::{self, Amount}; use namada::types::{address, key}; + use namada_test_utils::TestWasms; use namada_tx_prelude::{ BorshDeserialize, BorshSerialize, StorageRead, StorageWrite, }; @@ -46,10 +47,6 @@ mod tests { use crate::tx::{tx_host_env, TestTxEnv}; use crate::vp::{vp_host_env, TestVpEnv}; - // paths to the WASMs used for tests - const VP_ALWAYS_TRUE_WASM: &str = "../wasm_for_tests/vp_always_true.wasm"; - const VP_ALWAYS_FALSE_WASM: &str = "../wasm_for_tests/vp_always_false.wasm"; - #[test] fn test_tx_read_write() { // The environment must be initialized first @@ -220,8 +217,7 @@ mod tests { // The environment must be initialized first tx_host_env::init(); - let code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let code = TestWasms::VpAlwaysTrue.read_bytes(); tx::ctx().init_account(code).unwrap(); } @@ -528,16 +524,14 @@ mod tests { assert!(!result); // evaluating the VP template which always returns `true` should pass - let code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let code = TestWasms::VpAlwaysTrue.read_bytes(); let input_data = vec![]; let result = vp::CTX.eval(code, input_data).unwrap(); assert!(result); // evaluating the VP template which always returns `false` shouldn't // pass - let code = - std::fs::read(VP_ALWAYS_FALSE_WASM).expect("cannot load wasm"); + let code = TestWasms::VpAlwaysFalse.read_bytes(); let input_data = vec![]; let result = vp::CTX.eval(code, input_data).unwrap(); assert!(!result); diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 3d3d7d8280..66c7425b5e 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -1712,6 +1712,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -2570,6 +2576,7 @@ version = "0.14.0" dependencies = [ "borsh", "namada_core", + "strum", ] [[package]] @@ -2652,6 +2659,7 @@ dependencies = [ "masp_primitives", "masp_proofs", "namada", + "namada_test_utils", "namada_tests", "namada_tx_prelude", "namada_vp_prelude", @@ -3089,7 +3097,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5" dependencies = [ "bytes", - "heck", + "heck 0.3.3", "itertools", "lazy_static", "log", @@ -4012,6 +4020,28 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "subtle" version = "2.4.1" diff --git a/wasm/checksums.json b/wasm/checksums.json index 7c2b824921..e6ac0217a1 100644 --- a/wasm/checksums.json +++ b/wasm/checksums.json @@ -1,20 +1,21 @@ { - "tx_bond.wasm": "tx_bond.f0094b887c57565472bede01d98fb77f6faac2f72597e2efb2ebfe9b1bf7c234.wasm", - "tx_change_validator_commission.wasm": "tx_change_validator_commission.02dca468021b1ec811d0f35cc4b55a24f7c3f7b5e51f16399709257421f4a1f4.wasm", - "tx_ibc.wasm": "tx_ibc.a1735e3221f1ae055c74bb52327765dd37e8676e15fab496f9ab0ed4d0628f51.wasm", - "tx_init_account.wasm": "tx_init_account.7b6eafeceb81b679c382279a5d9c40dfd81fcf37e5a1940340355c9f55af1543.wasm", - "tx_init_proposal.wasm": "tx_init_proposal.f2ed71fe70fc564e1d67e4e7d2ea25466327b62ba2eee18ece0021abff9e2c82.wasm", - "tx_init_validator.wasm": "tx_init_validator.fedcfaecaf37e3e7d050c76a4512baa399fc528710a27038573df53596613a2c.wasm", - "tx_reveal_pk.wasm": "tx_reveal_pk.3e5417561e8108d4045775bf6d095cbaad22c73ff17a5ba2ad11a1821665a58a.wasm", - "tx_transfer.wasm": "tx_transfer.833a3849ca2c417f4e907c95c6eb15e6b52827458cf603e1c4f5511ab3e4fe76.wasm", - "tx_unbond.wasm": "tx_unbond.d4fd6c94abb947533a2728940b43fb021a008ad593c7df7a3886c4260cac39b5.wasm", - "tx_update_vp.wasm": "tx_update_vp.6d1eabab15dc6d04eec5b25ad687f026a4d6c3f118a1d7aca9232394496bd845.wasm", - "tx_vote_proposal.wasm": "tx_vote_proposal.54b594f686a72869b0d7f15492591854f26e287a1cf3b6e543b0246d5ac61003.wasm", - "tx_withdraw.wasm": "tx_withdraw.342c222d0707eb5b5a44b89fc1245f527be3fdf841af64152a9ab35a4766e1b5.wasm", - "vp_implicit.wasm": "vp_implicit.73678ac01aa009ac4e0d4a49eecaa19b49cdd3d95f6862a9558c9b175ae68260.wasm", - "vp_masp.wasm": "vp_masp.85446251f8e1defed81549dab37edfe8e640339c7230e678b65340cf71ce1369.wasm", - "vp_testnet_faucet.wasm": "vp_testnet_faucet.573b882a806266d6cdfa635fe803e46d6ce89c99321196c231c61d05193a086d.wasm", - "vp_token.wasm": "vp_token.8c6e5a86f047e7b1f1004f0d8a4e91fad1b1c0226a6e42d7fe350f98dc84359b.wasm", - "vp_user.wasm": "vp_user.75c68f018f163d18d398cb4082b261323d115aae43ec021c868d1128e4b0ee29.wasm", - "vp_validator.wasm": "vp_validator.2dc9f1c8f106deeef5ee988955733955444d16b400ebb16a25e7d71e4b1be874.wasm" + "tx_bond.wasm": "tx_bond.e12fae2744ac427944901868f62f53926680ea9a7c2424adcd5c2e02aae89836.wasm", + "tx_bridge_pool.wasm": "tx_bridge_pool.31624135f5bd960433e0bf2bfd6c42bde4a47fdb7492b5bb2f840fc3b4ef3036.wasm", + "tx_change_validator_commission.wasm": "tx_change_validator_commission.38fdd95bb60c902c2d941a2963fb87fbb30642ea9b071aa25eef1819dd40e6dc.wasm", + "tx_ibc.wasm": "tx_ibc.fc6defd86f4df3418ded88e620a6ce89d2b39097974acd19cb104f79a3165095.wasm", + "tx_init_account.wasm": "tx_init_account.899112e6dae6880115e925fdf947e96e61f9b971a2a9c6732b911fe8c26a0d01.wasm", + "tx_init_proposal.wasm": "tx_init_proposal.5ace9668f903b861a2a7e117929a3094810c8ecf8863131bc63f34a1672131d9.wasm", + "tx_init_validator.wasm": "tx_init_validator.08bdb5804dfc33690778b2c5e4152fa45c2d829380a5f5e6c0ce6fd2dac12f9d.wasm", + "tx_reveal_pk.wasm": "tx_reveal_pk.ea64f0eacdac81c2144049d05795abd72a791e3a1c55cc716055098bb9f92db2.wasm", + "tx_transfer.wasm": "tx_transfer.5d9fa33466874048e55f9f34f9959fcee6715b8f5be1dc991471dcb1d527046e.wasm", + "tx_unbond.wasm": "tx_unbond.4dd861ce178f3bcb6c71ca6ad861893cbb223f6c1ddde08792c26e6fad564e01.wasm", + "tx_update_vp.wasm": "tx_update_vp.e91013a732051b2bc825285b97e8b00524a2d6a2472bac9a74202fc60433bd12.wasm", + "tx_vote_proposal.wasm": "tx_vote_proposal.d94b467bd64597e2a524dd5e861185a3ae9fcf97dfb4292b6b1446d7815b5b80.wasm", + "tx_withdraw.wasm": "tx_withdraw.4d982803b4d1e1be1773098b2399a53098dab1d7706e207506e19fefae2ac2cd.wasm", + "vp_implicit.wasm": "vp_implicit.929aa3f640411886be5a0c12e4d3c7ae18b3c83dc43c35dc5b25fe93b90c489c.wasm", + "vp_masp.wasm": "vp_masp.0aac80e827808aaf92ff841c0f4dde7517fcdc429d7bf1a3930eed6cfb663230.wasm", + "vp_testnet_faucet.wasm": "vp_testnet_faucet.9840665dcb3818b6f9de1c20113e5b5a03413d9ea5dc8f065feafc3798612d07.wasm", + "vp_token.wasm": "vp_token.ec14ab95bb3d21ae531204eb990694d7abd3857c8007d51d55ae8139617e87ba.wasm", + "vp_user.wasm": "vp_user.614787afdade760567a5fb6c63008e6c3aef69a2cd518c21e7515c8b9f81c8a2.wasm", + "vp_validator.wasm": "vp_validator.0561030577ad9a8a9cb13590e79c6dcc15c0ce8c2fca115418b61f36b55dc111.wasm" } \ No newline at end of file diff --git a/wasm/wasm_source/Cargo.toml b/wasm/wasm_source/Cargo.toml index a2cd2ba674..be5bf52853 100644 --- a/wasm/wasm_source/Cargo.toml +++ b/wasm/wasm_source/Cargo.toml @@ -46,6 +46,7 @@ masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6af [dev-dependencies] namada = {path = "../../shared"} namada_tests = {path = "../../tests"} +namada_test_utils = {path = "../../test_utils"} namada_tx_prelude = {path = "../../tx_prelude"} namada_vp_prelude = {path = "../../vp_prelude"} # A fork with state machine testing diff --git a/wasm/wasm_source/src/vp_implicit.rs b/wasm/wasm_source/src/vp_implicit.rs index 31a920a540..377a1b8de3 100644 --- a/wasm/wasm_source/src/vp_implicit.rs +++ b/wasm/wasm_source/src/vp_implicit.rs @@ -203,6 +203,7 @@ mod tests { // Use this as `#[test]` annotation to enable logging use namada::ledger::pos::{GenesisValidator, PosParams}; use namada::types::storage::Epoch; + use namada_test_utils::TestWasms; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::tx::{self, tx_host_env, TestTxEnv}; @@ -215,9 +216,6 @@ mod tests { use super::*; - const VP_ALWAYS_TRUE_WASM: &str = - "../../wasm_for_tests/vp_always_true.wasm"; - /// Test that no-op transaction (i.e. no storage modifications) accepted. #[test] fn test_no_op_transaction() { @@ -765,8 +763,7 @@ mod tests { let secret_key = key::testing::keypair_1(); let public_key = secret_key.ref_to(); let vp_owner: Address = (&public_key).into(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); @@ -800,8 +797,7 @@ mod tests { let secret_key = key::testing::keypair_1(); let public_key = secret_key.ref_to(); let vp_owner: Address = (&public_key).into(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); let vp_hash = sha256(&vp_code); tx_env.init_parameters( @@ -846,8 +842,7 @@ mod tests { let secret_key = key::testing::keypair_1(); let public_key = secret_key.ref_to(); let vp_owner: Address = (&public_key).into(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // hardcoded hash of VP_ALWAYS_TRUE_WASM tx_env.init_parameters(None, None, Some(vec!["E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855".to_string()])); diff --git a/wasm/wasm_source/src/vp_testnet_faucet.rs b/wasm/wasm_source/src/vp_testnet_faucet.rs index 1b8802df6e..69dd886e01 100644 --- a/wasm/wasm_source/src/vp_testnet_faucet.rs +++ b/wasm/wasm_source/src/vp_testnet_faucet.rs @@ -109,6 +109,7 @@ fn validate_tx( #[cfg(test)] mod tests { use address::testing::arb_non_internal_address; + use namada_test_utils::TestWasms; // Use this as `#[test]` annotation to enable logging use namada_tests::log::test; use namada_tests::tx::{self, tx_host_env, TestTxEnv}; @@ -121,9 +122,6 @@ mod tests { use super::*; - const VP_ALWAYS_TRUE_WASM: &str = - "../../wasm_for_tests/vp_always_true.wasm"; - /// Allows anyone to withdraw up to 1_000 tokens in a single tx pub const MAX_FREE_DEBIT: i128 = 1_000_000_000; // in micro units @@ -197,8 +195,7 @@ mod tests { let mut tx_env = TestTxEnv::default(); let vp_owner = address::testing::established_address_1(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); @@ -233,8 +230,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = &keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); diff --git a/wasm/wasm_source/src/vp_user.rs b/wasm/wasm_source/src/vp_user.rs index b8cbc20982..efcae94d0f 100644 --- a/wasm/wasm_source/src/vp_user.rs +++ b/wasm/wasm_source/src/vp_user.rs @@ -193,6 +193,7 @@ mod tests { use address::testing::arb_non_internal_address; use namada::ledger::pos::{GenesisValidator, PosParams}; use namada::types::storage::Epoch; + use namada_test_utils::TestWasms; // Use this as `#[test]` annotation to enable logging use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; @@ -206,9 +207,6 @@ mod tests { use super::*; - const VP_ALWAYS_TRUE_WASM: &str = - "../../wasm_for_tests/vp_always_true.wasm"; - /// Test that no-op transaction (i.e. no storage modifications) accepted. #[test] fn test_no_op_transaction() { @@ -657,8 +655,7 @@ mod tests { let mut tx_env = TestTxEnv::default(); let vp_owner = address::testing::established_address_1(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); @@ -694,8 +691,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); @@ -735,8 +731,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); @@ -775,8 +770,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); let vp_hash = sha256(&vp_code); tx_env.init_parameters(None, Some(vec![vp_hash.to_string()]), None); @@ -818,8 +812,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); let vp_hash = sha256(&vp_code); tx_env.init_parameters( @@ -864,8 +857,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // hardcoded hash of VP_ALWAYS_TRUE_WASM tx_env.init_parameters(None, None, Some(vec!["E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855".to_string()])); diff --git a/wasm/wasm_source/src/vp_validator.rs b/wasm/wasm_source/src/vp_validator.rs index c9e4700d8e..755af2be83 100644 --- a/wasm/wasm_source/src/vp_validator.rs +++ b/wasm/wasm_source/src/vp_validator.rs @@ -201,6 +201,7 @@ mod tests { use address::testing::arb_non_internal_address; use namada::ledger::pos::{GenesisValidator, PosParams}; use namada::types::storage::Epoch; + use namada_test_utils::TestWasms; // Use this as `#[test]` annotation to enable logging use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; @@ -215,9 +216,6 @@ mod tests { use super::*; - const VP_ALWAYS_TRUE_WASM: &str = - "../../wasm_for_tests/vp_always_true.wasm"; - /// Test that no-op transaction (i.e. no storage modifications) accepted. #[test] fn test_no_op_transaction() { @@ -678,8 +676,7 @@ mod tests { let mut tx_env = TestTxEnv::default(); let vp_owner = address::testing::established_address_1(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); @@ -715,8 +712,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); @@ -756,8 +752,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // Spawn the accounts to be able to modify their storage tx_env.spawn_accounts([&vp_owner]); @@ -796,8 +791,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); let vp_hash = sha256(&vp_code); tx_env.init_parameters(None, Some(vec![vp_hash.to_string()]), None); @@ -839,8 +833,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); let vp_hash = sha256(&vp_code); tx_env.init_parameters( @@ -885,8 +878,7 @@ mod tests { let vp_owner = address::testing::established_address_1(); let keypair = key::testing::keypair_1(); let public_key = keypair.ref_to(); - let vp_code = - std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm"); + let vp_code = TestWasms::VpAlwaysTrue.read_bytes(); // hardcoded hash of VP_ALWAYS_TRUE_WASM tx_env.init_parameters(None, None, Some(vec!["E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855".to_string()])); diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index 1b290303cd..983294430c 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -1712,6 +1712,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -2570,6 +2576,7 @@ version = "0.14.0" dependencies = [ "borsh", "namada_core", + "strum", ] [[package]] @@ -3082,7 +3089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5" dependencies = [ "bytes", - "heck", + "heck 0.3.3", "itertools", "lazy_static", "log", @@ -4005,6 +4012,28 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "subtle" version = "2.4.1"