-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds ipfs reading / conversion tests Signed-off-by: Stefan Adolf <[email protected]>
- Loading branch information
1 parent
c38ef8a
commit 05a2fbb
Showing
5 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2,3 +2,6 @@ node_modules | |
|
||
build/ | ||
generated | ||
|
||
tests/.bin | ||
.latest.json |
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
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
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,83 @@ | ||
{ | ||
"schema_version": "0.0.1", | ||
"name": "Our awesome test IP-NFT", | ||
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...", | ||
"image": "ipfs://bafkreih5d2453qzkprn35zm4gj5ff6ezroevnaaygxqlwcbqq2tg7ebbe4", | ||
"external_url": "https://testnet.mint.molecule.to/ipnft/76", | ||
"terms_signature": "0x1f030b9f1a91d74610cb296aa87f12b2207d2b336766fffad8c53b825f1bee7d30f3665076102fe635dd3664d564ae1e5e746794b58e8861feafacfa6767ea491b", | ||
"properties": { | ||
"type": "IP-NFT", | ||
"initial_symbol": "AWSOME", | ||
"agreements": [ | ||
{ | ||
"type": "Research Agreement", | ||
"url": "ipfs://bafkreigqttkfe2vsgddhy4ohf3qs3eyacdz2vwindo33y7jefox3377yqq", | ||
"mime_type": "application/pdf", | ||
"content_hash": "bagaaiera7ftqs3jmnoph3zgq67bgjrszlqtxkk5ygadgjvnihukrqioipndq", | ||
"encryption": { | ||
"protocol": "lit", | ||
"encrypted_sym_key": "dff20fe5fc6aace9669a2afc25745350208825c073c6b8e280dbf02ca772747288e3f0ea122cb89dd9531331bf828819f98c24aa675966c236159c75461a182759d1f3fc9322932cb69ed7f4c125685362137b28fac26069a0fe6a304c8dd28a64ab484b7f610d608232c9104f155b38344fc79992a2a1afabf8137395e1c4f40000000000000020990610adf31cab49dddf73c9466772c96d9c85e48fc6bf8a29da685b204b6cb03ea6509ddf117ae3a52ee637d450e08b", | ||
"access_control_conditions": [ | ||
{ | ||
"conditionType": "evmContract", | ||
"contractAddress": "0x152B444e60C526fe4434C721561a077269FcF61a", | ||
"chain": "sepolia", | ||
"functionName": "canRead", | ||
"functionParams": [":userAddress", "76"], | ||
"functionAbi": { | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "reader", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "tokenId", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "canRead", | ||
"outputs": [ | ||
{ | ||
"internalType": "bool", | ||
"name": "", | ||
"type": "bool" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
"returnValueTest": { | ||
"key": "", | ||
"comparator": "=", | ||
"value": "true" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Assignment Agreement", | ||
"url": "ipfs://bafkreihzm4ew2ldltz66juhxyjsmmwk4e52sxobqazsnlkb5cumcdsd3i4", | ||
"mime_type": "application/pdf", | ||
"content_hash": "bagaaiera7ftqs3jmnoph3zgq67bgjrszlqtxkk5ygadgjvnihukrqioipndq" | ||
} | ||
], | ||
"project_details": { | ||
"industry": "Space Exploration", | ||
"organization": "NASA", | ||
"topic": "Wormholes", | ||
"funding_amount": { | ||
"value": 1234.5678, | ||
"decimals": 2, | ||
"currency": "USD", | ||
"currency_type": "ISO4217" | ||
}, | ||
"research_lead": { | ||
"name": "Carl Sagan", | ||
"email": "[email protected]" | ||
} | ||
} | ||
} | ||
} |
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,28 @@ | ||
import { ipfs } from "@graphprotocol/graph-ts" | ||
import { assert, describe, mockIpfsFile, test } from 'matchstick-as/assembly/index' | ||
import { handleMetadata } from '../src/metadataMapping' | ||
|
||
const IPNFT_METADATA = "IpnftMetadata" | ||
|
||
describe('Metadata', () => { | ||
//https://thegraph.com/docs/en/subgraphs/developing/creating/unit-testing-framework/#mocking-ipfs-files-from-matchstick-041 | ||
|
||
test('reads ipnft metadata', () => { | ||
|
||
mockIpfsFile('ipfsCatBaseIpnft', 'tests/fixtures/ipnft_1.json') | ||
|
||
let rawData = ipfs.cat("ipfsCatBaseIpnft") | ||
if (!rawData) { | ||
throw new Error("Failed to fetch ipfs data") | ||
} | ||
|
||
handleMetadata(rawData) | ||
assert.entityCount(IPNFT_METADATA, 1) | ||
assert.fieldEquals(IPNFT_METADATA, '', 'topic', 'Wormholes') | ||
assert.fieldEquals(IPNFT_METADATA, '', 'fundingAmount_value', '1234.5678') | ||
assert.fieldEquals(IPNFT_METADATA, '', 'fundingAmount_currency', 'USD') | ||
|
||
//logStore() | ||
}) | ||
}) | ||
|