Files
overnight-trading-bot/internal/tinvest/real_test.go
T
Valentin Popov b9efa98758
Deploy / Test, build and deploy (push) Failing after 3m7s
fourth version
2026-06-08 07:36:52 +00:00

40 lines
1.2 KiB
Go

package tinvest
import (
"strings"
"testing"
pb "github.com/russianinvestments/invest-api-go-sdk/proto"
"github.com/shopspring/decimal"
"overnight-trading-bot/internal/domain"
)
func TestOrderFromPostResponseZeroFillHasZeroAvgPrice(t *testing.T) {
order := orderFromPostResponse(&pb.PostOrderResponse{
OrderId: "broker",
ExecutionReportStatus: pb.OrderExecutionReportStatus_EXECUTION_REPORT_STATUS_NEW,
LotsRequested: 1,
LotsExecuted: 0,
ExecutedOrderPrice: &pb.MoneyValue{Currency: "rub", Units: 100},
InstrumentUid: "uid",
}, "account", "client", domain.SideBuy, decimal.NewFromInt(100))
if !order.AvgFillPrice.IsZero() {
t.Fatalf("avg fill price=%s, want zero for unfilled order", order.AvgFillPrice)
}
}
func TestMarshalProtoRedactsAccountID(t *testing.T) {
raw := marshalProto(&pb.OrderTrades{
OrderId: "order",
AccountId: "plain-account-id",
InstrumentUid: "uid",
})
if strings.Contains(raw, "plain-account-id") || strings.Contains(raw, "accountId") || strings.Contains(raw, "account_id") {
t.Fatalf("raw proto leaked account id: %s", raw)
}
if !strings.Contains(raw, "order") {
t.Fatalf("sanitizer removed non-sensitive data: %s", raw)
}
}