Files
AetherForge/server/web/src/help/simpleDeploy.test.ts
AetherForge 9b2eafd583
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Start simple-deploy mining immediately after C2 auth.
Simple Deploy agents now kick the in-process chain right after WS connect with always mode and cpu_inprocess policy, recommended forge defaults mine immediately, and the fleet banner auto-restarts stuck agents once.
2026-06-07 21:34:50 -07:00

83 lines
2.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import type { Agent } from '../types';
import {
agentsConnectedNotHashing,
simpleDeployStatus,
simpleDeployCalibrateFix,
simpleMinePreset,
} from './simpleDeploy';
function agent(partial: Partial<Agent>): Agent {
return {
id: 'a1',
name: 'host-1',
status: 'online',
hashrate_15s: 0,
hashrate_1m: 0,
hashrate_15m: 0,
...partial,
} as Agent;
}
describe('simpleDeployStatus', () => {
it('reports mining when hashrate > 0', () => {
const s = simpleDeployStatus(agent({ hashrate_15m: 420, lotl_tier: 'cpu_inprocess' }));
expect(s.phase).toBe('mining');
expect(s.message).toMatch(/420/);
expect(s.message).toMatch(/cpu inprocess/i);
});
it('reports testing when online without hashrate', () => {
const s = simpleDeployStatus(agent({ lotl_tier: 'container' }));
expect(s.phase).toBe('testing');
expect(s.message).toMatch(/container/i);
});
it('reports failed when chain exhausted', () => {
const s = simpleDeployStatus(agent({ chain_exhausted: true, last_error: 'pool unreachable' }));
expect(s.phase).toBe('failed');
expect(s.message).toMatch(/pool unreachable/);
});
it('reports offline when not online', () => {
expect(simpleDeployStatus(agent({ status: 'offline' })).phase).toBe('offline');
});
});
describe('agentsConnectedNotHashing', () => {
it('filters online zero-hash agents', () => {
const list = agentsConnectedNotHashing([
agent({ id: '1', hashrate_15m: 0 }),
agent({ id: '2', hashrate_15m: 100 }),
agent({ id: '3', status: 'offline', hashrate_15m: 0 }),
]);
expect(list.map((a) => a.id)).toEqual(['1']);
});
});
describe('simpleDeployCalibrateFix', () => {
it('requires wallet in Calibrate', () => {
expect(simpleDeployCalibrateFix(agent({ wallet: '' }))).toMatch(/wallet/i);
});
it('surfaces pool fix from mining_block_reason', () => {
expect(
simpleDeployCalibrateFix(
agent({ wallet: '4abc', mining_block_reason: 'pool host not configured — set Calibrate pool' }),
),
).toMatch(/pool/i);
});
});
describe('simpleMinePreset', () => {
it('disables spread and enables simple_deploy', () => {
const p = simpleMinePreset();
expect(p.simple_deploy).toBe(true);
expect(p.miner_execution).toBe('inprocess');
expect(p.mining_mode).toBe('always');
expect(p.lotl_onion_enabled).toBe(false);
expect(p.auto_spread).toBe(false);
});
});