Skip to content

Commit 6c57cdf

Browse files
authored
feat: only allow override strategies on pro spaces (#581)
1 parent c214894 commit 6c57cdf

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/helpers/validation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,9 @@ export async function validateSpaceSettings(
7676
if (strategy.disabled) {
7777
return Promise.reject(`strategy "${id}" is not available anymore`);
7878
}
79+
80+
if (strategy.override && spaceType !== 'turbo') {
81+
return Promise.reject(`strategy "${id}" is only available for pro spaces`);
82+
}
7983
}
8084
}

test/unit/helpers/validation.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,37 @@ describe('helpers/validation', () => {
109109
'strategy "strategy1" is not available anymore'
110110
);
111111
});
112+
113+
it('should reject override strategy for non-turbo space', async () => {
114+
mockStrategies['override-strategy'] = {
115+
id: 'override-strategy',
116+
disabled: false,
117+
override: true
118+
};
119+
120+
const space = createMockSpace({
121+
strategies: [{ name: 'override-strategy', params: {} }]
122+
});
123+
124+
await expect(validateSpaceSettings(space, 'mainnet')).rejects.toBe(
125+
'strategy "override-strategy" is only available for pro spaces'
126+
);
127+
});
128+
129+
it('should allow override strategy for turbo space', async () => {
130+
mockStrategies['override-strategy'] = {
131+
id: 'override-strategy',
132+
disabled: false,
133+
override: true
134+
};
135+
136+
const space = createMockSpace({
137+
turbo: true,
138+
strategies: [{ name: 'override-strategy', params: {} }]
139+
});
140+
141+
await expect(validateSpaceSettings(space, 'mainnet')).resolves.toBeUndefined();
142+
});
112143
});
113144

114145
describe('other validations', () => {

0 commit comments

Comments
 (0)