eleventh version
Deploy / Test, build and deploy (push) Failing after 2m15s

This commit is contained in:
2026-06-08 15:33:56 +00:00
parent 7626c1b831
commit e074eeedf2
22 changed files with 681 additions and 55 deletions
+28
View File
@@ -2,6 +2,7 @@ package risk
import (
"testing"
"time"
"github.com/shopspring/decimal"
@@ -26,3 +27,30 @@ func TestPreTradeClosingPositionBypassesOpenPositionLimit(t *testing.T) {
t.Fatalf("entry result=%+v, want max_open_positions reject", result)
}
}
func TestPreTradeRejectsServerClockDrift(t *testing.T) {
manager := NewManager(nil, ManagerConfig{})
input := PreTradeInput{
Portfolio: domain.Portfolio{Equity: decimal.NewFromInt(1000)},
TradingStatus: domain.TradingStatusNormal,
ServerClockDrift: 3 * time.Second,
MaxClockDrift: 2 * time.Second,
}
result := manager.PreTradeCheck(input)
if result.Allowed || result.Reason != "server_clock_drift_too_high" {
t.Fatalf("result=%+v, want server_clock_drift_too_high reject", result)
}
}
func TestPreTradeRejectsUnavailableServerTime(t *testing.T) {
manager := NewManager(nil, ManagerConfig{})
input := PreTradeInput{
Portfolio: domain.Portfolio{Equity: decimal.NewFromInt(1000)},
TradingStatus: domain.TradingStatusNormal,
ServerTimeUnavailable: true,
}
result := manager.PreTradeCheck(input)
if result.Allowed || result.Reason != "server_time_unavailable" {
t.Fatalf("result=%+v, want server_time_unavailable reject", result)
}
}