Skip to content

Commit

Permalink
feat: hedera test cases added :krypc (#14)
Browse files Browse the repository at this point in the history
* hedera: test cases added :krypc

* hedera: test cases added :krypc

* hedera: test cases added :krypc

* hedera: test cases added :krypc

* hedera: test cases added :krypc

* feat: hedera test cases added :krypc
  • Loading branch information
AnithaKrypC committed Mar 15, 2024
1 parent 9b60119 commit 6889368
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { v3, WrappedDocument } from "@tradetrust-tt/tradetrust";
import { documentHederaRevokedWithDocumentStore } from "../../../../test/fixtures/v2/documentHederaRevokedWithDocumentStore";
import { documentHederaValidWithDocumentStore as v2documentHederaValidWithDocumentStore } from "../../../../test/fixtures/v2/documentHederaValidWithDocumentStore";
import { documentMixedIssuance } from "../../../../test/fixtures/v2/documentMixedIssuance";
import { documentNotIssuedWithTokenRegistry } from "../../../../test/fixtures/v2/documentNotIssuedWithTokenRegistry";
import { openAttestationEthereumDocumentStoreStatus } from "./ethereumDocumentStoreStatus";

// v3 documents
import v3DocumentStoreIssuedRaw from "../../../../test/fixtures/v3/documentStore-issued.json";
import v3DocumentStoreWrappedRaw from "../../../../test/fixtures/v3/documentStore-wrapped.json";
import v3TokenRegistryIssuedRaw from "../../../../test/fixtures/v3/tokenRegistry-issued.json";
import { VerifierOptions } from "../../../types/core";

const v3DocumentStoreWrapped = v3DocumentStoreWrappedRaw as WrappedDocument<v3.OpenAttestationDocument>;
const v3DocumentStoreIssued = v3DocumentStoreIssuedRaw as WrappedDocument<v3.OpenAttestationDocument>;
const v3TokenRegistryIssued = v3TokenRegistryIssuedRaw as WrappedDocument<v3.OpenAttestationDocument>;

const options = {} as VerifierOptions;
//hederatestnet
describe("test", () => {
describe("v2", () => {
it("should return false when document does not have data", async () => {
const shouldVerify = await openAttestationEthereumDocumentStoreStatus.test(
{ ...v2documentHederaValidWithDocumentStore, data: null } as any,
options
);
expect(shouldVerify).toBe(false);
});
it("should return false when document does not have issuers", async () => {
const shouldVerify = await openAttestationEthereumDocumentStoreStatus.test(
{
...v2documentHederaValidWithDocumentStore,
data: { ...v2documentHederaValidWithDocumentStore.data, issuers: null },
} as any,
options
);
expect(shouldVerify).toBe(false);
});
it("should return false when document uses token registry", async () => {
const shouldVerify = await openAttestationEthereumDocumentStoreStatus.test(
documentNotIssuedWithTokenRegistry,
options
);
expect(shouldVerify).toBe(false);
});
it("should return true when document uses document store", async () => {
const shouldVerify = await openAttestationEthereumDocumentStoreStatus.test(
documentHederaRevokedWithDocumentStore,
options
);
expect(shouldVerify).toBe(true);
});
});
describe("v3", () => {
it("should return true for documents not yet issued via document store", async () => {
const shouldVerify = await openAttestationEthereumDocumentStoreStatus.test(v3DocumentStoreWrapped, options);
expect(shouldVerify).toBe(true);
});
it("should return true for documents issued via document store", async () => {
const shouldVerify = await openAttestationEthereumDocumentStoreStatus.test(v3DocumentStoreIssued, options);
expect(shouldVerify).toBe(true);
});
it("should return false for documents issued via token registry", async () => {
const shouldVerify = await openAttestationEthereumDocumentStoreStatus.test(v3TokenRegistryIssued, options);
expect(shouldVerify).toBe(false);
});
});
});

describe("verify", () => {
describe("v2", () => {
it("should return an invalid fragment when used with other issuance methods", async () => {
const fragment = await openAttestationEthereumDocumentStoreStatus.verify(documentMixedIssuance, options);

expect(fragment).toMatchInlineSnapshot(`
Object {
"data": [Error: Document store address not found in issuer DEMO STORE],
"name": "OpenAttestationEthereumDocumentStoreStatus",
"reason": Object {
"code": 7,
"codeString": "INVALID_ISSUERS",
"message": "Document store address not found in issuer DEMO STORE",
},
"status": "ERROR",
"type": "DOCUMENT_STATUS",
}
`);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ describe("verify", () => {
it("should return a valid fragment when document has valid identity and uses document store", async () => {
const fragment = await openAttestationDnsTxtIdentityProof.verify(documentHederaValidWithDocumentStore, options);
expect(fragment).toMatchInlineSnapshot(`
Object {
"data": Array [
Object {
"location": "trustlv.org",
"status": "VALID",
"value": "0x3DE43bfd3D771931E46CbBd4EDE0D3d95C85f81A",
},
],
"name": "OpenAttestationDnsTxtIdentityProof",
"status": "VALID",
"type": "ISSUER_IDENTITY",
}
`);
Object {
"data": Array [
Object {
"location": "trustlv.org",
"status": "VALID",
"value": "0x222B69788e2e9B7FB93a3a0fE258D4604Dc7df21",
},
],
"name": "OpenAttestationDnsTxtIdentityProof",
"status": "VALID",
"type": "ISSUER_IDENTITY",
}
`);
});
});
});
71 changes: 71 additions & 0 deletions test/fixtures/v2/documentHederaRevokedWithDocumentStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { SchemaId, v2, WrappedDocument } from "@tradetrust-tt/tradetrust";

interface CustomDocument extends v2.OpenAttestationDocument {
billTo: any;
network: {
chain: string;
chainId: string;
};
consignment: any;
declaration: any;
certification: any;
}

export const documentHederaRevokedWithDocumentStore: WrappedDocument<CustomDocument> = {
version: SchemaId.v2,
data: {
$template: {
name: "8f76e856-0695-4032-83f1-3e7a0e502b71:string:CERTIFICATE_OF_NON_MANIPULATION",
type: "9b10ec23-1ae4-401b-bc11-af9127f2dc4b:string:EMBEDDED_RENDERER",
url: "4d38de69-0622-4012-9316-38167b88f608:string:https://demo-cnm.openattestation.com",
},
billTo: {
name: "2fdf99b6-06f0-4d3c-87f5-8f8dde803b96:string:XYZ",
},
issuers: [
{
name: "ed31c75d-c0e4-4541-945f-0d9323068e2c:string:Demo Issuer",
documentStore: "3804f213-cb9d-4e2c-9051-d125ff63024f:string:0x222B69788e2e9B7FB93a3a0fE258D4604Dc7df21",
identityProof: {
type: "55592302-01e2-483b-967e-bb4239f79e49:string:DNS-TXT",
location: "82d945d8-35ef-4556-86c2-609a98549bfd:string:trustlv.org",
},
},
],
network: {
chain: "56221d22-bc28-4915-8a05-c3eb33724531:string:HBAR",
chainId: "b17571c7-c9c2-40af-b2d4-c14d8c7563c8:string:296",
},
consignment: {
description: "9f6661db-6465-4533-975b-d3b2df0152c5:string:16667 RED WINE",
quantity: {
value: "58b2fa48-b186-40d6-b722-75fab3365367:string:1000",
unit: "a8608e66-8356-4afa-b6bb-910506059d5a:string:LITRES",
},
countryOfOrigin: "c27d8e9d-b02c-47bf-87d5-740d0fc8a8e8:string:INDIA",
outwardBillNo: "e3a9c88e-0232-4884-8030-c3a3d206bc10:string:AQSIQ170923130",
dateOfDischarge: "477a597d-08d7-4b21-9e1b-c7af5c614661:string:2024-03-01",
dateOfDeparture: "22ecb19a-a148-432b-a21f-dd2abcab3b4e:string:2024-03-20",
countryOfFinalDestination: "bf10847d-ee86-4445-8c91-c149013bf5f5:string:SINGAPORE",
outgoingVehicleNo: "5708878e-9a66-4feb-9c8d-29e0ee936cfc:string:COSCO SING 074E/01-MAR",
},
declaration: {
name: "f733bb67-7273-406d-a8d4-70b6fe8d6c43:string:JOHN",
designation: "0b4603f2-e2b7-4081-a303-296304748b82:string:SHIPPING MANAGER",
date: "9506b5f1-6f0e-4a06-9ae4-eb7e869beebe:string:2024-03-01",
},
certification: {
name: "498463c7-2a70-45fa-bd50-5f2da3ec252c:string:DEMO JOHN TAN",
designation: "992d0be8-ed3d-4354-a0a1-d3360101ffb8:string:DEMO",
date: "8ae9b8f9-07c2-40a6-a711-220f82084f53:string:2024-03-01",
signature:
"57869919-e1e3-4549-9743-90ac71d7c453:string:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHYAAAB2CAMAAAAqeZcjAAAAb1BMVEX///8XGRwAAACRkZJ1dnfz8/MUFxoAAAkOEBQ+QEISExW2t7fj5OQTFRkFCQ4AAAYfISRubm/IyMjT09T5+fl7e3ydnZ4vMDKBgYLq6uqkpKWtra7Z2dlcXV5QUVNFRkc2NzgmJyplZma/v8CIiYnq/nZ7AAAF4ElEQVRogcVb2aKCIBCtKY0yQc2tRc3q/7/xZrKp4BZ5561EjrMyDMNqNZGs2/Oy2Wb70luvvTLJ/dfFOVlTZ5lENyfaw5sIRq69rshGeFf9k/iX008gwyBNMBBUw7XIPmAAz38a5jo8p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qtgvDsp39fwl5uySsMKl/ciAaLmDhcMGCo74o+JPg+E9LAdOyYi/chDW78DGFkGWXeZ7UaGsEP0lqeAqnddyfpHAsTGFtXd14wvrZjVAPcne/h5XT83/YjFTLznJbr6DB4OIbTe/za7FtNam9lpahjuhfighLl0w8+vjSb8umC0Ss6sikvHA5bNHi34EX//6r1LlkYdeV3HS5MnajBYR9y8JF+58fUURqcQ4cyOzwuAMZb+KBTP/x09PPXyOPn7Ls2pWXOH7quAp7gvWZ62zSH7ZJR4v6/cFMEkeLCg2KT5rZWaKj3oNU6dhYm97MIkuc+Cvn5eZm9pA8Zzt49SH5j1oCpEk1I8I76377RQOEfrdzQ6bbPaQ2k56Q7vBuI9ib0K9ogtIptiapladcrpXHbOOSRzjqQOOSrA27XzBDNKlNy1hTmj+tKa16gePig75c1UtPuQWvGGedqXhlZsPhdnrD4apKaUVfJoZ0antlPK+9stqNzW8mvdylj3anmeWpbLTOwvjW2UajOiYTu5G6jcLOjEbh+3TDuHTaonuvK4RB2moFR/PyFFUT+H7zVOjZCjYFNFux36wmc7MFx24Bf1reoYji6zMIqo735zWO8qqW0q7mkG86Ua0NtIGrclejwV91jQTD9osG/zed0+nXGXbw+P4CxzGdeHkD+2ZujZzjPZBRhUcbG7uqUlEYbEsgA8J2MXiZY/hKkBX4pdp+KCSsH47JRFfQ6Rrd69sp7UtXXhYHppJNJVm357VzxWwyl3+oR2ZAbpghWQAAAABJRU5ErkJggg==",
},
},
signature: {
type: "SHA3MerkleProof",
targetHash: "ab9040f1dce119c447a5eae6d08ec264f588350e47015d6aa32c49eb3ccdf60b",
proof: ["e3f42315d32b7d23942f2c140eb00254f120fc8b772c3ab771e36a2c17b5d4a7"],
merkleRoot: "fcea61cfe337f52c50ea52b2d092cbbcfe395b3e1880de148720b5a3cdd1539b",
},
};
54 changes: 39 additions & 15 deletions test/fixtures/v2/documentHederaValidWithDocumentStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,63 @@ interface CustomDocument extends v2.OpenAttestationDocument {
};
consignment: any;
declaration: any;
certification: any;
}
export const documentHederaValidWithDocumentStore: WrappedDocument<CustomDocument> = {
version: SchemaId.v2,
data: {
$template: {
name: "main",
type: "EMBEDDED_RENDERER",
url: "https://tutorial-renderer.openattestation.com",
name: "6bc6b7da-bf1d-4d54-a445-58c8534f622e:string:CERTIFICATE_OF_NON_MANIPULATION",
type: "ea285365-edda-458e-a5d9-581f8534b8a2:string:EMBEDDED_RENDERER",
url: "9fd7ef5f-24ee-44cb-b9ee-f1f0e5c558fb:string:https://demo-cnm.openattestation.com",
},
recipient: {
name: "KrypC - Piruthivi",
name: "3af83dd0-b2b3-474f-b951-2e22b31d7aad:string:XYZ",
address: {
street: "101 ORCHARD ROAD",
country: "SINGAPORE",
street: "f1ca022a-3f6b-4024-8d59-88816c5d7c87:string:42 BRIGADE ROAD",
country: "28b0ecca-e376-467a-b828-1b78627cd7d8:string:INDIA",
},
},
issuers: [
{
name: "KrypC Issuer",
tokenRegistry: "0x3DE43bfd3D771931E46CbBd4EDE0D3d95C85f81A",
name: "f233558c-e011-446a-84bb-701b16010257:string:Demo Issuer",
documentStore: "d478a47d-d9d3-4879-82b8-3643b332c82d:string:0x222B69788e2e9B7FB93a3a0fE258D4604Dc7df21",
identityProof: {
type: "DNS-TXT",
location: "trustlv.org",
type: "c0624592-af6c-436d-87a2-f4d02c277a60:string:DNS-TXT",
location: "5da286bd-6c42-4054-859e-e5661e78f306:string:trustlv.org",
},
},
],
consignment: {},
declaration: {},
consignment: {
description: "a371ecb9-e01f-4a57-bf00-b5704fba6fbc:string:16667 RED WINE",
quantity: {
value: "b45e8a3e-df98-4f5a-a2e0-5c780e57d648:string:1000",
unit: "21e2659e-a9a3-4d5f-95a9-32073c6e2d1d:string:LITRES",
},
countryOfOrigin: "0a58ba84-e35f-498d-b6e5-45d3ee48b519:string:INDIA",
outwardBillNo: "d78a523f-0819-4faa-8816-836427b20905:string:AQSIQ170923130",
dateOfDischarge: "0c6b0ef9-9418-43fb-944d-f5060c6557f4:string:2024-03-01",
dateOfDeparture: "ecb4655f-2c38-4965-8816-bce9d657f69f:string:2024-03-20",
countryOfFinalDestination: "32c8a550-bc72-488b-adfe-2df38b821671:string:SINGAPORE",
outgoingVehicleNo: "66dfd2c9-0052-4cd3-9962-6f35c9600ec1:string:COSCO SING 074E/01-MAR",
},
declaration: {
name: "0df36d67-fe76-436a-8cfd-3338a96e3b74:string:JOHN",
designation: "165d2b71-cca9-46f3-9d9e-dede1bbd6e42:string:SHIPPING MANAGER",
date: "1efca0d5-9792-4134-8e74-ec3e0c0ff292:string:2024-03-01",
},
certification: {
name: "3a1d00f0-b519-4d16-a4ce-e101cf66f667:string:DEMO JOHN TAN",
designation: "cc543b1d-9a7d-4366-ad21-b4f31a9ce173:string:DEMO",
date: "48b90f5c-37d2-4ff1-800d-45b8160eddd7:string:2024-03-01",
signature:
"57069b0b-7261-484e-af49-d0daeeaeee5e:string:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHYAAAB2CAMAAAAqeZcjAAAAb1BMVEX///8XGRwAAACRkZJ1dnfz8/MUFxoAAAkOEBQ+QEISExW2t7fj5OQTFRkFCQ4AAAYfISRubm/IyMjT09T5+fl7e3ydnZ4vMDKBgYLq6uqkpKWtra7Z2dlcXV5QUVNFRkc2NzgmJyplZma/v8CIiYnq/nZ7AAAF4ElEQVRogcVb2aKCIBCtKY0yQc2tRc3q/7/xZrKp4BZ5561EjrMyDMNqNZGs2/Oy2Wb70luvvTLJ/dfFOVlTZ5lENyfaw5sIRq69rshGeFf9k/iX008gwyBNMBBUw7XIPmAAz38a5jo8pQnAQQnJySVQPgwin+MCwO2FFMhJejMCeow8QGMwKTKQx/dqPkYjGRVkE/gS2EoBuvxgAjLh7mdh8I/zUa+oDYreMHYexU5wqigInPiVlRV2y9x2sJkJesyhOdfbSYqNylTDU5xBWxlQBnNQY8AtzO0z7Bl/enlA5O90YTsZ1MpkVm2ArBezpsBvsgzJRGcKvJ0MitORFm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najBYR9y8JF+58fUURqcQ4cyOzwuAMZb+KBTP/x09PPXyOPn7Ls2pWXOH7quAp7gvWZ62zSH7ZJR4v6/cFMEkeLCg2KT5rZWaKj3oNU6dhYm97MIkuc+Cvn5eZm9pA8Zzt49SH5j1oCpEk1I8I76377RQOEfrdzQ6bbPaQ2k56Q7vBuI9ib0K9ogtIptiapladcrpXHbOOSRzjqQOOSrA27XzBDNKlNy1hTmj+tKa16gePig75c1UtPuQWvGGedqXhlZsPhdnrD4apKaUVfJoZ0antlPK+9stqNzW8mvdylj3anmeWpbLTOwvjW2UajOiYTu5G6jcLOjEbh+3TDuHTaonuvK4RB2moFR/PyFFUT+H7zVOjZCjYFNFux36wmc7MFx24Bf1reoYji6zMIqo735zWO8qqW0q7mkG86Ua0NtIGrclejwV91jQTD9osG/zed0+nXGXbw+P4CxzGdeHkD+2ZujZzjPZBRhUcbG7uqUlEYbEsgA8J2MXiZY/hKkBX4pdp+KCSsH47JRFfQ6Rrd69sp7UtXXhYHppJNJVm357VzxWwyl3+oR2ZAbpghWQAAAABJRU5ErkJggg==",
},
},
signature: {
type: "SHA3MerkleProof",
targetHash: "1fdea9b542ec22f7d87f23d86f1cf3e526e2edec1b9baaa9aedff904efea78a9",
proof: [],
merkleRoot: "1fdea9b542ec22f7d87f23d86f1cf3e526e2edec1b9baaa9aedff904efea78a9",
targetHash: "f3488cf45a2d0cee14d28a115787daf1521fafadbf5617a1f04183ab90c8be71",
proof: ["c6d865ac5803a8d7cbaba58136d14c0b832de06af2e899829b1a73913e4dd9f3"],
merkleRoot: "139576d4803d4220368446c0f6f2803a702ccf8a93dd529596f17b96a647a524",
},
};

0 comments on commit 6889368

Please sign in to comment.