From d4276d666506176ab251887991bfd9574fe2eee7 Mon Sep 17 00:00:00 2001 From: wa0x6e <495709+wa0x6e@users.noreply.github.com> Date: Fri, 15 Aug 2025 04:23:32 +0400 Subject: [PATCH] feat: only allow override strategies on pro spaces --- src/helpers/validation.ts | 4 ++++ test/unit/helpers/validation.test.ts | 31 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/helpers/validation.ts b/src/helpers/validation.ts index 8314831f..33de4004 100644 --- a/src/helpers/validation.ts +++ b/src/helpers/validation.ts @@ -76,5 +76,9 @@ export async function validateSpaceSettings( if (strategy.disabled) { return Promise.reject(`strategy "${id}" is not available anymore`); } + + if (strategy.override && spaceType !== 'turbo') { + return Promise.reject(`strategy "${id}" is only available for pro spaces`); + } } } diff --git a/test/unit/helpers/validation.test.ts b/test/unit/helpers/validation.test.ts index 4ea65fd4..3d98a460 100644 --- a/test/unit/helpers/validation.test.ts +++ b/test/unit/helpers/validation.test.ts @@ -109,6 +109,37 @@ describe('helpers/validation', () => { 'strategy "strategy1" is not available anymore' ); }); + + it('should reject override strategy for non-turbo space', async () => { + mockStrategies['override-strategy'] = { + id: 'override-strategy', + disabled: false, + override: true + }; + + const space = createMockSpace({ + strategies: [{ name: 'override-strategy', params: {} }] + }); + + await expect(validateSpaceSettings(space, 'mainnet')).rejects.toBe( + 'strategy "override-strategy" is only available for pro spaces' + ); + }); + + it('should allow override strategy for turbo space', async () => { + mockStrategies['override-strategy'] = { + id: 'override-strategy', + disabled: false, + override: true + }; + + const space = createMockSpace({ + turbo: true, + strategies: [{ name: 'override-strategy', params: {} }] + }); + + await expect(validateSpaceSettings(space, 'mainnet')).resolves.toBeUndefined(); + }); }); describe('other validations', () => {