mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-17 14:21:25 +02:00
A browser-based roguelike synchronized with crypto block timing. A run is a race against the next block: reach the exit before the block lands, or the house wins. The same codebase runs the solo dungeon, the social Tavern, and operator-selected PvP and race rulesets, with separate free and paid leaderboards. Self-hostable under the MIT License. See README.md to run it, docs/ARCHITECTURE.md for the design, and docs/DEPLOY.md to operate an instance.
50 lines
2.3 KiB
JavaScript
50 lines
2.3 KiB
JavaScript
/**
|
|
* ChainProfile registry (Pillar 3 foundation): one source for chain params across Smirk's five
|
|
* PoW chains, and the fix for decimals silently defaulting to 12 for anything but WOW/XMR.
|
|
*/
|
|
const ChainProfile = require('../src/chain/chainProfile');
|
|
const { inferCurrencyDecimals } = require('../src/game/helpers/gameModeUtils');
|
|
|
|
describe('ChainProfile', () => {
|
|
test('decimals are correct for every Smirk chain', () => {
|
|
expect(ChainProfile.decimalsFor('WOW')).toBe(11);
|
|
expect(ChainProfile.decimalsFor('XMR')).toBe(12);
|
|
expect(ChainProfile.decimalsFor('BTC')).toBe(8);
|
|
expect(ChainProfile.decimalsFor('LTC')).toBe(8);
|
|
expect(ChainProfile.decimalsFor('GRIN')).toBe(9);
|
|
});
|
|
|
|
test('mean block time + adapter family per chain', () => {
|
|
expect(ChainProfile.meanBlockTimeMsFor('GRIN')).toBe(60000); // ~1 min, fast floor
|
|
expect(ChainProfile.meanBlockTimeMsFor('BTC')).toBe(600000); // ~10 min, slow end
|
|
expect(ChainProfile.familyFor('WOW')).toBe('monero');
|
|
expect(ChainProfile.familyFor('BTC')).toBe('utxo');
|
|
expect(ChainProfile.familyFor('LTC')).toBe('utxo');
|
|
expect(ChainProfile.familyFor('GRIN')).toBe('mimblewimble');
|
|
});
|
|
|
|
test('atomic divisor is a BigInt of the right scale', () => {
|
|
expect(ChainProfile.atomicDivisor('WOW')).toBe(100000000000n); // 1e11
|
|
expect(ChainProfile.atomicDivisor('BTC')).toBe(100000000n); // 1e8
|
|
expect(ChainProfile.atomicDivisor('GRIN')).toBe(1000000000n); // 1e9
|
|
});
|
|
|
|
test('case-insensitive; unknown falls back safely', () => {
|
|
expect(ChainProfile.getProfile('grin').decimals).toBe(9);
|
|
expect(ChainProfile.isSupported('DOGE')).toBe(false);
|
|
const fb = ChainProfile.getProfile('DOGE');
|
|
expect(fb.decimals).toBe(12);
|
|
expect(fb.family).toBe('monero');
|
|
});
|
|
});
|
|
|
|
describe('inferCurrencyDecimals now delegates to ChainProfile', () => {
|
|
test('WOW/XMR unchanged; BTC/GRIN fixed (were silently 12)', () => {
|
|
expect(inferCurrencyDecimals('WOW')).toBe(11);
|
|
expect(inferCurrencyDecimals('XMR')).toBe(12);
|
|
expect(inferCurrencyDecimals('BTC')).toBe(8);
|
|
expect(inferCurrencyDecimals('GRIN')).toBe(9);
|
|
expect(inferCurrencyDecimals('')).toBe(12);
|
|
});
|
|
});
|