diff --git a/src/bin/ssi-vc-test/main.rs b/src/bin/ssi-vc-test/main.rs index 56818fa66..95ae07f9b 100644 --- a/src/bin/ssi-vc-test/main.rs +++ b/src/bin/ssi-vc-test/main.rs @@ -1,6 +1,7 @@ use ssi::jwk::JWTKeys; -use ssi::vc::Contexts; +use ssi::vc::Context; use ssi::vc::Credential; +use ssi::vc::OneOrMany; use ssi::vc::Presentation; fn usage() { @@ -33,12 +34,14 @@ fn generate(data: String) -> String { } // work around https://github.com/w3c/vc-test-suite/issues/96 - if doc.type_.len() > 1 { - if let Contexts::Many(ref context) = doc.context { - if context.len() == 1 { - panic!("If there are multiple types, there should be multiple contexts."); - } - } + let contexts: &OneOrMany = &doc.context.clone().into(); + if doc.type_.len() > 1 && contexts.len() <= 1 { + panic!("If there are multiple types, there should be multiple contexts."); + } + + // work around https://github.com/w3c/vc-test-suite/issues/97 + if contexts.len() > 1 && doc.type_.len() <= 1 { + panic!("If there are multiple contexts, there should be multiple types."); } serde_json::to_string_pretty(&doc).unwrap() diff --git a/src/vc.rs b/src/vc.rs index b66c7c606..7a6f81516 100644 --- a/src/vc.rs +++ b/src/vc.rs @@ -304,6 +304,15 @@ impl TryFrom> for Contexts { } } +impl From for OneOrMany { + fn from(contexts: Contexts) -> OneOrMany { + match contexts { + Contexts::One(context) => OneOrMany::One(context), + Contexts::Many(contexts) => OneOrMany::Many(contexts), + } + } +} + impl TryFrom for URI { type Error = Error; fn try_from(uri: String) -> Result {