Skip to content

Commit

Permalink
WASM: enable in-browser tests through wasm-bindgen-test
Browse files Browse the repository at this point in the history
The unit tests currently are marked with both `#[test]` and
`#[wasm_bindgen_test]`. This allows tests to run with both `cargo test`
and `wasm-pack test`.

In theory, we could drop `#[test]`, but given that `cargo test` is
faster than `wasm-pack test`, this makes developing easier, so I'm
keeping it for now.
  • Loading branch information
andiflabs committed Nov 13, 2024
1 parent b63f951 commit 013cf4e
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 4 deletions.
61 changes: 57 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ironfish-rust-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ wasm-bindgen = "0.2.95"

[dev-dependencies]
hex-literal = "0.4.1"
wasm-bindgen-test = "0.3.45"
3 changes: 3 additions & 0 deletions ironfish-rust-wasm/src/keys/public_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ impl AsRef<ironfish::PublicAddress> for PublicAddress {
mod tests {
use crate::keys::public_address::PublicAddress;
use hex_literal::hex;
use wasm_bindgen_test::wasm_bindgen_test;

#[test]
#[wasm_bindgen_test]
fn valid_address() {
let bytes = hex!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0");
let addr = PublicAddress::deserialize(&bytes[..])
Expand All @@ -63,6 +65,7 @@ mod tests {
}

#[test]
#[wasm_bindgen_test]
fn invalid_address() {
let bytes = hex!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1");
PublicAddress::deserialize(&bytes[..])
Expand Down
5 changes: 5 additions & 0 deletions ironfish-rust-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ use getrandom as _;
pub mod errors;
pub mod keys;
pub mod primitives;

#[cfg(test)]
mod tests {
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
}
30 changes: 30 additions & 0 deletions supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ criteria = "safe-to-deploy"
delta = "0.10.1 -> 0.11.0"
notes = "Main change is how langauges are handled (previous version: through an enum, new version: through a marker type)"

[[audits.console_error_panic_hook]]
who = "andrea <[email protected]>"
criteria = "safe-to-run"
version = "0.1.7"

[[audits.crypto_box]]
who = "Andrea <[email protected]>"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -78,6 +83,16 @@ criteria = "safe-to-deploy"
version = "0.1.0"
notes = "Crate owned by the Iron Fish organization"

[[audits.js-sys]]
who = "andrea <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.3.69 -> 0.3.72"

[[audits.minicov]]
who = "andrea <[email protected]>"
criteria = "safe-to-run"
version = "0.3.7"

[[audits.mio]]
who = "Andrea <[email protected]>"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -120,6 +135,11 @@ criteria = "safe-to-deploy"
delta = "0.2.84 -> 0.2.95"
notes = "New features and bug fixes; there's are new/changed unsafe blocks and they all look benign"

[[audits.wasm-bindgen-futures]]
who = "andrea <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.4.34 -> 0.4.45"

[[audits.wasm-bindgen-macro]]
who = "andrea <[email protected]>"
criteria = "safe-to-deploy"
Expand All @@ -138,6 +158,16 @@ criteria = "safe-to-deploy"
delta = "0.2.92 -> 0.2.95"
notes = "Only minor changes; no new unsafe code or system calls introduced"

[[audits.wasm-bindgen-test]]
who = "andrea <[email protected]>"
criteria = "safe-to-run"
version = "0.3.45"

[[audits.wasm-bindgen-test-macro]]
who = "andrea <[email protected]>"
criteria = "safe-to-run"
version = "0.3.45"

[[trusted.reddsa]]
criteria = "safe-to-deploy"
user-id = 6289 # Jack Grigg (str4d)
Expand Down
36 changes: 36 additions & 0 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,12 @@ The delta just 1) inlines/expands `impl ToTokens` that used to be handled via
"""
aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT"

[[audits.google.audits.scoped-tls]]
who = "George Burgess IV <[email protected]>"
criteria = "safe-to-run"
version = "1.0.0"
aggregated-from = "https://chromium.googlesource.com/chromiumos/third_party/rust_crates/+/refs/heads/main/cargo-vet/audits.toml?format=TEXT"

[[audits.google.audits.unicode-xid]]
who = "George Burgess IV <[email protected]>"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -1029,6 +1035,12 @@ version = "1.1.0"
notes = "Straightforward crate with no unsafe code, does what it says on the tin."
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"

[[audits.mozilla.audits.scoped-tls]]
who = "Mike Hommey <[email protected]>"
criteria = "safe-to-run"
delta = "1.0.0 -> 1.0.1"
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"

[[audits.mozilla.audits.sha2]]
who = "Mike Hommey <[email protected]>"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -1228,6 +1240,30 @@ version = "0.1.3"
notes = "Reviewed in full."
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.js-sys]]
who = "Jack Grigg <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.3.61 -> 0.3.64"
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.js-sys]]
who = "Jack Grigg <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.3.64 -> 0.3.66"
notes = """
- Fixes the `BigInt64Array` variants of the existing `Atomics.wait` method.
- Adds `Atomics.waitAsync`, the `DataView` constructor variant that takes
`SharedArrayBuffer`, and `WebAssembly.Exception`; I checked these against their
MDN documentation.
"""
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.js-sys]]
who = "Daira-Emma Hopwood <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.3.66 -> 0.3.69"
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.jubjub]]
who = "Sean Bowe <[email protected]>"
criteria = "safe-to-deploy"
Expand Down

0 comments on commit 013cf4e

Please sign in to comment.