You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a test in my software that broke the moment I moved from 2.3.0 to 4.2.1. So I created a mocha test with pure Helia to illustrate my problem.
describe("pin|unpin|isPinned", function() {
this.timeout(15000)
it("should pin successfully", async() => {
const { createHelia } = await import('helia')
const helia = await createHelia({})
const heliaJson = json(helia)
const obj = {x:1, y:2}
const cid = await heliaJson.add(obj)
var pre = await helia.pins.add(cid)
for (var x in pre){
console.log(JSON.stringify(pre))
}
var result = await helia.pins.isPinned(cid)
expect(result).to.be.true //<--- breaks because its not true
await helia.stop()
})
})
The object is retrievable from the datastore. The generator recovered from the act of pinning ('variable name pre') does not have the passed in cid and ispinned always returns false. I would expect it to be true as it was in 2.3.0.
The text was updated successfully, but these errors were encountered:
const cid = CID.parse('QmFoo')
for await (const pinnedCid of helia.pins.add(cid)) {
// ...
}
In your test, you're using the helia.pins.add method with a single parameter (cid) and then trying to iterate over the result using a for...in loop. However, since add now returns an AsyncGenerator, you should use a for await...of loop instead.
change this code:
var pre = await helia.pins.add(cid)
for (var x in pre){
console.log(JSON.stringify(pre))
}
to
// Use the AsyncGenerator to pin the CID
for await (const pinnedCid of helia.pins.add(cid)) {
console.log(`Pinned CID: ${pinnedCid}`);
}
I have a test in my software that broke the moment I moved from 2.3.0 to 4.2.1. So I created a mocha test with pure Helia to illustrate my problem.
The object is retrievable from the datastore. The generator recovered from the act of pinning ('variable name pre') does not have the passed in cid and ispinned always returns false. I would expect it to be true as it was in 2.3.0.
The text was updated successfully, but these errors were encountered: