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', () => {