Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updated dataset (2023-11-17) #112

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import http from 'node:http'
import fs from 'node:fs'

export default {
tsRepo: false,
dependencyCheck: {
Expand All @@ -20,14 +23,40 @@ export default {
}
},
test: {
before: (...args) => {
if (args[0].runner === 'node') {
return {
env: {
NODE_OPTIONS: '--loader=esmock'
}
before: async (...args) => {
// set up a server to serve the fixtures
const server = http.createServer((req, res) => {
const cidString = req.url.replace('/ipfs/', '').split('?')[0]
const mockBlock = fs.readFileSync(`./test/fixtures/${cidString}.raw.bin`, null)

res.writeHead(200, {
'access-control-allow-origin': '*', // allow CORS requests
'Content-Type': 'application/vnd.ipld.raw',
'Content-Length': mockBlock.length
})
res.end(mockBlock)
})
let gwUrl = process.env.IPFS_GATEWAY
if (!gwUrl) {
// no gateway specified, start the server
await new Promise((resolve, _reject) => {
server.listen(0, () => {
gwUrl = `http://localhost:${server.address().port}`
console.log(`server listening at ${gwUrl}`)
resolve()
})
})
}

return {
server,
env: {
IPFS_GATEWAY: gwUrl,
}
}
},
after: (_, before) => {
before.server.close()
}
}
}
8 changes: 7 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": true
}
},
"ignorePatterns": [
"**/bin/load-fixtures.sh",
"**/dist/**",
"**/node_modules/**",
"**/test/fixtures/**"
],
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ build
node_modules

dist
ipfs-geoip.car
9 changes: 9 additions & 0 deletions DEVELOPER-NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Load fixtures

We need to load a fixture with the following command:

```bash
./bin/load-fixtures.sh bafyreif3tfdpr5n4jdrbielmcapwvbpcthepfkwq2vwonmlhirbjmotedi
```

then, we can do `npm run test:node -- -g 'lookup via HTTP Gateway'` to run a test that will tell us of any subsequent fixtures we need to load, and replace the CID in the above command with the CID that the test hangs on, and repeat.
2 changes: 1 addition & 1 deletion bin/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint no-console: "off", no-unreachable: "off" */
import Gauge from 'gauge'
import gen from '../src/generate/index.js'
import { create } from 'ipfs-http-client'
import { create } from 'kubo-rpc-client'
import { CarWriter } from '@ipld/car'
import fs from 'fs'
import { Readable } from 'stream'
Expand Down
8 changes: 8 additions & 0 deletions bin/load-fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

function main() {
local CID="$1"
curl -H "Accept: application/vnd.ipld.raw" "https://ipfs.io/ipfs/$CID?format=raw" > test/fixtures/$CID.raw.bin
}

main "$@"
Loading