import test from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; const text = path => readFileSync(new URL(path, import.meta.url), 'utf8'); test('opcode 8 требует upgrade authority, строго один код SOL и индексируемую economy PDA', () => { const rust = text('../../shine-solana/shine/programs/shine_users/src/lib.rs'); const body = rust.split('fn process_update_namespace_price')[1].split('fn validate_upgrade_authority')[0]; assert.match(rust, /const IX_UPDATE_NAMESPACE_PRICE: u8 = 8;/); assert.match(body, /validate_upgrade_authority\(program_id, signer, program_ai, programdata_ai\)/); assert.match(body, /read_namespace\(program_id, namespace_pda, name\)/); assert.match(body, /validate_users_economy_config_pda\(program_id, economy_pda\)/); assert.match(body, /ensure_pda_size_and_rent/); assert.match(rust, /state\.currency_code == NAMESPACE_CURRENCY_SOL/); }); test('server sync узнаёт update цены, а UPSERT сохраняет новые fee/currency, не старые', () => { const codec = text('../../SHiNE-server/shine-server-solana-users-sync/src/main/java/sync/codec/ShineUsersCodec.java'); const repo = text('../../SHiNE-server/shine-server-solana-users-sync/src/main/java/sync/storage/postgres/PostgresStorageRepository.java'); const migrations = text('../../SHiNE-server/shine-server-db/src/main/resources/postgres/migration_v40.sql'); assert.match(codec, /case IX_UPDATE_NAMESPACE_PRICE ->/); assert.match(codec, /TxKind\.UPDATE_NAMESPACE_PRICE/); assert.match(repo, /registration_fee_lamports=EXCLUDED.registration_fee_lamports/); assert.match(repo, /currency_code=EXCLUDED.currency_code/); assert.doesNotMatch(repo, /shine_namespace_current\.raw_data_base64=EXCLUDED\.raw_data_base64/); assert.match(migrations, /ADD COLUMN currency_code SMALLINT NOT NULL DEFAULT 1/); });