feat: expose immutable release identity

This commit is contained in:
jwinterm
2026-07-23 13:27:17 -04:00
parent 578f6ce1a0
commit 6a3d5f8191
7 changed files with 203 additions and 1 deletions
+10
View File
@@ -228,6 +228,16 @@ describe('GameModeManager', () => {
}
});
test('game mode info binds Socket.IO clients to the immutable release', () => {
const release = {
verified: true,
id: `git-${'a'.repeat(12)}`,
commit: 'a'.repeat(40)
};
gmm.releaseIdentity = release;
expect(gmm.getGameModeInfo().release).toEqual(release);
});
test('crypto race economy is hidden when the payout master switch is off', () => {
const keys = [
'MATCH_ENABLED', 'MATCH_CRYPTO_RACE_ENABLED', 'MATCH_PAYOUTS_ENABLED',
+33 -1
View File
@@ -16,7 +16,39 @@ describe('public health payload', () => {
status: 'ok',
ready: true,
checks: { database: 'up', chain: 'up', wallet: 'up' },
money: { paymentsEnabled: true, payoutsEnabled: false }
money: { paymentsEnabled: true, payoutsEnabled: false },
release: { verified: false, id: null, commit: null }
});
});
test('publishes only a self-consistent immutable release identity', () => {
const commit = 'a'.repeat(40);
const health = buildPublicHealth({
databaseReady: true,
blockHeight: 123,
releaseIdentity: {
verified: true,
id: `git-${commit.slice(0, 12)}`,
commit
}
});
expect(health.release).toEqual({
verified: true,
id: `git-${commit.slice(0, 12)}`,
commit
});
const mismatched = buildPublicHealth({
releaseIdentity: {
verified: true,
id: `git-${'b'.repeat(12)}`,
commit
}
});
expect(mismatched.release).toEqual({
verified: false,
id: null,
commit: null
});
});
+64
View File
@@ -0,0 +1,64 @@
const fs = require('fs');
const os = require('os');
const path = require('path');
const {
loadReleaseIdentity,
readBoundedRegularFile
} = require('../src/config/releaseIdentity');
describe('immutable release identity', () => {
let root;
beforeEach(() => {
root = fs.mkdtempSync(path.join(os.tmpdir(), 'wowngeon-release-identity-'));
});
afterEach(() => {
fs.rmSync(root, { recursive: true, force: true });
});
function writeIdentity(commit = 'a'.repeat(40), id = `git-${commit.slice(0, 12)}`) {
fs.writeFileSync(path.join(root, '.release-id'), `${id}\n`, { mode: 0o444 });
fs.writeFileSync(path.join(root, '.release-commit'), `${commit}\n`, { mode: 0o444 });
}
test('returns the matching artifact release ID and commit', () => {
writeIdentity();
expect(loadReleaseIdentity({ releaseRoot: root, production: true })).toEqual({
verified: true,
id: `git-${'a'.repeat(12)}`,
commit: 'a'.repeat(40)
});
});
test('fails production closed when identity files disagree', () => {
writeIdentity('b'.repeat(40), `git-${'c'.repeat(12)}`);
expect(() => loadReleaseIdentity({ releaseRoot: root, production: true }))
.toThrow('production release identity is absent or invalid');
});
test('fails production closed when either identity file is absent', () => {
expect(() => loadReleaseIdentity({ releaseRoot: root, production: true }))
.toThrow('production release identity is absent or invalid');
});
test('returns an explicit unverified identity outside production', () => {
expect(loadReleaseIdentity({ releaseRoot: root, production: false })).toEqual({
verified: false,
id: null,
commit: null
});
});
test('refuses symlinks and oversized identity files', () => {
const target = path.join(root, 'target');
fs.writeFileSync(target, 'a'.repeat(40));
const linked = path.join(root, 'linked');
fs.symlinkSync(target, linked);
expect(() => readBoundedRegularFile(linked)).toThrow();
const oversized = path.join(root, 'oversized');
fs.writeFileSync(oversized, 'x'.repeat(129));
expect(() => readBoundedRegularFile(oversized)).toThrow('unsafe shape');
});
});