mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge branch 'main' into denis/gev-news-layer
Wildlife Sightings (#1591) published share token 9, so News takes the next free token, 00. The token tests read the ledger before both where they were written against it, and the README counts both layers.
This commit is contained in:
commit
2e87dd87eb
144 files changed
+26748
-489
No files matched your search
@@ -203,8 +203,8 @@ function encode(state) {
|
||||
|
||||
test('production registry is exact, canonical, and rejects incomplete contracts', async () => {
|
||||
assert.equal(validateLayerStateRegistry(), true);
|
||||
assert.equal(REGISTERED_LAYER_IDS.length, 36);
|
||||
assert.equal(new Set(REGISTERED_LAYER_IDS).size, 36);
|
||||
assert.equal(REGISTERED_LAYER_IDS.length, 37);
|
||||
assert.equal(new Set(REGISTERED_LAYER_IDS).size, 37);
|
||||
assert.ok(REGISTERED_LAYER_IDS.includes('transit'));
|
||||
assert.deepEqual(REGISTERED_LAYER_IDS, [...REGISTERED_LAYER_IDS].sort());
|
||||
assert.deepEqual(LEGACY_LAYER_STATE_TOKENS, {
|
||||
@@ -243,17 +243,24 @@ test('production registry is exact, canonical, and rejects incomplete contracts'
|
||||
for (const [id, token] of Object.entries(LEGACY_LAYER_STATE_TOKENS)) {
|
||||
assert.equal(LAYER_STATE_TOKEN_RESERVATIONS[id], token);
|
||||
}
|
||||
// News took the last single digit: the next tokens are pairs.
|
||||
assert.equal(nextLayerStateToken(), '00');
|
||||
// News holds 00, the first pair: the next token is 01.
|
||||
assert.equal(nextLayerStateToken(), '01');
|
||||
// The allocation rules below read the ledger before News took it.
|
||||
const beforeNews = { ...LAYER_STATE_TOKEN_RESERVATIONS };
|
||||
delete beforeNews.news;
|
||||
assert.equal(nextLayerStateToken(beforeNews), '00');
|
||||
assert.equal(
|
||||
nextLayerStateToken({
|
||||
...LAYER_STATE_TOKEN_RESERVATIONS,
|
||||
alpha: '00',
|
||||
bravo: '01',
|
||||
...beforeNews,
|
||||
alpha: '9',
|
||||
bravo: '00',
|
||||
}),
|
||||
'02',
|
||||
'01',
|
||||
);
|
||||
const digitsExhausted = { ...LAYER_STATE_TOKEN_RESERVATIONS };
|
||||
const digitsExhausted = {
|
||||
...beforeNews,
|
||||
...Object.fromEntries([...'9'].map((digit) => [`prior-${digit}`, digit])),
|
||||
};
|
||||
assert.equal(nextLayerStateToken(digitsExhausted), '00');
|
||||
assert.equal(
|
||||
nextLayerStateToken({ ...digitsExhausted, retired: '00', used: '01' }),
|
||||
@@ -302,8 +309,8 @@ test('production registry is exact, canonical, and rejects incomplete contracts'
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
validateLayerStateAllocations(LAYER_STATE_TOKEN_RESERVATIONS, {
|
||||
...LAYER_STATE_TOKEN_RESERVATIONS,
|
||||
validateLayerStateAllocations(beforeNews, {
|
||||
...beforeNews,
|
||||
future: '00',
|
||||
next: '01',
|
||||
}),
|
||||
@@ -311,14 +318,15 @@ test('production registry is exact, canonical, and rejects incomplete contracts'
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
validateLayerStateAllocations(LAYER_STATE_TOKEN_RESERVATIONS, {
|
||||
...LAYER_STATE_TOKEN_RESERVATIONS,
|
||||
validateLayerStateAllocations(beforeNews, {
|
||||
...beforeNews,
|
||||
future: '01',
|
||||
}),
|
||||
/next free token 00/,
|
||||
);
|
||||
const beforeLastDigit = { ...digitsExhausted };
|
||||
delete beforeLastDigit.news;
|
||||
delete beforeLastDigit['prior-9'];
|
||||
delete beforeLastDigit['wildlife-sightings'];
|
||||
assert.equal(
|
||||
validateLayerStateAllocations(beforeLastDigit, {
|
||||
...beforeLastDigit,
|
||||
@@ -338,10 +346,10 @@ test('production registry is exact, canonical, and rejects incomplete contracts'
|
||||
assert.throws(
|
||||
() =>
|
||||
validateLayerStateAllocations(
|
||||
{ ...LAYER_STATE_TOKEN_RESERVATIONS, merged: '00' },
|
||||
{ ...LAYER_STATE_TOKEN_RESERVATIONS, merged: '00', competing: '00' },
|
||||
{ ...beforeNews, merged: '9' },
|
||||
{ ...beforeNews, merged: '9', competing: '9' },
|
||||
),
|
||||
/next free token 01/,
|
||||
/next free token 00/,
|
||||
);
|
||||
assert.throws(
|
||||
() => validateLayerStateAllocations({ future: '00' }, { future: '01' }),
|
||||
@@ -497,7 +505,7 @@ test('unknown enabled-layer tokens reject the payload instead of becoming an emp
|
||||
});
|
||||
|
||||
test('malformed enabled-layer lists reject the entire payload', () => {
|
||||
for (const value of ['.c', 'c.', 'c..e', 'c.c', '00', 'c.00']) {
|
||||
for (const value of ['.c', 'c.', 'c..e', 'c.c', 'zz', 'c.zz']) {
|
||||
assert.equal(
|
||||
decodeLayerStateParams(new URLSearchParams(`v=2&l=${value}`)),
|
||||
null,
|
||||
@@ -2693,6 +2701,32 @@ test('the recent-imagery split is share-link only: never stored locally, and a s
|
||||
);
|
||||
});
|
||||
|
||||
test('wildlife confirmed and every taxa preset round-trip through the full share codec', () => {
|
||||
assert.equal(
|
||||
LAYER_STATE_REGISTRY.find(({ id }) => id === 'wildlife-sightings').token,
|
||||
'9',
|
||||
);
|
||||
for (const taxa of [
|
||||
'all',
|
||||
'Aves',
|
||||
'Mammalia',
|
||||
'whales',
|
||||
'Insecta',
|
||||
'Plantae',
|
||||
]) {
|
||||
const state = normalizeLayerState({
|
||||
enabledLayerIds: ['wildlife-sightings'],
|
||||
options: { 'wildlife-sightings': { confirmed: true, taxa } },
|
||||
});
|
||||
const encoded = encode(state);
|
||||
assert.doesNotMatch(encoded, /undefined/);
|
||||
assert.deepEqual(
|
||||
decodeLayerStateParams(new URLSearchParams(encoded)),
|
||||
state,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('drone restrictions uses digit 8 without colliding with fire perimeters', () => {
|
||||
const decoded = decodeLayerStateParams(new URLSearchParams('v=2&l=8.2'));
|
||||
assert.deepEqual(decoded.enabledLayerIds, [
|
||||
|
||||
Reference in new issue
Block a user