-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Conversation
Also, validate that a block is not pinned before removing it.
11a877d
to
ca24f36
Compare
Needs ipfs/interop#89 for CI to pass. |
Hmmm this broke few things 😅 First of all the change of taking multiple CIDs into Second of all quiet, some tests were expecting for Lastly one general question about programming attitude. When you have bulk operations (like bulk remove of blocks), do you fail-fast or do as much as possible? From the perspective of the backward compatibility of this change, it would make sense to fail-fast and don't catch the exceptions, but not sure what is the general approach about this across IPFS JS-land... |
Looks like that test should be refactored to enforce that the exception is thrown, if that's valid behaviour e.g: // Second rm should fail because GC has already removed that block
await rm2.then(
() => expect.fail('should have thrown when trying to remove already removed block'),
(err) => expect(err.code).eql(Errors.dbDeleteFailedError().code)
) I think in general we try to fail fast, but there are a few exceptions. |
I see, alright make sense. Sure, I will do that. But at the same time, looking on diff of this PR, it is bit suspicious that you did not change any tests which would depend on |
All the tests in this repo passed, plus most of the In general we want to add tests there and not here where possible so they get run against Side note: I find this sort of development flow hard to work with, maybe you do too, in which case chime in on #2446 |
Hmmm well, then I found an inconsistency. https://github.com/ipfs/js-ipfs/blob/master/test/core/block.spec.js#L56 expects to throw on invalid CID. Which is happening and correctly passing. But with your introduced change it should not throw but return an array:
Right? So currently validation of CID fails fast, but deletion errors do not... |
Also maybe https://github.com/ipfs/js-ipfs/blob/master/test/core/pin.js#L208 could be un-skipped? |
Also, I assume that there is a plan to go all "async" and hence support generators at some point? Maybe it would be worth to track the points where currently generators are degraded to arrays because of this, so the final refactor switch could be easier? |
This is intentional. Sort of. It's what
Yes, though better to rewrite it so it doesn't affect other tests in the suite so they can all be run in isolation as well as together.
Yes! It's happening in two stages, the first is #1670 to convert everything internally, then #2509 to expose it to the wider world in a more refined API that reflects what we've learnt over the past few years (and also so we stop having to say "it behaves like this because that's what go does" about everything).
This should really only be happening at the very last moment - e.g. in the functions in |
We had a few instances in the tests where assertions may be missed due to functions not throwing where we thought they would so this PR refactors that code to use `.then(onResult, onReject)` instead. Follows on from #2514 (comment)
We had a few instances in the tests where assertions may be missed due to functions not throwing where we thought they would so this PR refactors that code to use `.then(onResult, onReject)` instead. Follows on from #2514 (comment)
We had a few instances in the tests where assertions may be missed due to functions not throwing where we thought they would so this PR refactors that code to use `.then(onResult, onReject)` instead. Follows on from #2514 (comment)
* chore: remove try-catch from tests where functions are async We had a few instances in the tests where assertions may be missed due to functions not throwing where we thought they would so this PR refactors that code to use `.then(onResult, onReject)` instead. Follows on from #2514 (comment)
* chore: remove try-catch from tests where functions are async We had a few instances in the tests where assertions may be missed due to functions not throwing where we thought they would so this PR refactors that code to use `.then(onResult, onReject)` instead. Follows on from #2514 (comment)
Also, validate that a block is not pinned before removing it.
Might, uh, might want to do that.