Real XMR pilot

This commit is contained in:
2026-10-22 14:40:00 -04:00
parent 52559f65d7
commit 3f04c3afa9
19 changed files with 408 additions and 50 deletions
+46
View File
@@ -21,8 +21,36 @@ test('default testnet v6 manifest is unchanged and unknown network profiles fail
assert.equal(GENESIS_TIME, 1_792_411_200);
assert.equal(CHAIN_ID, hash(JSON.stringify(['wikideck-randomx-testnet-6', CONSENSUS, 1_792_411_200, MAX_TARGET])));
assert.equal(networkProfile(undefined), 'testnet');
assert.equal(networkProfile('pilot'), 'pilot');
assert.throws(() => networkProfile('production')); assert.throws(() => networkProfile(''));
});
test('private pilot is a separate deterministic chain with an explicit mock-only startup gate', () => {
const output = JSON.parse(script(`
import { NETWORK, NETWORK_GENESIS_TIME, NETWORK_LABEL } from './shared/network.ts';
import { CHAIN_ID, GENESIS_HASH, GENESIS_TIME } from './server/testnet/consensus.ts';
import { launchManifest, assertLaunchAllowed } from './server/launch.ts';
const allowed = (env) => { try { assertLaunchAllowed(env); return true; } catch { return false; } };
console.log(JSON.stringify({ NETWORK, NETWORK_GENESIS_TIME, NETWORK_LABEL, CHAIN_ID, GENESIS_HASH, GENESIS_TIME,
manifest:launchManifest(), missing:allowed({}), approved:allowed({WIKIDECK_PILOT_MODE:'private-mock-only'}),
livePayment:allowed({WIKIDECK_PILOT_MODE:'private-mock-only',WIKIDECK_PAYMENT_MODE:'live'}) }));
`, { WIKIDECK_NETWORK: 'pilot' }));
assert.equal(output.NETWORK, 'wikideck-randomx-pilot-1');
assert.equal(output.GENESIS_TIME, 1_792_627_200);
assert.equal(output.NETWORK_LABEL, 'PRIVATE PILOT');
assert.equal(output.manifest.launchStatus, 'private-pilot-mock-only');
assert.equal(output.manifest.paymentMode, 'mock');
assert.equal(output.missing, false);
assert.equal(output.approved, true);
assert.equal(output.livePayment, false);
assert.notEqual(output.CHAIN_ID, CHAIN_ID);
assert.notEqual(output.GENESIS_HASH, GENESIS_HASH);
const missingMode = spawnSync(process.execPath, ['--experimental-strip-types', 'server/index.ts'], {
env: { ...process.env, WIKIDECK_NETWORK: 'pilot', WIKIDECK_PILOT_MODE: '' },
encoding: 'utf8', timeout: 30000,
});
assert.notEqual(missingMode.status, 0);
assert.match(missingMode.stderr, /Private pilot requires WIKIDECK_PILOT_MODE/);
});
test('mainnet candidate has distinct deterministic genesis, signatures and strict transaction schemas', () => {
const output = JSON.parse(script(`
import { NETWORK, nftTransferMessage } from './shared/testnet.ts';
@@ -86,6 +114,24 @@ test('mainnet ledger and market files use isolated folders; testnet backup heade
} finally { await rm(dir, { recursive: true, force: true }); }
});
test('pilot ledger and market files use their own profile directory', async () => {
const dir = await mkdtemp(join(tmpdir(), 'wikideck-pilot-network-'));
try {
const result = JSON.parse(script(`
import { Ledger } from './server/testnet/ledger.ts';
import { Market } from './server/market/store.ts';
import { existsSync } from 'node:fs'; import { join } from 'node:path';
const ledger=await Ledger.open(process.env.PROFILE_TEST_DIR,{hash:async()=>{throw Error('unused')},close(){}});
const market=await Market.open(process.env.PROFILE_TEST_DIR,ledger,undefined,Date.now,{worker:false});
const result={ledger:existsSync(join(process.env.PROFILE_TEST_DIR,'pilot','ledger.sqlite')),
market:existsSync(join(process.env.PROFILE_TEST_DIR,'pilot','market.sqlite')),
testnet:existsSync(join(process.env.PROFILE_TEST_DIR,'testnet'))};
market.close();ledger.close();console.log(JSON.stringify(result));
`, { WIKIDECK_NETWORK: 'pilot', WIKIDECK_PILOT_MODE: 'private-mock-only', PROFILE_TEST_DIR: dir }));
assert.deepEqual(result, { ledger: true, market: true, testnet: false });
} finally { await rm(dir, { recursive: true, force: true }); }
});
test('operator preflight is read-only, fails closed, and does not disclose credentials', async () => {
const dir = await mkdtemp(join(tmpdir(), 'wikideck-preflight-'));
try {