Skip to content

Commit a7d4d42

Browse files
committed
Reverted demo tests
Signed-off-by: artem.ivanov <[email protected]>
1 parent 2b53726 commit a7d4d42

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

wrappers/java/src/test/java/org/hyperledger/indy/sdk/demo/AnoncredsDemoTest.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ public void testAnoncredsDemo() throws Exception {
9090
String credDefId = createCredDefResult.getCredDefId();
9191
String credDef = createCredDefResult.getCredDefJson();
9292

93-
System.out.println(credDef);
94-
9593
// Prover create Master Secret
9694
Anoncreds.proverCreateMasterSecret(proverWallet, masterSecretId).get();
9795

@@ -117,41 +115,49 @@ public void testAnoncredsDemo() throws Exception {
117115
" \"name\":\"proof_req_1\",\n" +
118116
" \"version\":\"0.1\", " +
119117
" \"requested_attributes\": {" +
120-
" \"attr1_referent\":{\"name\":\"name\"}" +
118+
" \"attr1_referent\":{\"name\":\"name\"}," +
119+
" \"attr2_referent\":{\"name\":\"sex\"}," +
120+
" \"attr3_referent\":{\"name\":\"phone\"}" +
121121
" }," +
122122
" \"requested_predicates\":{" +
123+
" \"predicate1_referent\":{\"name\":\"age\",\"p_type\":\">=\",\"p_value\":18}" +
123124
" }" +
124125
" }").toString();
125126

126127
String credentialsForProofJson = Anoncreds.proverGetCredentialsForProofReq(proverWallet, proofRequestJson).get();
127128

128129
JSONObject credentialsForProof = new JSONObject(credentialsForProofJson);
129130
JSONArray credentialsForAttribute1 = credentialsForProof.getJSONObject("attrs").getJSONArray("attr1_referent");
131+
JSONArray credentialsForAttribute2 = credentialsForProof.getJSONObject("attrs").getJSONArray("attr2_referent");
132+
JSONArray credentialsForAttribute3 = credentialsForProof.getJSONObject("attrs").getJSONArray("attr3_referent");
133+
JSONArray credentialsForPredicate = credentialsForProof.getJSONObject("predicates").getJSONArray("predicate1_referent");
130134

131135
assertEquals(credentialsForAttribute1.length(), 1);
136+
assertEquals(credentialsForAttribute2.length(), 1);
137+
assertEquals(credentialsForAttribute3.length(), 0);
138+
assertEquals(credentialsForPredicate.length(), 1);
132139

133140
String credentialUuid = credentialsForAttribute1.getJSONObject(0).getJSONObject("cred_info").getString("referent");
134141

135142
// Prover create Proof
136143
String selfAttestedValue = "8-800-300";
137144
String requestedCredentialsJson = new JSONObject(String.format("{\n" +
138-
" \"self_attested_attributes\":{},\n" +
139-
" \"requested_attributes\":{\"attr1_referent\":{\"cred_id\":\"%s\", \"revealed\":true}},\n" +
140-
" \"requested_predicates\":{}\n" +
141-
" }", credentialUuid)).toString();
145+
" \"self_attested_attributes\":{\"attr3_referent\":\"%s\"},\n" +
146+
" \"requested_attributes\":{\"attr1_referent\":{\"cred_id\":\"%s\", \"revealed\":true},\n" +
147+
" \"attr2_referent\":{\"cred_id\":\"%s\", \"revealed\":false}},\n" +
148+
" \"requested_predicates\":{\"predicate1_referent\":{\"cred_id\":\"%s\"}}\n" +
149+
" }", selfAttestedValue, credentialUuid, credentialUuid, credentialUuid)).toString();
142150

143151
String schemas = new JSONObject(String.format("{\"%s\":%s}", gvtSchemaId, gvtSchema)).toString();
144152
String credentialDefs = new JSONObject(String.format("{\"%s\":%s}", credDefId, credDef)).toString();
145153
String revocStates = new JSONObject("{}").toString();
146154

147155
String proofJson = Anoncreds.proverCreateProof(proverWallet, proofRequestJson, requestedCredentialsJson,
148156
masterSecretId, schemas, credentialDefs, revocStates).get();
149-
150-
System.out.println(proofJson);
151157
JSONObject proof = new JSONObject(proofJson);
152158

153159
// Verifier verify Proof
154-
/*JSONObject revealedAttr1 = proof.getJSONObject("requested_proof").getJSONObject("revealed_attrs").getJSONObject("attr1_referent");
160+
JSONObject revealedAttr1 = proof.getJSONObject("requested_proof").getJSONObject("revealed_attrs").getJSONObject("attr1_referent");
155161
assertEquals("Alex", revealedAttr1.getString("raw"));
156162

157163
assertNotNull(proof.getJSONObject("requested_proof").getJSONObject("unrevealed_attrs").getJSONObject("attr2_referent").getInt("sub_proof_index"));
@@ -162,7 +168,7 @@ public void testAnoncredsDemo() throws Exception {
162168
String revocRegs = new JSONObject("{}").toString();
163169

164170
Boolean valid = Anoncreds.verifierVerifyProof(proofRequestJson, proofJson, schemas, credentialDefs, revocRegDefs, revocRegs).get();
165-
assertTrue(valid);*/
171+
assertTrue(valid);
166172
}
167173

168174
@Test
@@ -620,4 +626,4 @@ public void testVerifyProofWorksForProofDoesNotCorrespondToProofRequest() throws
620626

621627
Anoncreds.verifierVerifyProof(proofRequestJson, proofJson, schemas, credentialDefs, revocRegDefs, revocRegs).get();
622628
}
623-
}
629+
}

wrappers/python/tests/demo/test_anoncreds.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ async def test_anoncreds_demo_works(pool_name, wallet_name, path_home, credentia
2121
(cred_def_id, cred_def_json) = \
2222
await anoncreds.issuer_create_and_store_credential_def(wallet_handle, issuer_did, schema_json, 'tag1', 'CL',
2323
'{"support_revocation": false}')
24-
print(cred_def_json)
24+
2525
# 3. Prover create Master Secret
2626
master_secret_id = "master_secret"
2727
await anoncreds.prover_create_master_secret(wallet_handle, master_secret_id)
2828

2929
# 4. Issuer create credential Offer
3030
cred_offer_json = await anoncreds.issuer_create_credential_offer(wallet_handle, cred_def_id)
31-
print(cred_offer_json)
3231

3332
# 5. Prover create credential Request
3433
(cred_req_json, cred_req_metadata_json) = \
@@ -60,7 +59,9 @@ async def test_anoncreds_demo_works(pool_name, wallet_name, path_home, credentia
6059
'requested_attributes': {
6160
'attr1_referent': {'name': 'name'}
6261
},
63-
'requested_predicates': {}
62+
'requested_predicates': {
63+
'predicate1_referent': {'name': 'age', 'p_type': '>=', 'p_value': 18}
64+
}
6465
})
6566

6667
credential_for_proof_json = await anoncreds.prover_get_credentials_for_proof_req(wallet_handle, proof_req_json)
@@ -73,7 +74,7 @@ async def test_anoncreds_demo_works(pool_name, wallet_name, path_home, credentia
7374
requested_credentials_json = json.dumps({
7475
'self_attested_attributes': {},
7576
'requested_attributes': {'attr1_referent': {'cred_id': referent, 'revealed': True}},
76-
'requested_predicates': {}
77+
'requested_predicates': {'predicate1_referent': {'cred_id': referent}}
7778
})
7879

7980
schemas_json = json.dumps({schema_id: json.loads(schema_json)})
@@ -84,7 +85,6 @@ async def test_anoncreds_demo_works(pool_name, wallet_name, path_home, credentia
8485
master_secret_id, schemas_json, credential_defs_json,
8586
revoc_states_json)
8687
proof = json.loads(proof_json)
87-
print(proof_json)
8888

8989
assert 'Alex' == proof['requested_proof']['revealed_attrs']['attr1_referent']['raw']
9090

@@ -209,4 +209,4 @@ async def test_anoncreds_demo_works_for_revocation_proof(pool_name, wallet_name,
209209

210210
# 14. Close wallet
211211
await wallet.close_wallet(wallet_handle)
212-
await wallet.delete_wallet(wallet_name, credentials)
212+
await wallet.delete_wallet(wallet_name, credentials)

0 commit comments

Comments
 (0)