Files
SHiNE-server/shine-UI/tests/registration-contract-economy.test.mjs
T

15 lines
960 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const contract = readFileSync(new URL('../../shine-solana/shine/programs/shine_users/src/lib.rs', import.meta.url), 'utf8');
test('контракт не берёт депозит PDA поверх цены namespace', () => {
const create = contract.split('fn process_create_user_pda')[1].split('fn process_update_user_pda')[0];
assert.match(create, /minimum_balance\(settings::USER_PDA_SPACE\)/);
assert.match(create, /namespace\.registration_fee >= required_rent/);
assert.match(create, /required_rent\.saturating_sub\(user_pda\.lamports\(\)\)/);
assert.match(create, /namespace\.registration_fee\s*\.checked_sub\(rent_paid_by_signer\)/);
assert.match(create, /transfer_lamports\(signer, inflow_vault, system_program_ai, vault_fee\)/);
assert.doesNotMatch(create, /namespace\.registration_fee\.checked_add\(limit_fee_lamports/);
});