Ejemplo n.º 1
0
        [TestMethod] //This test fails here and in the Java version.
        public async Task TestGetTxnRequestWorks()
        {
            var didJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";

            var didResult = await Signus.CreateAndStoreMyDidAsync(_wallet, didJson);

            var did = didResult.Did;

            var schemaData = "{\"name\":\"gvt2\",\"version\":\"3.0\",\"attr_names\": [\"name\", \"male\"]}";

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, schemaData);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = schemaResponseObj["result"].Value <int>("seqNo");

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(_pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            var returnedSchemaData = getTxnResponseObj["result"]["data"]["data"];
            var expectedSchemaData = JToken.Parse(schemaData);

            Assert.IsTrue(JToken.DeepEquals(expectedSchemaData, returnedSchemaData));
        }
        [TestMethod] //This test fails here and in the Java version.
        public async Task TestGetTxnRequestWorks()
        {
            var did = await CreateStoreAndPublishDidFromTrusteeAsync();

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = schemaResponseObj["result"]["txnMetadata"].Value <int>("seqNo");

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, null, seqNo);

            var expectedData = "{\"name\":\"gvt\",\"version\":\"1.0\",\"attr_names\": [\"name\"]}";

            var getTxnResponse = await PoolUtils.EnsurePreviousRequestAppliedAsync(pool, getTxnRequest, response => {
                var getTxnResponseObj    = JObject.Parse(response);
                var schemaTransactionObj = getTxnResponseObj["result"]["data"]["txn"]["data"]["data"];

                return(JValue.DeepEquals(JObject.Parse(expectedData), schemaTransactionObj));
            });

            Assert.IsNotNull(getTxnResponse);
        }
Ejemplo n.º 3
0
        public async Task TestGetTxnRequestWorksForInvalidSeqNo()
        {
            var didJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";

            var didResult = await Signus.CreateAndStoreMyDidAsync(_wallet, didJson);

            var did = didResult.Did;

            var schemaData = "{\"name\":\"gvt2\",\"version\":\"3.0\",\"attr_names\": [\"name\", \"male\"]}";

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, schemaData);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = (int)schemaResponseObj["result"]["seqNo"] + 1;

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(_pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            Assert.IsFalse(getTxnResponseObj["result"]["data"].HasValues);
        }
Ejemplo n.º 4
0
        [TestMethod] //This test fails here and in the Java version.
        public async Task TestGetTxnRequestWorks()
        {
            var didResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var did = didResult.Did;

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = schemaResponseObj["result"].Value <int>("seqNo");

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            var returnedSchemaData = getTxnResponseObj["result"]["data"]["data"];
            var expectedSchemaData = JToken.Parse(SCHEMA_DATA);

            Assert.IsTrue(JToken.DeepEquals(expectedSchemaData, returnedSchemaData));
        }
        /// <inheritdoc />
        public virtual async Task <string> LookupTransactionAsync(Pool pool, string submitterDid, string ledgerType, int sequenceId)
        {
            var req = await Ledger.BuildGetTxnRequestAsync(submitterDid, ledgerType, sequenceId);

            var res = await Ledger.SubmitRequestAsync(pool, req);

            return(res);
        }
Ejemplo n.º 6
0
        public async Task TestBuildGetTxnRequestWorks()
        {
            var data = 1;

            var expectedResult = string.Format("\"identifier\":\"{0}\"," +
                                               "\"operation\":{{" +
                                               "\"type\":\"3\"," +
                                               "\"data\":{1}", DID1, data);

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(DID1, LEDGER_TYPE, data);

            Assert.IsTrue(getTxnRequest.Replace("\\", "").Contains(expectedResult));
        }
        public async Task TestBuildGetTxnRequestWorksForLedgerType()
        {
            var seq_no = 1;

            var expectedResult = string.Format("\"identifier\":\"{0}\"," +
                                               "\"operation\":{{" +
                                               "\"type\":\"3\"," +
                                               "\"data\":{1}," +
                                               "\"ledgerId\":0" +
                                               "}}", DID, seq_no);

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(DID, "POOL", seq_no);

            Assert.IsTrue(getTxnRequest.Replace("\\", "").Contains(expectedResult));
        }
Ejemplo n.º 8
0
        public async Task TestBuildGetTxnRequestWorks()
        {
            var identifier = "Th7MpTaRZVRYnPiabds81Y";
            var data       = 1;

            var expectedResult = string.Format("\"identifier\":\"{0}\"," +
                                               "\"operation\":{{" +
                                               "\"type\":\"3\"," +
                                               "\"data\":{1}" +
                                               "}}", identifier, data);

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(identifier, data);

            Assert.IsTrue(getTxnRequest.Replace("\\", "").Contains(expectedResult));
        }
Ejemplo n.º 9
0
        public async Task TestGetTxnRequestWorksForInvalidSeqNo1()
        {
            var didResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var did = didResult.Did;

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA);

            var seqNo = 1;

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, LEDGER_TYPE, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            Assert.IsNotNull(getTxnResponseObj["result"]["data"]);
        }
        public async Task TestGetTxnRequestWorksForInvalidSeqNo()
        {
            var did = await CreateStoreAndPublishDidFromTrusteeAsync();

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = (int)schemaResponseObj["result"]["txnMetadata"]["seqNo"] + 1;

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, null, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            Assert.IsTrue(getTxnResponseObj["result"]["data"] != null);
        }
Ejemplo n.º 11
0
        public async Task TestGetTxnRequestWorksForInvalidSeqNo()
        {
            var didResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var did = didResult.Did;

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = (int)schemaResponseObj["result"]["seqNo"] + 1;

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            Assert.IsFalse(getTxnResponseObj["result"]["data"].HasValues);
        }