Mainnet
This commit is contained in:
+10
-8
@@ -11,15 +11,16 @@ import { CHAIN_ID, GENESIS_TIME, GENESIS_HASH, MAX_TARGET } from '../server/test
|
||||
|
||||
function script(code: string, env: Record<string,string> = {}) {
|
||||
return execFileSync(process.execPath, ['--experimental-strip-types', '--input-type=module', '-e', code], {
|
||||
env: { ...process.env, WIKIDECK_NETWORK: 'mainnet', ...env }, encoding: 'utf8', timeout: 30000,
|
||||
env: { ...process.env, WIKIDECK_NETWORK: 'mainnet', WIKIDECK_GENESIS_TIME: '1798761600', ...env }, encoding: 'utf8', timeout: 30000,
|
||||
}).trim();
|
||||
}
|
||||
test('default testnet v6 manifest is unchanged and unknown network profiles fail closed', () => {
|
||||
test('default profile is mainnet while testnet remains an explicit isolated profile', () => {
|
||||
const hash = (text: string) => createHash('sha256').update(text).digest('hex');
|
||||
assert.equal(NETWORK, 'wikideck-randomx-testnet-6');
|
||||
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(undefined), 'mainnet');
|
||||
assert.equal(networkProfile('testnet'), 'testnet');
|
||||
assert.throws(() => networkProfile('production')); assert.throws(() => networkProfile(''));
|
||||
});
|
||||
test('mainnet candidate has distinct deterministic genesis, signatures and strict transaction schemas', () => {
|
||||
@@ -37,7 +38,7 @@ test('mainnet candidate has distinct deterministic genesis, signatures and stric
|
||||
});
|
||||
test('mainnet startup is blocked before resources open, while manifest inspection needs no launch approval', () => {
|
||||
const args = ['--experimental-strip-types', 'server/index.ts'];
|
||||
const env = { ...process.env, WIKIDECK_NETWORK: 'mainnet', WIKIDECK_MAINNET_LAUNCH: '', WIKIDECK_MAINNET_REVIEW_ACK: '' };
|
||||
const env = { ...process.env, WIKIDECK_NETWORK: 'mainnet', WIKIDECK_GENESIS_TIME: '1798761600', WIKIDECK_MAINNET_LAUNCH: '', WIKIDECK_MAINNET_RISK_ACK: '' };
|
||||
const result = spawnSync(process.execPath, args, { env, encoding: 'utf8', timeout: 30000 });
|
||||
assert.notEqual(result.status, 0); assert.match(result.stderr, /launch-gated/);
|
||||
const manifest = JSON.parse(execFileSync(process.execPath, [...args, '--network-manifest'], { env, encoding: 'utf8' }));
|
||||
@@ -48,10 +49,11 @@ test('mainnet gates require genesis time, chain-specific approval, HTTPS, and in
|
||||
const result = JSON.parse(script(`
|
||||
import { assertLaunchAllowed } from './server/launch.ts';
|
||||
import { CHAIN_ID, GENESIS_TIME } from './server/testnet/consensus.ts';
|
||||
const env={WIKIDECK_MAINNET_LAUNCH:CHAIN_ID,WIKIDECK_MAINNET_REVIEW_ACK:'independent-review-complete',
|
||||
const env={WIKIDECK_MAINNET_LAUNCH:CHAIN_ID,WIKIDECK_MAINNET_RISK_ACK:'operator-accepts-unaudited-risk',
|
||||
PUBLIC_ORIGIN:'https://wikideck.example',WIKIDECK_PEERS:'https://peer-a.example,https://peer-b.example'};
|
||||
const results=[];
|
||||
for(const [changes,now] of [[{},0],[{WIKIDECK_MAINNET_LAUNCH:'wrong'},Infinity],
|
||||
[{WIKIDECK_MAINNET_RISK_ACK:'not-accepted'},Infinity],
|
||||
[{PUBLIC_ORIGIN:'http://wikideck.example'},Infinity],[{WIKIDECK_PEERS:''},Infinity],
|
||||
[{WIKIDECK_PEERS:'https://peer-a.example,https://peer-a.example/'},Infinity],
|
||||
[{WIKIDECK_ALLOW_PRIVATE_PEERS:'1'},Infinity],[{},Infinity]]) {
|
||||
@@ -59,7 +61,7 @@ test('mainnet gates require genesis time, chain-specific approval, HTTPS, and in
|
||||
}
|
||||
console.log(JSON.stringify(results));
|
||||
`));
|
||||
assert.deepEqual(result, [false,false,false,false,false,false,true]);
|
||||
assert.deepEqual(result, [false,false,false,false,false,false,false,true]);
|
||||
});
|
||||
test('mainnet ledger uses its isolated folder; testnet backup headers are rejected', async () => {
|
||||
const dir = await mkdtemp(join(tmpdir(), 'wikideck-network-'));
|
||||
@@ -89,8 +91,8 @@ test('operator preflight is read-only, fails closed, and does not disclose crede
|
||||
const dataDir = join(dir, 'must-not-be-created');
|
||||
const secret = 'test-only-sensitive-value-must-not-appear';
|
||||
const result = spawnSync(process.execPath, ['--experimental-strip-types', 'server/index.ts', '--launch-preflight'], {
|
||||
env: { ...process.env, WIKIDECK_NETWORK: 'mainnet', WIKIDECK_DATA_DIR: dataDir,
|
||||
WIKIDECK_MAINNET_LAUNCH: '', WIKIDECK_MAINNET_REVIEW_ACK: '', PAYMENT_PROVIDER_API_KEY: secret },
|
||||
env: { ...process.env, WIKIDECK_NETWORK: 'mainnet', WIKIDECK_GENESIS_TIME: '1798761600', WIKIDECK_DATA_DIR: dataDir,
|
||||
WIKIDECK_MAINNET_LAUNCH: '', WIKIDECK_MAINNET_RISK_ACK: '', PAYMENT_PROVIDER_API_KEY: secret },
|
||||
encoding: 'utf8', timeout: 30000,
|
||||
});
|
||||
assert.equal(result.status, 1);
|
||||
|
||||
Reference in New Issue
Block a user