Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 9806128

Browse files
committed
fix: failing tests
1 parent 2639065 commit 9806128

File tree

5 files changed

+185
-1922
lines changed

5 files changed

+185
-1922
lines changed

examples/browser-angular/src/app/ipfs.service.ts

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -60,119 +60,4 @@ export class IpfsService {
6060
const node = await this.ipfs;
6161
return await node.isOnline();
6262
}
63-
64-
/**
65-
* @description Add a file with the given options
66-
* @param {IPFS_UTILS_TYPES.ImportCandidate} entry
67-
* @param {IPFS_ROOT_TYPES.AddOptions} [options={}]
68-
* @return {Promise<IPFS_ROOT_TYPES.AddResult>}
69-
*/
70-
async add(entry: IPFS_UTILS_TYPES.ImportCandidate, options: IPFS_ROOT_TYPES.AddOptions = {}): Promise<IPFS_ROOT_TYPES.AddResult>{
71-
console.log(`Adding file ${entry} ...`)
72-
console.log(entry)
73-
74-
const node = await this.ipfs
75-
const result = await node.add(entry, options)
76-
77-
this._ipfsSource.next(node);
78-
console.log(result)
79-
return result;
80-
}
81-
82-
/**
83-
* @description Add files with the given options
84-
* @param {IPFS_UTILS_TYPES.ImportCandidate[]} entries
85-
* @param {IPFS_ROOT_TYPES.AddAllOptions} [options={}]
86-
* @return {Promise<IPFS_ROOT_TYPES.AddResult[]>}
87-
*/
88-
async addAll(entries: IPFS_UTILS_TYPES.ImportCandidate[], options: IPFS_ROOT_TYPES.AddAllOptions = {}): Promise<IPFS_ROOT_TYPES.AddResult[]>{
89-
console.log("Adding files...")
90-
const results = []
91-
const node = await this.ipfs
92-
93-
for await (const result of node.addAll(entries, options)) {
94-
console.log(result)
95-
results.push(result)
96-
}
97-
98-
this._ipfsSource.next(node);
99-
return results;
100-
}
101-
102-
/**
103-
* @description Get file(s) of a given path
104-
* @param {IPFS_UTILS_TYPES.IPFSPath} ipfsPath
105-
* @param {IPFS_ROOT_TYPES.GetOptions} [options={}]
106-
* @param {boolean} [onlyFiles=true]
107-
* @return {Promise<Array<[IPFS_ROOT_TYPES.IPFSEntry, string]>>}
108-
*/
109-
async get(ipfsPath: IPFS_UTILS_TYPES.IPFSPath, options: IPFS_ROOT_TYPES.GetOptions = {}, onlyFiles = true):
110-
Promise<Array<[IPFS_ROOT_TYPES.IPFSEntry, string]>>{
111-
console.log(`Returning file for ${ipfsPath}...`)
112-
const results = [] as Array<[IPFS_ROOT_TYPES.IPFSEntry, string]>
113-
const node = await this.ipfs
114-
115-
for await (const file of node.get(ipfsPath, options)) {
116-
const content = []
117-
118-
if ('content' in file && file.content) {
119-
for await (const chunk of file.content) {
120-
content.push(chunk)
121-
}
122-
}
123-
124-
if (content.length > 0 || !onlyFiles) {
125-
results.push([file, content.toString()])
126-
}
127-
}
128-
129-
console.log(results)
130-
return results
131-
}
132-
133-
/**
134-
* @description Read a file
135-
* @param {IPFS_UTILS_TYPES.IPFSPath} ipfsPath
136-
* @param {IPFS_ROOT_TYPES.CatOptions} [options={}]
137-
* @return {(Promise<string | null>)}
138-
*/
139-
async cat (ipfsPath: IPFS_UTILS_TYPES.IPFSPath, options: IPFS_ROOT_TYPES.CatOptions = {}):
140-
Promise<string | null> {
141-
console.log(`Reading file for ${ipfsPath} ...`);
142-
const content = []
143-
const node = await this.ipfs
144-
145-
for await (const chunk of node.cat(ipfsPath, options)) {
146-
content.push(chunk)
147-
}
148-
149-
let result = null;
150-
151-
if (content.length > 0) {
152-
result = content.toString();
153-
}
154-
155-
console.log(content)
156-
return result;
157-
}
158-
159-
/**
160-
* @description List the file(s) and directory(ies) of a given path
161-
* @param {IPFS_UTILS_TYPES.IPFSPath} ipfsPath
162-
* @param {IPFS_ROOT_TYPES.ListOptions} [options={}]
163-
* @returns {Promise<Array<IPFS_ROOT_TYPES.IPFSEntry>>}
164-
*/
165-
async ls (ipfsPath: IPFS_UTILS_TYPES.IPFSPath, options: IPFS_ROOT_TYPES.ListOptions = {}):
166-
Promise<Array<IPFS_ROOT_TYPES.IPFSEntry>> {
167-
console.log(`Listing files for ${ipfsPath} ...`);
168-
const result = [];
169-
const node = await this.ipfs
170-
171-
for await (const data of node.ls(ipfsPath, options)) {
172-
result.push(data)
173-
}
174-
175-
console.log(result)
176-
return result;
177-
}
17863
}

examples/browser-exchange-files/tests/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ play.describe('upload file using http client: ', () => {
6767
const WORKSPACE = 'test-workspace'
6868

6969
const connect = async (page, address, workspace, remotePeerId) => {
70+
await page.waitForTimeout(2000)
7071
await page.waitForSelector(connectedPeers)
7172

7273
await page.fill(multiAddressInput, address)
@@ -79,6 +80,7 @@ play.describe('upload file using http client: ', () => {
7980
await page.click(workspaceBtn)
8081

8182
await page.waitForSelector(`${workspacePeers}:has-text('${remotePeerId}')`)
83+
await page.waitForTimeout(2000)
8284
}
8385

8486
let sigServer;

examples/browser-nextjs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
},
1414
"dependencies": {
1515
"ipfs": "^0.57.0",
16-
"next": "11.1.0",
16+
"next": "11.0.0",
1717
"react": "17.0.2",
1818
"react-dom": "17.0.2"
1919
},
2020
"devDependencies": {
2121
"@playwright/test": "^1.12.3",
2222
"eslint": "7.32.0",
23-
"eslint-config-next": "11.1.0",
23+
"eslint-config-next": "11.0.0",
2424
"playwright": "^1.12.3",
2525
"rimraf": "^3.0.2",
2626
"test-util-ipfs-example": "^1.0.0"

examples/custom-libp2p/tests/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { node } = require('test-util-ipfs-example');
55
const Libp2p = require('libp2p')
66
const TCP = require('libp2p-tcp')
77
const MPLEX = require('libp2p-mplex')
8-
const { NOISE } = require('libp2p-noise')
8+
const { NOISE } = require('@chainsafe/libp2p-noise')
99
const PeerId = require('peer-id')
1010
const uint8ArrayToString = require('uint8arrays/to-string')
1111

0 commit comments

Comments
 (0)