From 614059a53938c0bd9a83b88ac181606a0efc9b27 Mon Sep 17 00:00:00 2001 From: Pauan Date: Sat, 3 Aug 2024 21:02:26 -0700 Subject: [PATCH] Fixing Wasm tests --- wasm/src/programs/proving_key/mod.rs | 11 +++++++---- wasm/src/programs/verifying_key/metadata.rs | 2 +- wasm/src/programs/verifying_key/mod.rs | 16 ++++++++++++---- wasm/src/types/networks/mainnet.rs | 2 ++ wasm/src/types/networks/testnet.rs | 2 ++ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/wasm/src/programs/proving_key/mod.rs b/wasm/src/programs/proving_key/mod.rs index 9c08bc14c..290d0e87f 100644 --- a/wasm/src/programs/proving_key/mod.rs +++ b/wasm/src/programs/proving_key/mod.rs @@ -127,10 +127,13 @@ mod tests { ProvingKey::from_string(&transfer_public_proving_key_string).unwrap(); assert_eq!(key, transfer_public_proving_key_from_string); + #[cfg(feature = "testnet")] + let checksum = "846f86cabf9fa50e5abe347e559a8e9f3018459b5af9fdf52f1c44892b05f7e5"; + + #[cfg(feature = "mainnet")] + let checksum = "f8e5f6437b945174b62313ece8a1c9dcbeac5dfff5b0fef2e968c9b92f86da06"; + let transfer_public_proving_key_checksum = key.checksum(); - assert_eq!( - transfer_public_proving_key_checksum, - "846f86cabf9fa50e5abe347e559a8e9f3018459b5af9fdf52f1c44892b05f7e5" - ); + assert_eq!(transfer_public_proving_key_checksum, checksum); } } diff --git a/wasm/src/programs/verifying_key/metadata.rs b/wasm/src/programs/verifying_key/metadata.rs index ee5d9c431..c09342f56 100644 --- a/wasm/src/programs/verifying_key/metadata.rs +++ b/wasm/src/programs/verifying_key/metadata.rs @@ -36,7 +36,7 @@ pub struct Metadata { } impl Metadata { - const BASE_URL: &'static str = "https://parameters.aleo.org/testnet/"; + const BASE_URL: &'static str = crate::types::native::BASE_URL; fn new(name: &str, verifying_key: &str, locator: &str, prover: &'static str, verifier: &'static str) -> Self { fn url(function_name: &str, kind: &str, proving_key_metadata: &'static str) -> String { diff --git a/wasm/src/programs/verifying_key/mod.rs b/wasm/src/programs/verifying_key/mod.rs index fd8a4c30b..96eb871d7 100644 --- a/wasm/src/programs/verifying_key/mod.rs +++ b/wasm/src/programs/verifying_key/mod.rs @@ -121,8 +121,12 @@ mod tests { use super::*; use wasm_bindgen_test::*; + #[cfg(feature = "testnet")] const TRANSFER_PUBLIC_VERIFYING_KEY: &str = "verifier1qygqqqqqqqqqqqp3xqqqqqqqqqqzvvqqqqqqqqqq23hqqqqqqqqqqau5qqqqqqqqqq5yzqqqqqqqqqqvqqqqqqqqqqqz2rh4q6m4u0ycv2z5qx95echpdcsktezkr2j9cvff0dngp45jfqggm8q3578nkhjudslm2rdpsgcpks4ulquyqrtd978zvj65pxmhkudyjtj005h66jcnwg3f6mdqqaqjed3avcz599kth8a3nak0tftsrk4hczcdvlmrdnzsa6rfppy72flsrhdhn6npxfxt2rrudk8jrk5fefkawhhrf0psccp6l9akckaps898v5mk7vprkx90gg798d6j5tvvtma0r9phq3jndan5rkwv8wmkngeha3pzrjzslkt8ct9umm4wfq8dhnpdv8m4plq70c3d6wxs4l3cv4gyqhgjtwfuydc5fflulwgjvdtaxxlmpf0l5n800jn2lwnt5kqqtdsx2lvzl3kw3ns5hnsu4jzg9ejptg7n7r7d9dvqsrvldw9paeq86hjxeaac6typemynwzt8w3vq3e27l4swd9aqxaas7zsy5mw7ftnjct9jq6t9rdq0kx8vjag77nt0z894xqkrfp27hehk83nfcg7cpjcc7f8mznga33xp36seafxpn26rq4w5l9uawtx02mzpq9kuyyx7nvhtad0mxk5su659xx5wv3yhqqy3577kwc40spvp9dst59ap2ll5uuq7qaauy9vy5yvrjd77c443evxrwfsee8jg5hvt6f9xaupjzq2cmuuwdvjs0qtxmnwjmdepu5979qy4nhqs63zljatt7kkggddxctt74crayt4djvnh3u6tjzm8wyqpc7nf0r0k9mp34x9musgdqegkmscey50ckyehm67c5tcdlawkh6my2v3xzwaug7c4y9xyw0dfkqup24jdckk5wxkyfd8rsp6h220dj786t54fyj59ehtq0gyut6lcattumgdss4kkchrdp7f5sjgcu7ycpzq0d47m6xe3yh2q5q76fa20lm46pe8fcd9yqcrxduhkdqfe4c9pw3pqqqqqqqqqq0qvtsl"; + #[cfg(feature = "mainnet")] + const TRANSFER_PUBLIC_VERIFYING_KEY: &str = "verifier1qygqqqqqqqqqqqp3xqqqqqqqqqqzvvqqqqqqqqqq23hqqqqqqqqqqau5qqqqqqqqqq5yzqqqqqqqqqqvqqqqqqqqqqqz2rh4q6m4u0ycv2z5qx95echpdcsktezkr2j9cvff0dngp45jfqggm8q3578nkhjudslm2rdpsgcpks4ulquyqrtd978zvj65pxmhkudyjtj005h66jcnwg3f6mdqqaqjed3avcz599kth8a3nak0tftsrk4hczcdvlmrdnzsa6rfppy72flsrhdhn6npxfxt2rrudk8jrk5fefkawhhrf0psccp6l9akckaps898v5mk7vprkx90gg798d6j5tvvtma0r9phq3jndan5rkwv8wmkngeha3pzrjzslkt8ct9umm4wfq8dhnpdv8m4plq70c3d6wxs4l3cv4gyqhgjtwfuydc5fflulwgjvdtaxxlmpf0l5n800jn2lwnt5kqqtdsx2lvzl3kw3ns5hnsu4jzg9ejptg7n7r7d9dvqsrvldw9paeq86hjxeaac6typemynwzt8w3vq3e27l4swd9aqxaas7zsy5mw7ftnjct9jq6t9rdq0kx8vjag77nt0z894xqkrfp27hehk83nfcg7cpjcc7f8mznga33xp36seafxpn26rq4w5l9uawtx02mzpq9kuyyx7nvhtad0mxk5su659xx5wv3yhqqy3577kwc40spvp9dst59ap2ll5uuq7qaauy9vy5yvrjd77c443evxrwfsee8jg5hvt6f9xaupjzqdd2jexnaselrezp7eptfjtpgs6ga5p3nkycwf26k6nkrf8j302e3a62rq7x5xpz9r8q9ttf36y3vqq6kvvmnuuzv6zkv0p8ds0g6z7stfhtxvzl4vjgj9vf35tnkxxvhmk4xgqcycz6g5aaejlmskvr8uq24jdckk5wxkyfd8rsp6h220dj786t54fyj59ehtq0gyut6lcattumgdss4kkchrdp7f5sjgcu7ycppt59jx985rpqa04krg2sh5je7dt6rntnvf2xd76vrgh3ldnp33lw3pqqqqqqqqqqjgex6x"; + #[allow(dead_code)] #[test] fn verifying_key_strings() { @@ -218,9 +222,13 @@ mod tests { crate::types::native::parameters::TransferPublicVerifier::load_bytes().unwrap(); let transfer_public_verifier = VerifyingKey::from_bytes(&transfer_public_verifier_bytes).unwrap(); let transfer_public_verifying_key_checksum = transfer_public_verifier.checksum(); - assert_eq!( - transfer_public_verifying_key_checksum, - "1b5109468e7992c39bbbc299dd1f94f18e49928e253e60ed68c7d9f02e73fe8d" - ); + + #[cfg(feature = "testnet")] + let checksum = "1b5109468e7992c39bbbc299dd1f94f18e49928e253e60ed68c7d9f02e73fe8d"; + + #[cfg(feature = "mainnet")] + let checksum = "ea77f42a35b3f891e7753c7333df365f356883550c4602df11f270237bef340d"; + + assert_eq!(transfer_public_verifying_key_checksum, checksum); } } diff --git a/wasm/src/types/networks/mainnet.rs b/wasm/src/types/networks/mainnet.rs index 5a74355e7..ffd89a69b 100644 --- a/wasm/src/types/networks/mainnet.rs +++ b/wasm/src/types/networks/mainnet.rs @@ -19,3 +19,5 @@ pub use snarkvm_circuit_network::AleoV0 as CurrentAleo; pub use snarkvm_console::network::MainnetV0 as CurrentNetwork; pub use snarkvm_parameters::mainnet as parameters; + +pub const BASE_URL: &'static str = "https://parameters.aleo.org/mainnet/"; diff --git a/wasm/src/types/networks/testnet.rs b/wasm/src/types/networks/testnet.rs index 4257ffba4..9085dc799 100644 --- a/wasm/src/types/networks/testnet.rs +++ b/wasm/src/types/networks/testnet.rs @@ -19,3 +19,5 @@ pub use snarkvm_circuit_network::AleoTestnetV0 as CurrentAleo; pub use snarkvm_console::network::TestnetV0 as CurrentNetwork; pub use snarkvm_parameters::testnet as parameters; + +pub const BASE_URL: &'static str = "https://parameters.aleo.org/testnet/";