Исправить регистрацию free-пользователей без учёта регистра

НЕ ПРОВЕРЕНО: учтены логины с большими и маленькими буквами.

Добавлен временный devnet-смарт-контракт для очистки тестового аккаунта от старых логинов; после сброса его необходимо удалить и восстановить штатный контракт.
This commit is contained in:
AidarKC
2026-10-28 12:19:19 +03:00
parent ce97171d5a
commit 94d4665185
49 changed files with 687 additions and 129 deletions
@@ -0,0 +1,19 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
const read = (p) => fs.readFileSync(path.join(root, p), 'utf8');
test('Тестовая эпоха Arweave одинакова в UI, Server и Viewer', () => {
const ui = read('shine-UI/js/services/protocol-tags.js');
const server = read('SHiNE-server/shine-server-blockchain/src/main/java/blockchain/ShineProtocolTags.java');
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');
assert.match(ui, /SHINE_PROTOCOL_NAMESPACE\s*=\s*'test5592'/);
assert.match(server, /NAMESPACE\s*=\s*"test5592"/);
assert.match(viewer, /SHINE_PROTOCOL_NAMESPACE\s*=\s*'test5592'/);
assert.match(reg, /ShineProtocolTags\.APP_TAG_VALUE/);
for (const txt of [ui, server, viewer, reg]) assert.doesNotMatch(txt, /test5591/);
});
@@ -0,0 +1,11 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
const schema = fs.readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/resources/postgres/schema_v1.sql', import.meta.url), 'utf8');
const current = schema.slice(schema.lastIndexOf('CREATE OR REPLACE FUNCTION shine_blocks_connection_state_ai() RETURNS TRIGGER'));
test('социальные проекции нормализуют target, не изменяя блоки', () => {
assert.match(current, /VALUES\(lower\(NEW\.login\),1,lower\(NEW\.to_login\),/);
assert.match(current, /WHERE from_login=lower\(NEW\.login\)/);
assert.match(current, /INSERT INTO message_stats\(to_login,to_block_number,to_block_hash,replies_count\)[\s\S]*?VALUES\(lower\(NEW\.to_login\),/);
assert.match(current, /VALUES\(lower\(NEW\.login\),NEW\.msg_sub_type,lower\(NEW\.to_login\),/);
});
@@ -14,7 +14,9 @@ const bh = x => Uint8Array.from(Buffer.from(x, 'hex'));
test('строгая нормализация полных логинов', () => {
assert.equal(normalizeFullLogin('alice@shine'), 'alice@shine');
for (const bad of ['alice','ALICE@shine','alice@Shine',' alice@shine','alice@@shine','alice.s@shine','a'.repeat(30)+'@a'])
assert.equal(normalizeFullLogin('ALICE@shine'), 'ALICE@shine');
assert.equal(normalizeFullLogin('AlIcE@shine'), 'AlIcE@shine');
for (const bad of ['alice','alice@Shine',' alice@shine','alice@@shine','alice.s@shine','a'.repeat(30)+'@a'])
assert.throws(() => normalizeFullLogin(bad));
assert.notEqual(normalizeFullLogin('a_b@shine'), normalizeFullLogin('ab@shine'));
});
@@ -31,6 +33,8 @@ test('SHA256 PDA seeds stable and domain separated', async () => {
assert.equal(hex(await userPdaSeed32('bob@free')), props.user_bob_free_seed);
assert.equal(hex(await namespacePdaSeed32('free')), props.namespace_free_seed);
assert.notEqual(hex(await userPdaSeed32('bob@free')), hex(await namespacePdaSeed32('free')));
assert.equal(hex(await userPdaSeed32('BoB@free')), hex(await userPdaSeed32('bob@free')));
assert.equal(hex(await userPdaSeed32('BOB@free')), hex(await userPdaSeed32('bob@free')));
});
test('inner message is byte-for-byte fixture', () => {
const b = buildFreeCertificateInnerMessage('bob@free',
@@ -38,6 +42,11 @@ test('inner message is byte-for-byte fixture', () => {
bh('29acbae141bccaf0b22e1a94d34d0bc7361e526d0bfe12c89794bc9322966dd7'),
bh('2543b92ff1095511476adc8369db6ddc933665a11978dda1404ee1066ca9559d'));
assert.equal(hex(b), props.inner_message_hex);
const mixed = buildFreeCertificateInnerMessage('BoB@free',
bh('03a107bff3ce10be1d70dd18e74bc09967e4d6309ba50d5f1ddc8664125531b8'),
bh('29acbae141bccaf0b22e1a94d34d0bc7361e526d0bfe12c89794bc9322966dd7'),
bh('2543b92ff1095511476adc8369db6ddc933665a11978dda1404ee1066ca9559d'));
assert.notEqual(hex(mixed), hex(b)); // Подпись сертификата включает оригинальный регистр.
});
test('create instruction suffix encodes registrar signature, never promo', () => {
const common = {login:'bob@free', rootKey32: new Uint8Array(32), createdAtMs:1n,