forked from ipfs-shipyard/ipfs-protocol-compliance-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip: prep for fleek publishing * fix: no raw leaves We want to reuse pinning provided by Fleek, but atm it uses CIDv0, which does not support raw leaves. By disabling raw leaves in CIDv1 add, we get the same underlying dag-pb, and the same multihash inside of both CIDv1 used in tests and CIDv0 produced by Fleek. * Add DELETE tests, add DAG tests, clean up README, fix empty dir test with fleek, disable Worker tests Co-authored-by: Marcin Rataj <lidel@lidel.org>
- Loading branch information
1 parent
c2ac95b
commit e057640
Showing
9 changed files
with
237 additions
and
10 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
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,134 @@ | ||
/* global | ||
promise_test, | ||
assert_true, | ||
assert_equals, | ||
fetch, | ||
*/ | ||
|
||
import { | ||
URL_IPFS_TEXT_FILE_RAW | ||
} from './constants.js' | ||
|
||
// TODO: These tests currently don't pass in any browsers. | ||
// Based on https://github.com/ipfs/go-ipfs/issues/8234 | ||
// Work on this is pending on gateway support / API availability | ||
|
||
promise_test(async (t) => { | ||
const response = await fetch(URL_IPFS_TEXT_FILE_RAW + '?format=car') | ||
|
||
assert_true(response.ok, 'Able to get CID') | ||
|
||
assert_true(response.headers.get('Content-Type').includes('application/octet-stream'), 'Got binary content type') | ||
|
||
const content = await response.arrayBuffer() | ||
|
||
assert_true(content.byteLength > 0, 'Content is non-empty') | ||
// TODO: Check the content format | ||
}, 'GET CID as a CAR file') | ||
promise_test(async (t) => { | ||
const response = await fetch(URL_IPFS_TEXT_FILE_RAW + '?format=block') | ||
|
||
assert_true(response.ok, 'Able to get CID') | ||
|
||
assert_true(response.headers.get('Content-Type').includes('application/octet-stream'), 'Got binary content type') | ||
|
||
const content = await response.arrayBuffer() | ||
|
||
assert_true(content.byteLength > 0, 'Content is non-empty') | ||
// TODO: Check the content format | ||
}, 'GET CID as a block') | ||
promise_test(async (t) => { | ||
const response = await fetch(URL_IPFS_TEXT_FILE_RAW + '?format=dag-json') | ||
|
||
assert_true(response.ok, 'Able to get CID') | ||
|
||
assert_true(response.headers.get('Content-Type').includes('application/json'), 'Got binary content type') | ||
|
||
const content = await response.json() | ||
|
||
assert_true(content && Object.keys(content).length !== 0, 'Content is non-empty') | ||
// TODO: Check the content format | ||
}, 'GET CID as a dag-json file') | ||
promise_test(async (t) => { | ||
const response = await fetch(URL_IPFS_TEXT_FILE_RAW + '?format=dag-cbor') | ||
|
||
assert_true(response.ok, 'Able to get CID') | ||
|
||
assert_true(response.headers.get('Content-Type').includes('application/cbor'), 'Got binary content type') | ||
|
||
const content = await response.arrayBuffer() | ||
|
||
assert_true(content.byteLength > 0, 'Content is non-empty') | ||
// TODO: Check the content format | ||
}, 'GET CID as a dag-cbor file') | ||
|
||
promise_test(async (t) => { | ||
// Data will be saved as dag-cbor | ||
const postResponse = await fetch('ipfs://?format=dag-cbor', { | ||
method: 'POST', | ||
headers: { | ||
// Data is represented as JSON before it's converted | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
hello: 'World' | ||
}) | ||
}) | ||
|
||
assert_true(postResponse.ok, 'Able to POST JSON') | ||
|
||
const url = await postResponse.text() | ||
|
||
assert_true(url.startsWith('ipfs://'), 'Returned IPFS URL') | ||
|
||
const getResponse = await fetch(url + '?format=dag-cbor') | ||
|
||
assert_true(getResponse.ok, 'Able to get CID') | ||
|
||
assert_true(getResponse.headers.get('Content-Type').includes('application/cbor'), 'Got binary content type') | ||
|
||
const content = await getResponse.arrayBuffer() | ||
|
||
assert_true(content.byteLength > 0, 'Content is non-empty') | ||
}, 'POST JSON, get CBOR from CID') | ||
promise_test(async (t) => { | ||
const postResponse1 = await fetch('ipfs://?format=dag-cbor', { | ||
method: 'POST', | ||
headers: { | ||
// Data is represented as JSON before it's converted | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
hello: 'World' | ||
}) | ||
}) | ||
|
||
assert_true(postResponse1.ok, 'Able to POST JSON') | ||
|
||
const url1 = await postResponse1.text() | ||
|
||
const postResponse2 = await fetch(url1 + '/newField?format=dag-cbor', { | ||
method: 'POST', | ||
headers: { | ||
// Data is represented as JSON before it's converted | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
goodbye: 'World' | ||
}) | ||
}) | ||
|
||
assert_true(postResponse2.ok, 'Able to POST over CID') | ||
|
||
const url2 = await postResponse2.text() | ||
|
||
assert_true(url2.startsWith('ipfs://'), 'Returned IPFS URL') | ||
|
||
const getResponse = await fetch(url2 + '?format=dag-json') | ||
|
||
assert_true(getResponse.ok, 'Able to GET new CID') | ||
|
||
const content = await getResponse.json() | ||
|
||
assert_equals(content?.newKey?.goodbye, 'world', 'Subkey got added to content') | ||
}, 'POST JSON (as cbor), POST on top of CID, get 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<title>IPFS Protocol Compliance Suite - DAG</title> | ||
|
||
<script src="testharness/testharness.js"></script> | ||
<script src="testharness/testharnessreport.js"></script> | ||
|
||
<script type="module" src="dag-tests.js"></script> |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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