implemented persistence
Generate check / check-changes (pull_request) Successful in 36s
Quality / check-changes (pull_request) Successful in 35s
Generate check / verify-generate (pull_request) Successful in 48s
Quality / run-tests (pull_request) Successful in 51s

This commit is contained in:
2026-08-02 15:53:27 +01:00
parent 6fcc21adfe
commit 5fe47746fa
15 changed files with 1447 additions and 48 deletions
+44
View File
@@ -271,3 +271,47 @@ func TestFillerQueue_AdjustForSplit_NilReceiver(t *testing.T) {
var fq *FillerQueue
fq.AdjustForSplit(decimal.NewFromFloat(5)) // must not panic
}
func TestNewFillerFromState(t *testing.T) {
// The underlying Record reports very different values; NewFillerFromState
// must ignore them and use the caller-supplied overrides instead.
rec := &testRecord{
quantity: decimal.NewFromFloat(999),
price: decimal.NewFromFloat(999),
}
qty := decimal.NewFromFloat(50)
price := decimal.NewFromFloat(20)
filled := qty // fully filled on load
f := NewFillerFromState(rec, qty, price, filled)
if !f.Quantity().Equal(qty) {
t.Errorf("want quantity %v but got %v", qty, f.Quantity())
}
if !f.Price().Equal(price) {
t.Errorf("want price %v but got %v", price, f.Price())
}
if !f.IsFilled() {
t.Errorf("want IsFilled() to be true when filled == quantity")
}
// Partially filled: filled < quantity => IsFilled must be false.
partial := NewFillerFromState(rec, qty, price, decimal.NewFromFloat(10))
if partial.IsFilled() {
t.Errorf("want IsFilled() to be false when filled < quantity")
}
if !partial.Quantity().Equal(qty) {
t.Errorf("want quantity %v but got %v", qty, partial.Quantity())
}
if !partial.Price().Equal(price) {
t.Errorf("want price %v but got %v", price, partial.Price())
}
// Filled from Fill() on a restored lot must work correctly against the
// restored (not Record-derived) quantity/price.
_, done := partial.Fill(decimal.NewFromFloat(40))
if !done {
t.Errorf("after filling the remaining 40, IsFilled() should be true")
}
}