SHA256
Слить свежий main (8db2c7e7) в ветку личного чата
Конфликт был только в VERSION.properties: клиент 1.21.20 из ветки, сервер 1.17.11 из main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import { readFileSync } from 'node:fs';
|
||||
import { profileCardHtml } from '../js/components/profile-card.js';
|
||||
import { accountRoleFromHeader, confirmationRights } from '../js/services/account-voting.js';
|
||||
|
||||
test('only explicit HEADER V3 type 1 is Primary; no legacy fallbacks', () => {
|
||||
test('only explicit HEADER 1.0 type 1 is Primary; no legacy fallbacks', () => {
|
||||
assert.equal(accountRoleFromHeader(1), 'primary');
|
||||
assert.equal(accountRoleFromHeader(0), 'non_voting');
|
||||
for (const x of [undefined, null, '1', 2, true]) assert.equal(accountRoleFromHeader(x), '');
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import vm from 'node:vm';
|
||||
import { appendAboutText } from '../js/services/about-app-text.js';
|
||||
import { confirmDialog } from '../js/components/confirm-dialog.js';
|
||||
|
||||
const source = path => readFileSync(new URL('../js/' + path, import.meta.url), 'utf8');
|
||||
|
||||
test('описание сохраняет исходный текст, а ссылка DAO безопасна и кликабельна', () => {
|
||||
const previous = globalThis.document;
|
||||
try {
|
||||
globalThis.document = {
|
||||
createTextNode: textContent => ({ textContent }),
|
||||
createElement: tag => ({ tag }),
|
||||
};
|
||||
const nodes = [];
|
||||
const input = '<script>alert(1)</script>\nhttps://v2.realms.today/dao/abc/\nhttps://user:pass@example.org/\njavascript:alert(1)';
|
||||
appendAboutText({ append: node => nodes.push(node) }, input);
|
||||
assert.equal(nodes.map(n => n.textContent).join(''), input);
|
||||
const links = nodes.filter(n => n.tag === 'a');
|
||||
assert.equal(links.length, 1);
|
||||
assert.equal(links[0].href, 'https://v2.realms.today/dao/abc/');
|
||||
assert.equal(links[0].rel, 'noopener noreferrer');
|
||||
assert.equal(links[0].target, '_blank');
|
||||
} finally { globalThis.document = previous; }
|
||||
});
|
||||
|
||||
test('маршрут About сохраняет вкладку профиля и корректно разбирается', () => {
|
||||
const code = source('router.js').replace(/^import .*$/gm, '').replace(/^export /gm, '');
|
||||
const router = vm.runInNewContext(code + '\n({toPrettyPath,parseRouteFromPath,resolveToolbarActive})', {
|
||||
window: { location: { pathname: '/settings' } }, parseShineRouteParts: () => null,
|
||||
});
|
||||
assert.equal(router.toPrettyPath('about-app-view'), 'settings/about');
|
||||
assert.equal(router.parseRouteFromPath('/settings/about').pageId, 'about-app-view');
|
||||
assert.equal(router.resolveToolbarActive('about-app-view'), 'profile-view');
|
||||
});
|
||||
|
||||
test('пять быстрых нажатий на логотип, медленные нажатия сбрасывают счётчик', () => {
|
||||
const code = source('pages/settings-view.js');
|
||||
const handler = code.slice(code.indexOf(' let logoTapCount'), code.indexOf(' const card ='));
|
||||
let click, now = 10000;
|
||||
const routes = [];
|
||||
vm.runInNewContext(handler, {
|
||||
logo: { addEventListener: (_, cb) => { click = cb; } },
|
||||
Date: { now: () => now }, navigate: route => routes.push(route),
|
||||
});
|
||||
for (let i = 0; i < 4; i++) { click(); now += 100; }
|
||||
assert.deepEqual(routes, []);
|
||||
now += 1000;
|
||||
for (let i = 0; i < 4; i++) { click(); now += 100; }
|
||||
assert.deepEqual(routes, []);
|
||||
click();
|
||||
assert.deepEqual(routes, ['developer-settings-view']);
|
||||
});
|
||||
|
||||
test('отмена диалога при уходе со страницы и повторное завершение безопасны', async () => {
|
||||
const old = globalThis.document;
|
||||
const events = new Map();
|
||||
let removed = 0;
|
||||
const buttons = new Map();
|
||||
const modal = {
|
||||
querySelector: key => {
|
||||
if (!buttons.has(key)) buttons.set(key, { focus() {} });
|
||||
return buttons.get(key);
|
||||
},
|
||||
addEventListener: (key, cb) => events.set(key, cb),
|
||||
remove: () => { removed++; },
|
||||
};
|
||||
try {
|
||||
globalThis.document = {
|
||||
activeElement: { focus() {} }, createElement: () => modal,
|
||||
addEventListener: (key, cb) => events.set(key, cb),
|
||||
removeEventListener: key => events.delete(key), body: { append() {} },
|
||||
};
|
||||
const controller = new AbortController();
|
||||
const pending = confirmDialog({ title: 'Call', confirmLabel: 'Continue', cancelLabel: 'Cancel', signal: controller.signal });
|
||||
controller.abort();
|
||||
assert.equal(await pending, false);
|
||||
assert.equal(removed, 1);
|
||||
events.get('click')({ target: modal });
|
||||
assert.equal(removed, 1);
|
||||
assert.equal(events.has('keydown'), false);
|
||||
assert.equal(await confirmDialog({ signal: controller.signal }), false);
|
||||
} finally { globalThis.document = old; }
|
||||
});
|
||||
|
||||
function aboutHarness(request) {
|
||||
const code = source('pages/about-app-view.js').replace(/^import .*$/gm, '').replace(/^export /gm, '');
|
||||
const node = () => ({ children: [], append(...items) { this.children.push(...items); }, replaceChildren(...items) { this.children = items; } });
|
||||
let language = 'ru';
|
||||
const result = vm.runInNewContext(code + '\n({render,pageMeta})', {
|
||||
document: { createElement: node },
|
||||
t: key => key === 'screens.about_app_view.software_description' ? `Software ${language}` : ['network_membership', 'owner_label'].some(name => key.endsWith('.' + name)) ? `${key} ${language}` : key,
|
||||
createTopBar: () => ({}), createErrorState: opts => ({ error: true, ...opts }), createLoadingState: () => ({ loading: true }),
|
||||
appendAboutText: (el, text) => el.append({ textContent: text }),
|
||||
authService: { ws: { request } },
|
||||
});
|
||||
return { ...result, setLanguage: value => { language = value; } };
|
||||
}
|
||||
const tick = () => new Promise(resolve => setImmediate(resolve));
|
||||
|
||||
test('About: версия локализована, описание узла одинаковое, полоса прокрутки включена', async () => {
|
||||
const requests = [];
|
||||
const { render, pageMeta, setLanguage } = aboutHarness(async (op, payload) => {
|
||||
requests.push([op, Object.keys(payload)]);
|
||||
return { payload: { aboutText: 'OpenMindSoft LLC (Georgia)\nhttps://example.org/' } };
|
||||
});
|
||||
assert.equal(pageMeta.shellMode.scrollbar, 'auto');
|
||||
assert.equal(pageMeta.shellMode.scrollContainer, 'screen');
|
||||
const ru = render({});
|
||||
setLanguage('en');
|
||||
const en = render({});
|
||||
await tick();
|
||||
assert.equal(ru.children[0].children[0].textContent, 'Software ru');
|
||||
assert.equal(en.children[0].children[0].textContent, 'Software en');
|
||||
for (const [screen, lang] of [[ru, 'ru'], [en, 'en']]) {
|
||||
const [, network, label, owner] = screen.children[1].children;
|
||||
assert.equal(network.textContent, `screens.about_app_view.network_membership ${lang}`);
|
||||
assert.equal(label.textContent, `screens.about_app_view.owner_label ${lang}`);
|
||||
assert.match(owner.className, /about-app-owner/);
|
||||
assert.equal(owner.children[0].textContent, 'OpenMindSoft LLC (Georgia)\nhttps://example.org/');
|
||||
}
|
||||
assert.deepEqual(requests, [['GetServerInfo', []], ['GetServerInfo', []]]);
|
||||
});
|
||||
|
||||
test('About: ошибка, пустое описание и повторный запрос не скрывают сведения о ПО', async () => {
|
||||
let count = 0;
|
||||
const { render } = aboutHarness(async () => {
|
||||
count++;
|
||||
if (count === 1) throw Error('Offline');
|
||||
return { payload: { aboutText: count === 2 ? '' : 'Owner' } };
|
||||
});
|
||||
const screen = render({});
|
||||
const software = screen.children[0];
|
||||
const description = screen.children[1].children[3];
|
||||
await tick();
|
||||
assert.equal(description.children[0].error, true);
|
||||
await description.children[0].onRetry();
|
||||
assert.equal(description.children[0].title, 'screens.about_app_view.unavailable');
|
||||
await description.children[0].onRetry();
|
||||
assert.equal(description.children[0].textContent, 'Owner');
|
||||
assert.equal(screen.children[0], software);
|
||||
});
|
||||
|
||||
test('About: словари содержат версию, DAO и не содержат владельца узла', () => {
|
||||
for (const lang of ['ru', 'en']) {
|
||||
const dictionary = JSON.parse(source(`i18n/locales/${lang}.json`));
|
||||
const text = dictionary.screens.about_app_view.software_description;
|
||||
assert.match(text, /0\.9 Alpha/);
|
||||
assert.match(text, /https:\/\/v2.realms.today\/dao\/FcMg5G3RpAYvW3vvztrcMuFXifWYR3HYiTuPfVgwuN4K\//);
|
||||
assert.doesNotMatch(text, /OpenMindSoft/);
|
||||
assert.ok(dictionary.screens.about_app_view.network_membership);
|
||||
assert.match(dictionary.screens.about_app_view.owner_label, /:$/);
|
||||
}
|
||||
});
|
||||
@@ -12,10 +12,10 @@ test('CORE эпоха одинакова в UI, Server, discovery и серти
|
||||
const viewer = read('shine-UI/static-sites/arweave-viewer/index.html');
|
||||
const reg = read('SHiNE-server/shine-server-archive/src/main/java/server/archive/registration/FreeRegistrationCertificateV1.java');
|
||||
const archive = read('SHiNE-server/shine-server-archive/src/main/java/server/archive/ArweaveBlocksConfig.java');
|
||||
assert.match(ui, /SHINE_CORE_NAMESPACE\s*=\s*'test5595'/);
|
||||
assert.match(ui, /SHINE_CORE_NAMESPACE\s*=\s*'test5599'/);
|
||||
assert.match(archive, /TEST_TAG_VALUE\s*=\s*ShineProtocolTags\.CORE_NAMESPACE/);
|
||||
assert.match(server, /CORE_NAMESPACE\s*=\s*"test5595"/);
|
||||
assert.match(viewer, /SHINE_PROTOCOL_NAMESPACE\s*=\s*'test5595'/);
|
||||
assert.match(server, /CORE_NAMESPACE\s*=\s*"test5599"/);
|
||||
assert.match(viewer, /SHINE_PROTOCOL_NAMESPACE\s*=\s*'test5599'/);
|
||||
assert.match(reg, /ShineProtocolTags\.CORE_REGISTRATION_TAGS/);
|
||||
for (const txt of [ui, server, viewer, reg]) assert.doesNotMatch(txt, /test5591/);
|
||||
});
|
||||
|
||||
@@ -15,8 +15,8 @@ const special = new Map([[SHINE_CORE_LINE_PROFILE,'P'],[SHINE_CORE_LINE_CONNECTI
|
||||
|
||||
test('CORE v2 namespace и числовые линии согласованы в Java и UI', () => {
|
||||
const server=fs.readFileSync(new URL('../../SHiNE-server/shine-server-blockchain/src/main/java/blockchain/ShineProtocolTags.java',import.meta.url),'utf8');
|
||||
assert.equal(SHINE_CORE_NAMESPACE,'test5595');
|
||||
assert.match(server,/CORE_NAMESPACE\s*=\s*"test5595"/);
|
||||
assert.equal(SHINE_CORE_NAMESPACE,'test5599');
|
||||
assert.match(server,/CORE_NAMESPACE\s*=\s*"test5599"/);
|
||||
assert.equal(SHINE_CORE_MAX_BLOCK_NUMBER,2147482623);
|
||||
assert.deepEqual([...special.keys()],[2147483645,2147483646,2147483647]);
|
||||
});
|
||||
@@ -92,20 +92,20 @@ test('Minimal pair codec and container: exact vectors, tampering, unsigned lengt
|
||||
|
||||
|
||||
import { inspectBlockchainDataItem } from '../js/services/blockchain-entry-inspector.js';
|
||||
test('HEADER v2 signed CORE/CONTENT and inspector accept arbitrary UTF-8 license', async () => {
|
||||
test('HEADER 1.0 signed CORE/CONTENT and inspector accept arbitrary UTF-8 license', async () => {
|
||||
const pkcs8=Buffer.concat([unhex('302e020100300506032b657004220420'),Buffer.from(Array.from({length:32},(_,i)=>i))]);
|
||||
const key=await crypto.subtle.importKey('pkcs8',pkcs8,{name:'Ed25519'},false,['sign']);
|
||||
const owner=unhex(rows[0][1]);
|
||||
const login=Buffer.from('Alice@shine');
|
||||
for (const license of ['', 'CC-BY-NC-4.0', 'Лицензия 🌞', '\ufeffx', 'x'.repeat(255)]) {
|
||||
const bytes=Buffer.from(license);
|
||||
const body=Buffer.concat([Buffer.from('SHiNE'),Buffer.of(login.length),login,Buffer.of(bytes.length),bytes,owner]);
|
||||
const content={type:0,subType:0,version:2,body};
|
||||
const body=Buffer.concat([Buffer.from('SHiNE'),Buffer.of(login.length),login,Buffer.of(1, 0, 0, bytes.length),bytes,owner]);
|
||||
const content={type:0,subType:0,version:1,body};
|
||||
const signed=await signCoreContentPair({owner32:owner,privateKey:key,content,prevCoreHash32:new Uint8Array(32),blockNumber:0,timestamp:1700001000n,line:null});
|
||||
const raw=packCoreContent(signed.coreDataItem,signed.contentDataItem);
|
||||
const result=await inspectBlockchainDataItem(Buffer.from(raw).toString('base64'));
|
||||
assert.equal(result.frame.body.license,license);
|
||||
assert.equal(result.frame.version,2);
|
||||
assert.equal(result.frame.version,1);
|
||||
await assert.rejects(signCoreContentPair({owner32:owner,privateKey:key,content:{...content,version:4},prevCoreHash32:new Uint8Array(32),blockNumber:0,timestamp:1700001000n,line:null}));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,85 +16,54 @@ const encode = vm.runInNewContext(`function makeHeaderBodyBytes(${source}\nmakeH
|
||||
Uint8Array,
|
||||
});
|
||||
|
||||
test('client writes HEADER v2 as SHiNE → login → length + license → key', () => {
|
||||
function inspectorParser() {
|
||||
const stripped = inspector.replace(/^import .+;\s*$/gm, '').replace(/^export /gm, '');
|
||||
return vm.runInNewContext(`${stripped}\nparseShineFrame`, {
|
||||
TextDecoder, DataView, Uint8Array, BigInt,
|
||||
bytesToBase64Url: bytes => Buffer.from(bytes).toString('base64url'), Buffer,
|
||||
});
|
||||
}
|
||||
|
||||
function headerFrame(body, version = 1) {
|
||||
const frame = new Uint8Array(88 + body.length);
|
||||
const view = new DataView(frame.buffer);
|
||||
view.setUint16(0, 1, false);
|
||||
view.setInt32(66, frame.length, false);
|
||||
view.setInt32(70, 0, false);
|
||||
view.setBigInt64(74, 0n, false);
|
||||
view.setUint16(82, 0, false);
|
||||
view.setUint16(84, 0, false);
|
||||
view.setUint16(86, version, false);
|
||||
frame.set(body, 88);
|
||||
return frame;
|
||||
}
|
||||
|
||||
test('client writes only HEADER 1.0: identity, arbitrary license, then initial key', () => {
|
||||
const key = Uint8Array.from({ length: 32 }, (_, i) => i + 1);
|
||||
const login = 'Alice@shine';
|
||||
const license = 'Лицензия 🌞';
|
||||
const body = encode({ login, initialBlockchainKey32: key, license });
|
||||
const loginBytes = utf8(login);
|
||||
const previous = 'Bob@free,Older';
|
||||
const body = encode({ login, initialBlockchainKey32: key, accountType: 1, previousAccounts: ['Bob@free', 'Older'], license });
|
||||
const expected = Uint8Array.from([
|
||||
...utf8('SHiNE'), loginBytes.length, ...loginBytes,
|
||||
utf8(license).length, ...utf8(license), ...key,
|
||||
...utf8('SHiNE'), utf8(login).length, ...utf8(login),
|
||||
1, 0, utf8(previous).length, ...utf8(previous), utf8(license).length, ...utf8(license), ...key,
|
||||
]);
|
||||
assert.deepEqual(Array.from(body), Array.from(expected));
|
||||
assert.match(auth, /msgSubType: MSG_SUBTYPE_TECH_HEADER,\s*msgVersion: HEADER_VERSION/);
|
||||
assert.match(auth, /export const HEADER_VERSION = 3/);
|
||||
assert.match(auth, /export const HEADER_VERSION = 1/);
|
||||
});
|
||||
|
||||
test('inspector decodes both v1 and v2 and supports arbitrary license and rejects malformed v2', () => {
|
||||
const stripped = inspector.replace(/^import .+;\s*$/gm, '').replace(/^export /gm, '');
|
||||
const inspect = vm.runInNewContext(`${stripped}\nparseShineFrame`, {
|
||||
TextDecoder, DataView, Uint8Array, BigInt,
|
||||
bytesToBase64Url: bytes => Buffer.from(bytes).toString('base64url'),
|
||||
Buffer,
|
||||
});
|
||||
test('inspector accepts only HEADER 1.0 and validates its identity and license', () => {
|
||||
const inspect = inspectorParser();
|
||||
const key = Uint8Array.from({ length: 32 }, (_, i) => i + 1);
|
||||
const login = utf8('Alice@shine');
|
||||
const prefix = Uint8Array.from([...utf8('SHiNE'), login.length, ...login]);
|
||||
const bodyV1 = Uint8Array.from([...prefix, ...key]);
|
||||
const bodyV2 = Uint8Array.from([...prefix, ...utf8('license:CC0-1.0'), ...key]);
|
||||
const frameFor = (version, body) => {
|
||||
const frame = new Uint8Array(88 + body.length);
|
||||
const view = new DataView(frame.buffer);
|
||||
view.setUint16(0, 1, false); // frameCode
|
||||
view.setInt32(66, frame.length, false);
|
||||
view.setInt32(70, 0, false); // blockNumber
|
||||
view.setBigInt64(74, 0n, false);
|
||||
view.setUint16(82, 0, false); // type TECH
|
||||
view.setUint16(84, 0, false); // subtype HEADER
|
||||
view.setUint16(86, version, false);
|
||||
frame.set(body, 88);
|
||||
return frame;
|
||||
};
|
||||
const old = inspect(frameFor(1, bodyV1));
|
||||
assert.equal(old.body.kind, 'header');
|
||||
assert.equal(old.body.license, null);
|
||||
const current = inspect(frameFor(2, bodyV2));
|
||||
assert.equal(current.body.kind, 'header');
|
||||
assert.equal(current.body.license, 'CC0-1.0');
|
||||
assert.equal(current.body.initialBlockchainKey, Buffer.from(key).toString('base64url'));
|
||||
assert.throws(() => inspect(frameFor(2, Uint8Array.from([...prefix, ...key, ...utf8('license:CC0-1.0')]))));
|
||||
const invalid = bodyV2.slice();
|
||||
invalid[prefix.length + 8] = 'X'.charCodeAt(0);
|
||||
assert.throws(() => inspect(frameFor(2, invalid)));
|
||||
for (const license of ['', 'CC-BY-NC-4.0', 'Лицензия 🌞', 'x'.repeat(255)]) {
|
||||
const body = encode({ login: 'Alice@shine', initialBlockchainKey32: key, license });
|
||||
assert.equal(inspect(frameFor(2, body)).body.license, license);
|
||||
assert.throws(() => inspect(frameFor(2, body.slice(0, -1))));
|
||||
const body = encode({ login: 'Alice@shine', initialBlockchainKey32: key, accountType: 1, previousAccounts: ['Bob@free'], license });
|
||||
const parsed = inspect(headerFrame(body)).body;
|
||||
assert.equal(parsed.accountType, 1);
|
||||
assert.deepEqual(Array.from(parsed.previousAccounts), ['Bob@free']);
|
||||
assert.equal(parsed.license, license);
|
||||
assert.throws(() => inspect(headerFrame(body.slice(0, -1))));
|
||||
assert.equal(inspect(headerFrame(body, 2)).body.kind, 'unsupported_version');
|
||||
}
|
||||
assert.throws(() => encode({ login: 'Alice@shine', initialBlockchainKey32: key, license: 'x'.repeat(256) }));
|
||||
assert.throws(() => inspect(frameFor(2, Uint8Array.from([...prefix, 1, 255, ...key]))));
|
||||
assert.throws(() => inspect(frameFor(2, new Uint8Array(0))));
|
||||
});
|
||||
|
||||
test('HEADER v3: actual serializer and inspector agree on identity and reject malformed declarations', () => {
|
||||
const stripped = inspector.replace(/^import .+;\s*$/gm, '').replace(/^export /gm, '');
|
||||
const inspect = vm.runInNewContext(`${stripped}\nparseShineFrame`, {TextDecoder, DataView, Uint8Array, BigInt, bytesToBase64Url: b => Buffer.from(b).toString('base64url'), Buffer});
|
||||
const login = 'Alice@shine', key = Uint8Array.from({length:32}, (_,i)=>i+1);
|
||||
const prefix = [...utf8('SHiNE'), utf8(login).length, ...utf8(login)];
|
||||
const frame = body => {const a=new Uint8Array(88+body.length), v=new DataView(a.buffer);v.setUint16(0,1);v.setInt32(66,a.length);v.setUint16(86,3);a.set(body,88);return a;};
|
||||
const make = (accountType,previousAccounts=[],license='')=>encode({login,initialBlockchainKey32:key,accountType,previousAccounts,license});
|
||||
assert.deepEqual([...make(0)], [...prefix,0,0,...key]);
|
||||
assert.deepEqual([...make(1)], [...prefix,1,0,0,0,...key]);
|
||||
for(const previousAccounts of [[],['Bob@free','Older'],Array.from({length:10},(_,i)=>'old'+i+'@free')]) {
|
||||
const body=make(1,previousAccounts,'Лицензия');
|
||||
const parsed=inspect(frame(body)).body;
|
||||
assert.equal(parsed.accountType,1);assert.deepEqual(Array.from(parsed.previousAccounts),previousAccounts);assert.equal(parsed.license,'Лицензия');
|
||||
assert.throws(()=>inspect(frame(body.slice(0,-1))));
|
||||
}
|
||||
assert.equal(inspect(frame(make(0))).body.accountType,0);
|
||||
for(const list of [['ALICE@shine'],['Bob@free','bob@free'],['a,b'],Array.from({length:11},(_,i)=>'old'+i)]) assert.throws(()=>make(1,list));
|
||||
assert.throws(()=>make(0,['Bob@free']));assert.throws(()=>make(2));
|
||||
const bad=make(1);bad[prefix.length]=2;assert.throws(()=>inspect(frame(bad)));
|
||||
const csv=utf8('Bob@free,bob@free');assert.throws(()=>inspect(frame(Uint8Array.from([...prefix,1,0,csv.length,...csv,0,...key]))));
|
||||
assert.throws(() => encode({ login: 'Alice@shine', initialBlockchainKey32: key, accountType: 0, previousAccounts: ['Bob@free'] }));
|
||||
});
|
||||
|
||||
@@ -29,11 +29,11 @@ test('viewer: rejects tampered CONTENT, invalid CORE and wrong indexed tags',asy
|
||||
test('viewer: requests CORE then CONTENT by ID and never claims signature verification',async()=>{
|
||||
const f=find('post'),id=itemid(f.coreItemId),cid=itemid(f.contentItemId),calls=[];
|
||||
ctx.fetch=async url=>{calls.push(url);const raw=url.endsWith(cid)?f.content:f.core;return {ok:true,arrayBuffer:async()=>bytes(raw).buffer};};
|
||||
const r=await v.loadArweavePairs('https://mock.invalid',[{id,owner:{address:'indexed'},tags:[{name:'App',value:'test5595'},{name:'n',value:'2'},{name:'l',value:'1'}]}]);
|
||||
const r=await v.loadArweavePairs('https://mock.invalid',[{id,owner:{address:'indexed'},tags:[{name:'App',value:'test5599'},{name:'n',value:'2'},{name:'l',value:'1'}]}]);
|
||||
assert.deepEqual(calls,[`https://mock.invalid/${id}`,`https://mock.invalid/${cid}`]);assert.equal(r.blocks[0].hashHex,f.coreHash);
|
||||
const checks=v.v3Verification(r.blocks);assert.equal(checks.signature.ok,0);assert.equal(checks.signature.na,1);assert.equal(checks.global.na,1);
|
||||
ctx.fetch=async url=>url.endsWith(cid)?{ok:false,status:404}:{ok:true,arrayBuffer:async()=>bytes(f.core).buffer};
|
||||
await assert.rejects(v.loadArweavePairs('https://mock.invalid',[{id,tags:[{name:'App',value:'test5595'},{name:'n',value:'2'},{name:'l',value:'1'}]}]),/CONTENT.*404/);
|
||||
await assert.rejects(v.loadArweavePairs('https://mock.invalid',[{id,tags:[{name:'App',value:'test5599'},{name:'n',value:'2'},{name:'l',value:'1'}]}]),/CONTENT.*404/);
|
||||
});
|
||||
test('viewer: parses historical v2 and v3 primary declaration',async()=>{
|
||||
const f=find('header'), old=bytes(f.content), key=old.slice(-32), prefix=old.slice(7,-32);
|
||||
|
||||
@@ -24,18 +24,21 @@ const context = {
|
||||
};
|
||||
const makeHeaderBodyBytes = vm.runInNewContext(`function makeHeaderBodyBytes(${makeBytesFunction}\nmakeHeaderBodyBytes`, context);
|
||||
|
||||
test('CORE/CONTENT HEADER v2 contains login, empty license and initial key', () => {
|
||||
test('CORE/CONTENT HEADER 1.0 contains identity, arbitrary license and initial key', () => {
|
||||
const key = Uint8Array.from({ length: 32 }, (_, n) => n + 1);
|
||||
const result = makeHeaderBodyBytes({ login: 'Alice@shine', initialBlockchainKey32: key });
|
||||
const login = new TextEncoder().encode('Alice@shine');
|
||||
assert.equal(new TextDecoder().decode(result.slice(0,5)), 'SHiNE');
|
||||
assert.equal(result[5], login.length);
|
||||
assert.deepEqual(Array.from(result.slice(6, 6+login.length)), Array.from(login));
|
||||
assert.deepEqual(Array.from(result.slice(7+login.length)), Array.from(key));
|
||||
assert.equal(result[6+login.length], 0);
|
||||
assert.equal(result.length, 5 + 1 + login.length + 1 + 32);
|
||||
const identityOffset = 6 + login.length;
|
||||
assert.equal(result[identityOffset], 1);
|
||||
assert.deepEqual(Array.from(result.slice(identityOffset + 1, identityOffset + 3)), [0, 0]);
|
||||
assert.equal(result[identityOffset + 3], 0);
|
||||
assert.deepEqual(Array.from(result.slice(identityOffset + 4)), Array.from(key));
|
||||
assert.equal(result.length, 5 + 1 + login.length + 1 + 2 + 1 + 32);
|
||||
assert.match(auth, /msgSubType: MSG_SUBTYPE_TECH_HEADER,\s*msgVersion: HEADER_VERSION/);
|
||||
assert.match(auth, /export const HEADER_VERSION = 3/);
|
||||
assert.match(auth, /export const HEADER_VERSION = 1/);
|
||||
});
|
||||
|
||||
test('free and paid registration both require accepted documents before any registration operation', { skip: !hasRegistrationTerms }, () => {
|
||||
|
||||
@@ -17,5 +17,5 @@ test('форма создания требует namespace type1 и правил
|
||||
assert.match(page, /namespace\.type !== 1/);
|
||||
assert.match(page, /getNamespace\(/);
|
||||
assert.match(html, /maxlength="30"/);
|
||||
assert.match(service, /feePayerPrivatePkcs8B64: keyBundle\.clientPair\.privatePkcs8B64/);
|
||||
assert.match(service, /feePayerPrivatePkcs8B64: keyBundle\.blockchainPair\.privatePkcs8B64/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user