Skip to content

Commit 53c779f

Browse files
netheril96QZHelen
authored andcommitted
Add a build script to minimize wasm size
1 parent 7df996f commit 53c779f

2 files changed

Lines changed: 41 additions & 52 deletions

File tree

matcher-rs/build.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 1. Build with maximum rustc optimizations
2+
CARGO_PROFILE_RELEASE_PANIC=immediate-abort \
3+
CARGO_PROFILE_RELEASE_OPT_LEVEL="z" \
4+
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 \
5+
CARGO_PROFILE_RELEASE_STRIP=true \
6+
cargo +nightly build \
7+
-Z panic-immediate-abort \
8+
-Z build-std \
9+
--target wasm32-unknown-unknown \
10+
--release
11+
12+
# 2. Further shrink using wasm-opt (if available)
13+
wasm-opt -Oz --strip-debug --enable-bulk-memory \
14+
target/wasm32-unknown-unknown/release/issuance.wasm \
15+
-o target/wasm32-unknown-unknown/release/issuance.wasm
16+

matcher-rs/src/issuance.rs

Lines changed: 25 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -315,63 +315,36 @@ mod test {
315315
"entry_id": "C",
316316
"title": "TTTT",
317317
"subtitle": "SSSSS",
318-
"icon": [0, 0],
318+
"icon": [
319+
0,
320+
0
321+
],
319322
"filter": {
320-
"SupportsMdocDoctype": {
321-
"doctypes": ["org.iso.18013.5.1.mDL"]
322-
}
323-
}
324-
}"#,
325-
icon: Vec::new(),
326-
added_entries: Vec::new(),
327-
};
328-
329-
issuance_main(&mut credman).unwrap();
330-
331-
assert_eq!(credman.added_entries.len(), 1);
332-
}
333-
334-
#[test]
335-
fn match_mdoc_with_algs() {
336-
let mut credman = FakeCredman {
337-
request_json: r#"
338-
{
339-
"requests": [
340-
{
341-
"protocol": "openid4vci-1.1",
342-
"data": {
343-
"credential_offer": {
344-
"credential_issuer": "https://issuer.my",
345-
"credential_configuration_ids": [
346-
"FICTITIOUS_STATE_MDL"
347-
],
348-
"grants": {
349-
"authorization_code": {}
323+
"Or": {
324+
"filters": [
325+
{
326+
"AllowsConfigurationIds": {
327+
"configuration_ids": [
328+
"US_SOCIAL_SECURITY_NUMBER",
329+
"EU_AGE"
330+
]
350331
}
351332
},
352-
"credential_issuer_metadata": {
353-
"nonce_endpoint": "https://nonce.my",
354-
"credential_configurations_supported": {
355-
"FICTITIOUS_STATE_MDL": {
356-
"format": "mso_mdoc",
357-
"doctype": "org.iso.18013.5.1.mDL",
358-
"credential_signing_alg_values_supported": ["ES256", "ES384"]
359-
}
333+
{
334+
"AllowsIssuers": {
335+
"issuers": [
336+
"ccb"
337+
]
338+
}
339+
},
340+
{
341+
"SupportsMdocDoctype": {
342+
"doctypes": [
343+
"org.iso.18013.5.1.mDL"
344+
]
360345
}
361346
}
362-
}
363-
}
364-
]
365-
}"#,
366-
registered_json: r#"
367-
{
368-
"entry_id": "C",
369-
"title": "TTTT",
370-
"subtitle": "SSSSS",
371-
"icon": [0, 0],
372-
"filter": {
373-
"SupportsMdocDoctype": {
374-
"doctypes": ["org.iso.18013.5.1.mDL"]
347+
]
375348
}
376349
}
377350
}"#,

0 commit comments

Comments
 (0)