This commit is contained in:
2026-11-05 09:57:11 -05:00
parent d34388bf2c
commit 89e392cc2e
81 changed files with 12410 additions and 1135 deletions
+28 -9
View File
@@ -64,7 +64,7 @@ test('package twice: identical full inventory and manifest hashes, original asse
assert.deepEqual(await inventory(a), await inventory(b));
const hash = data => createHash('sha256').update(data).digest('hex');
assert.equal(hash(await fs.readFile(path.join(a, MANIFEST))), hash(await fs.readFile(path.join(b, MANIFEST))));
const manifest = await verifyPackage(a);
const manifest = await verifyPackage(a,{requireBundled:false});
assert.ok(manifest.entries.some(entry => entry.path === 'release.json'));
for (const absent of ['scripts', 'tests', '.git', 'README.md', 'secret.env', 'mods/hearth/textures/stale.png']) assert.equal(await exists(path.join(a, absent)), false);
assert.deepEqual(await fs.readFile(path.join(a, 'mods/hearth/data.png')), binary);
@@ -114,7 +114,7 @@ test('package manifest rejects missing, extra, corrupted files and extra empty d
if (kind === 'extra') await fs.writeFile(path.join(destination, 'extra'), binary);
if (kind === 'corrupt') await fs.appendFile(path.join(destination, 'game.conf'), 'bad');
if (kind === 'directory') await fs.mkdir(path.join(destination, 'empty-extra'));
await assert.rejects(verifyPackage(destination), /manifest mismatch/);
await assert.rejects(verifyPackage(destination,{requireBundled:false}), /manifest mismatch/);
}
});
@@ -370,19 +370,38 @@ test('CLI package/verify work with absent engine and invalid runtime env; backup
test('new-world terrain preset is pure, explicit, bounded and matches packaged game defaults', async () => {
const first = terrainSettings(true);
const expected = [
'mg_name = v7', 'fixed_map_seed = 731104', 'water_level = 32',
'mapgen_limit = 4096',
'mg_flags = caves,nodungeons,light,biomes,ores',
'mgv7_spflags = mountains,ridges,nofloatlands,caverns',
'mgv7_mount_zero_level = 0',
'mgv7_np_terrain_base = 12, 45, (900, 384, 900), 82341, 5, 0.6, 2.0',
'mgv7_np_terrain_alt = -8, 24, (900, 384, 900), 5934, 5, 0.6, 2.0',
'mgv7_np_terrain_persist = 0.6, 0.1, (1200, 1200, 1200), 539, 3, 0.6, 2.0',
'mgv7_np_height_select = -4, 14, (1400, 320, 1400), 4213, 6, 0.7, 2.0',
'mgv7_np_filler_depth = 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0',
'mgv7_np_mount_height = 250, 100, (700, 700, 700), 72449, 3, 0.6, 2.0',
'mgv7_np_mountain = -0.6, 1, (320, 280, 320), 5333, 5, 0.63, 2.0',
'mgv7_np_ridge_uwater = 0, 1, (700, 700, 700), 85039, 5, 0.6, 2.0',
'mgv7_np_ridge = 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0',
'mg_biome_np_heat = 50, 50, (256, 256, 256), 5349, 3, 0.5, 2.0',
'mg_biome_np_humidity = 50, 50, (256, 256, 256), 842, 3, 0.5, 2.0',
'epic_terrain_enable = true',
];
assert.deepEqual(first, expected);
assert.deepEqual(terrainSettings(false), []);
assert.throws(() => terrainSettings('true'), /boolean/);
assert.ok(first.includes('mapgen_limit = 4096'));
assert.ok(first.includes('mgv7_spflags = mountains,ridges,nofloatlands,caverns'));
assert.ok(first.includes('mgv7_np_terrain_base = 12, 45, (384, 384, 384), 82341, 5, 0.6, 2.0'));
assert.ok(first.includes('mgv7_np_mount_height = 250, 100, (700, 700, 700), 72449, 3, 0.6, 2.0'));
const defaults = (await fs.readFile(path.join(SOURCE, 'minetest.conf'), 'utf8'))
.split(/\r?\n/).filter(isTerrainSetting).sort();
assert.deepEqual(first.filter(line => !line.startsWith('fixed_map_seed')).sort(), defaults);
.split(/\r?\n/).filter(isTerrainSetting).filter(line => !line.startsWith('epic_terrain_enable')).sort();
assert.deepEqual(first.filter(line => !line.startsWith('fixed_map_seed') && !line.startsWith('epic_terrain_enable')).sort(), defaults);
assert.equal(new Set(first.map(line => line.split('=')[0].trim())).size, first.length);
first[0] = 'mg_name = flat'; first.push('untrusted = true');
assert.equal(terrainSettings(true)[0], 'mg_name = v7');
for (const line of ['mg_name = v7', ' mgv7_np_terrain_base = 1', 'mg_biome_np_heat = 1',
for (const line of ['mg_name = v7', ' mgv7_np_terrain_base = 1', 'mg_biome_np_heat = 1', 'epic_terrain_enable = true',
'fixed_map_seed = 42', 'mapgen_limit = 512', 'water_level = 1']) assert.ok(isTerrainSetting(line), line);
assert.equal(isTerrainSetting('hearth_latitude = 45'), false);
});
@@ -405,7 +424,7 @@ test('world creation writes terrain once; subsequent ephemeral configs never ret
'mgv7_np_mountain = 1', 'water_level = 30', 'mapgen_limit = 4096',
], 'local');
const second = await fs.readFile(secondConfig, 'utf8');
assert.deepEqual(second.split(/\r?\n/).filter(isTerrainSetting), []);
assert.deepEqual(second.split(/\r?\n/).filter(isTerrainSetting), ['epic_terrain_enable = false']);
assert.match(second, /hearth_latitude = 45/);
assert.match(second, /secure.enable_security = true/);
assert.deepEqual(await fs.readFile(path.join(world, 'world.mt')), worldFile);
@@ -424,7 +443,7 @@ test('world.mt without map metadata and orphan map metadata each suppress creati
await fs.writeFile(path.join(world, name), bytes);
const config = path.join(root, path.basename(world) + '.conf');
await writeWorld(world, config, [], ['fixed_map_seed = 731104'], 'local');
assert.deepEqual((await fs.readFile(config, 'utf8')).split(/\r?\n/).filter(isTerrainSetting), []);
assert.deepEqual((await fs.readFile(config, 'utf8')).split(/\r?\n/).filter(isTerrainSetting), ['epic_terrain_enable = false']);
assert.deepEqual(await fs.readFile(path.join(world, name)), bytes);
}
});
@@ -497,7 +516,7 @@ test('play/course/test configs include unique graphics keys for new and existing
}
assert.ok(lines.includes('secure.enable_security = true'));
if (existing) {
assert.deepEqual(lines.filter(isTerrainSetting), []);
assert.deepEqual(lines.filter(isTerrainSetting), ['epic_terrain_enable = false']);
assert.deepEqual(await inventory(world), before);
} else {
for (const setting of terrainSettings(true)) assert.ok(lines.includes(setting), setting);