Intelligence, Advanced Charting & Trading Platform
test(risk): prohibit price persistence without verified historical-storage rights
davoodmehraban89 committed
Oct 22, 2026 at 23:41 UTC
b025284f573211bf1a63b44542865173fb37d4d2
1 file changed
+13
-1
packages/market-domain/test/alert-postgres-coordinator.test.mjs
+13
-1
@@ -10,7 +10,7 @@ const timestamp='2026-10-22T12:00:00.000Z';
10
const rule={id:'usd-upper',symbol:'USD_IRT_FREE',provider:'LicensedFeed',unit:'IRT_PER_USD',
11
legs:[{type:'ABOVE',side:'SELL',threshold:100}]};
12
const quote={provider:rule.provider,symbol:rule.symbol,unit:rule.unit,side:'SELL',
13
- price:110,timestamp,permission:{publicDisplay:true,derivedAlerts:true}};
13
+ price:110,timestamp,permission:{publicDisplay:true,derivedAlerts:true,historicalStorage:true}};
14
const NON_ADVISORY='اطلاعات آموزشی و غیرتوصیهای';
15
const event={kind:'INFORMATIONAL_THRESHOLD',
16
id:'usd-upper:2026-10-22T12:00:00.000Z:0',
@@ -145,3 +145,15 @@ test('refuses inconsistent/malformed database responses',async()=>{
145
};
146
await assert.rejects(()=>evaluateAndPersistAlert(args(e)),/CORRUPT_ALERT_STATE_RESULT/);
147
});
148
+
149
+test('no historical-storage entitlement forbids ANY database read or write',async()=>{
150
+ for(const permission of [null,{publicDisplay:true,derivedAlerts:true},
151
+ {publicDisplay:true,historicalStorage:true},
152
+ {derivedAlerts:true,historicalStorage:true}]){
153
+ const e=engine();
154
+ await assert.rejects(()=>evaluateAndPersistAlert({
155
+ ...args(e),observation:{...quote,permission}
156
+ }),/PRICE_STORAGE_OR_ALERT_RIGHTS_UNVERIFIED/);
157
+ assert.equal(e.db.calls.length,0);
158
+ }
159
+});