Previously when we had an ordered (set/map) prolly tree containing
non-ordered values (blobs/refs/etc), we'd put the ref of the largest
value in each meta node, complete with its full type info and height.
This is wasteful, all we really need is the hash of the largest item for
searching the tree. In lieu of encoding just the hash - which isn't a
value - this patch creates a fake Ref<Boolean> with height 0.
In Go: there are already similar tests for numbers, but testing structs
hits the non-scalar value prolly tree code.
In JS: the set and map tests hadn't even been ported from Go, so I
ported most of their functionality.
There were a few issues here:
1. The version header was not always passed to fetch
2. HTTP headers are case insensitive and Node an Fetch uses lower case.
3. The old code used a Map instead of an object as map. Node and Fetch
uses an object as map. Now we just pass along the response headers.
Fixes#1881Closes#1880 (which this is partially based in)
ChunkStores provide a Version() method so that anyone directly
using a ChunkStore (e.g. BatchStoreAdaptor) can retrieve and
check the version of the underlying store.
remoteDatabaseServer checks the version of the ChunkStore it's
backed by at startup, and then provides that version as an HTTP
header to all clients. In Go, httpBatchStore checks this header
anytime it gets a response from the server and bails if there's
version skew.
In Go, the responsibility for checking whether the running code and
the data being accessed lies with the BatchStore layer. In JS, there
is code in fetch.js that checks the header mentioned above.
Towards #1561
Fix sequence chunker bug triggered by repeatedly removing last element
The bug is we sometimes create a prollytree with a root meta sequence
node with only a single item. This is never the canonical representation
of prollytrees.
I reworked the sequence chunker to take a different approach to corner
cases. Instead of being smart and avoiding this case (which clearly
didn't work properly), it's more liberal with creating unnecessary
nodes, then it fixes them up in the finalisation step.
Now that we are using a binary serialization it makes more sense to
have Hash work with the digest and only compute the sha1 string when
needed.
Fixes#1685
And fix new errors that were found.
This also adds tools/run-all-js-tests.py which runs `npm install`
and `npm test` in all directories containing a package.json file.
In JS, the forEach() method didn't correctly handle async
callbacks for processing collection items. Now, if the
callback returns a Promise, it'll be properly waited for.