Skip to content

Commit 390b982

Browse files
authored
Merge pull request hyperledger-indy#774 from Artemkaaas/bugfix/filtering
Fixed credentials filtering bug
2 parents 1911725 + 838cfd2 commit 390b982

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

libindy/src/domain/credential.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,25 @@ pub struct CredentialInfo {
4040
}
4141

4242
impl CredentialInfo {
43-
fn parts(&self) -> Vec<&str> {
44-
self.cred_def_id.split_terminator(DELIMITER).collect::<Vec<&str>>()
43+
fn schema_parts(&self) -> Vec<&str> {
44+
self.schema_id.split_terminator(DELIMITER).collect::<Vec<&str>>()
4545
}
4646
}
4747

4848
impl Filtering for CredentialInfo {
4949
fn schema_id(&self) -> String { self.schema_id.to_string() }
50-
fn schema_issuer_did(&self) -> String { self.parts().get(3).map(|s| s.to_string()).unwrap_or(String::new()) }
51-
fn schema_name(&self) -> String { self.parts().get(5).map(|s| s.to_string()).unwrap_or(String::new()) }
52-
fn schema_version(&self) -> String { self.parts().get(6).map(|s| s.to_string()).unwrap_or(String::new()) }
53-
fn issuer_did(&self) -> String { self.parts()[0].to_string() }
50+
fn schema_issuer_did(&self) -> String {
51+
self.schema_parts().get(0).map(|s| s.to_string()).unwrap_or(String::new())
52+
}
53+
fn schema_name(&self) -> String {
54+
self.schema_parts().get(2).map(|s| s.to_string()).unwrap_or(String::new())
55+
}
56+
fn schema_version(&self) -> String {
57+
self.schema_parts().get(3).map(|s| s.to_string()).unwrap_or(String::new())
58+
}
59+
fn issuer_did(&self) -> String {
60+
self.cred_def_id.split_terminator(DELIMITER).collect::<Vec<&str>>()[0].to_string()
61+
}
5462
fn cred_def_id(&self) -> String { self.cred_def_id.to_string() }
5563
}
5664

libindy/tests/interaction.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ fn anoncreds_revocation_interaction_test_issuance_by_demand() {
173173
&cred_def_json,
174174
Some(&revoc_reg_def_json)).unwrap();
175175

176+
let credentials = AnoncredsUtils::prover_get_credentials(prover_wallet_handle, &format!(r#"{{"schema_name":"{}"}}"#, GVT_SCHEMA_NAME)).unwrap();
177+
let credentials: Vec<serde_json::Value> = serde_json::from_str(&credentials).unwrap();
178+
assert_eq!(credentials.len(), 1);
179+
176180
// Verifying Prover Credential
177181
thread::sleep(std::time::Duration::from_secs(3));
178182

0 commit comments

Comments
 (0)