Skip to content

Commit

Permalink
Merge pull request hyperledger-archives#6 from Artemkaaas/mikelodder7…
Browse files Browse the repository at this point in the history
…_master

Fixed ledger.build_cred_def_request tests
  • Loading branch information
Vyacheslav authored Jul 6, 2018
2 parents 7bf024e + 2cc8f5d commit a3eeb60
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
11 changes: 6 additions & 5 deletions libindy/tests/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use self::openssl::hash::{MessageDigest, Hasher};
use self::sodiumoxide::crypto::secretbox;

use utils::domain::anoncreds::schema::{Schema, SchemaV1};
use utils::domain::anoncreds::credential_definition::{CredentialDefinitionV1};
use utils::domain::anoncreds::credential_definition::CredentialDefinitionV1;
use utils::domain::anoncreds::revocation_registry_definition::RevocationRegistryDefinitionV1;
use utils::domain::anoncreds::revocation_registry::RevocationRegistryV1;
use utils::domain::anoncreds::revocation_registry_delta::RevocationRegistryDeltaV1;
Expand Down Expand Up @@ -808,18 +808,19 @@ mod high_cases {
"primary":{
"n":"1",
"s":"2",
"rms":"3",
"r":{"name":"1"},
"r":{"name":"1","master_secret":"3"},
"rctxt":"1",
"z":"1"
}
}
}"#;

let expected_result = r#""operation":{"ref":1,"data":{"primary":{"n":"1","s":"2","rms":"3","r":{"name":"1"},"rctxt":"1","z":"1"}},"type":"102","signature_type":"CL","tag":"TAG_1"}"#;
let expected_result = r#"{"ref":1,"data":{"primary":{"n":"1","s":"2","r":{"name":"1","master_secret":"3"},"rctxt":"1","z":"1"}},"type":"102","signature_type":"CL","tag":"TAG_1"}"#;

let cred_def_request = LedgerUtils::build_cred_def_txn(IDENTIFIER, cred_def_json).unwrap();
assert!(cred_def_request.contains(&expected_result));

assert_eq!(serde_json::from_str::<serde_json::Value>(&cred_def_request).unwrap()["operation"].as_object().unwrap(),
serde_json::from_str::<serde_json::Value>(&expected_result).unwrap().as_object().unwrap());
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ - (void)testBuildCredDefRequestWorksForCorrectDataJson {
@"primary": @{
@"n": @"1",
@"s": @"2",
@"rms": @"3",
@"r": @{@"height": @"1"},
@"r": @{@"height": @"1",@"master_secret": @"1"},
@"rctxt": @"1",
@"z": @"1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.concurrent.TimeUnit;

import static org.hamcrest.CoreMatchers.isA;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class CredDefRequestsTest extends LedgerIntegrationTest {
Expand All @@ -29,18 +30,17 @@ public void testBuildCredDefRequestWorks() throws Exception {
" \"primary\": {\n" +
" \"n\": \"1\",\n" +
" \"s\": \"2\",\n" +
" \"rms\": \"3\",\n" +
" \"r\": {\"name\": \"1\"},\n" +
" \"r\": {\"name\": \"1\",\"master_secret\": \"3\"},\n" +
" \"rctxt\": \"1\",\n" +
" \"z\": \"1\"\n" +
" }\n" +
" }\n" +
" }";

String expectedResult = "\"operation\": {\n" +
String expectedResult = "{\n" +
" \"ref\": 1,\n" +
" \"data\": {\n" +
" \"primary\": {\"n\": \"1\", \"s\": \"2\", \"rms\": \"3\", \"r\": {\"name\": \"1\"}, \"rctxt\": \"1\", \"z\": \"1\"}\n" +
" \"primary\": {\"n\": \"1\", \"s\": \"2\", \"r\": {\"name\": \"1\",\"master_secret\": \"3\"}, \"rctxt\": \"1\", \"z\": \"1\"}\n" +
" },\n" +
" \"type\": \"102\",\n" +
" \"signature_type\": \"CL\",\n" +
Expand All @@ -49,7 +49,7 @@ public void testBuildCredDefRequestWorks() throws Exception {

String credDefRequest = Ledger.buildCredDefRequest(DID, data).get();

assertTrue(credDefRequest.replaceAll("\\s+", "").contains(expectedResult.replaceAll("\\s+", "")));
assertTrue(new JSONObject(credDefRequest).getJSONObject("operation").similar(new JSONObject(expectedResult)));
}

@Test
Expand Down
5 changes: 2 additions & 3 deletions wrappers/python/tests/ledger/test_build_cred_def_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ async def test_build_cred_def_request_works_for_correct_data_json(did_trustee):
"primary": {
"n": "1",
"s": "2",
"rms": "3",
"r": {"name": "1"},
"r": {"name": "1", "master_secret": "3"},
"rctxt": "1",
"z": "1"
}
Expand All @@ -29,7 +28,7 @@ async def test_build_cred_def_request_works_for_correct_data_json(did_trustee):
"operation": {
"ref": 1,
"data": {
"primary": {"n": "1", "s": "2", "rms": "3", "r": {"name": "1"}, "rctxt": "1", "z": "1"}
"primary": {"n": "1", "s": "2", "r": {"name": "1", "master_secret": "3"}, "rctxt": "1", "z": "1"}
},
"type": "102",
"signature_type": "CL",
Expand Down

0 comments on commit a3eeb60

Please sign in to comment.