forked from Open-Attestation/oa-verify
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hedera test cases added :krypc (#14)
* 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
1 parent
9b60119
commit 6889368
Showing
4 changed files
with
213 additions
and
28 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
src/verifiers/documentStatus/documentStore/hederaDocumentStoreStatus.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
} | ||
`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
test/fixtures/v2/documentHederaRevokedWithDocumentStore.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/iX008gwyBNMBBUw7XIPmAAz38a5jo8pQnAQQnJySVQPgwin+MCwO2FFMhJejMCeow8QGMwKTKQx/dqPkYjGRVkE/gS2EoBuvxgAjLh7mdh8I/zUa+oDYreMHYexU5wqigInPiVlRV2y9x2sJkJesyhOdfbSYqNylTDU5xBWxlQBnNQY8AtzO0z7Bl/enlA5O90YTsZ1MpkVm2ArBezpsBvsgzJRGcKvJ0MitORFmLFJRxkU7hOQb1InmqDtzmPf9W6JhLHNqTjX91IAibwmgD6Ab54kgOAP6ycmiLxlgvZjFh3jiRpQT4qTIdbgYoPk3QjKEhgIq4vvzA71rw/nisK9sO4gld3dqD5kCMEDcWQfoVeETy/QX3nIiUIsfUPjfnInff1umnlAvfRN/AqxhUm0gShsT7/vfE1bKTVD5LQmT5ehQnivI718SHi/Lqg8wruOvhuLhF7iEnVAxw2AKGJ4bCXCsJE+FI9tlgEd4nRTNsquepU83IRg2MSVTJUdO8+DDjqhKVqHHHtKcLena7OuDCNKpkztI3mQp/YWBGcnEcxLr2w4jy7dP8O71S94LfGl1T+EHff8gG/E9UReeCxBIxV8e3J2W0yxWIxVsSJWjUIDcPmRGccTMy7BruCWQVPGdY+apJVz+2uu4/ObLfYYJdplvjdN1Z7NNKvjvUs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Xbw+P4CxzGdeHkD+2ZujZzjPZBRhUcbG7uqUlEYbEsgA8J2MXiZY/hKkBX4pdp+KCSsH47JRFfQ6Rrd69sp7UtXXhYHppJNJVm357VzxWwyl3+oR2ZAbpghWQAAAABJRU5ErkJggg==", | ||
}, | ||
}, | ||
signature: { | ||
type: "SHA3MerkleProof", | ||
targetHash: "ab9040f1dce119c447a5eae6d08ec264f588350e47015d6aa32c49eb3ccdf60b", | ||
proof: ["e3f42315d32b7d23942f2c140eb00254f120fc8b772c3ab771e36a2c17b5d4a7"], | ||
merkleRoot: "fcea61cfe337f52c50ea52b2d092cbbcfe395b3e1880de148720b5a3cdd1539b", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters