engine: Fix nil pointer panic in TestGetHistoricCandles (#1976)

* Initial plan

* Fix nil pointer panic in TestGetHistoricCandles by adding early returns

Co-authored-by: thrasher- <4685270+thrasher-@users.noreply.github.com>

* Replace error handling with require.NoError in TestGetHistoricCandles

Co-authored-by: gbjk <86617+gbjk@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thrasher- <4685270+thrasher-@users.noreply.github.com>
Co-authored-by: gbjk <86617+gbjk@users.noreply.github.com>
This commit is contained in:
Copilot
2025-07-21 10:19:32 +10:00
committed by GitHub
parent 844b3b03b4
commit 1c24bf2491

View File

@@ -821,9 +821,7 @@ func TestGetHistoricCandles(t *testing.T) {
AssetType: asset.Spot.String(),
TimeInterval: int64(kline.OneHour.Duration()),
})
if err != nil {
t.Error(err)
}
require.NoError(t, err)
if len(results.Candle) == 0 {
t.Error("expected results")
}
@@ -842,9 +840,7 @@ func TestGetHistoricCandles(t *testing.T) {
Sync: true,
ExRequest: true,
})
if err != nil {
t.Error(err)
}
require.NoError(t, err)
if len(results.Candle) == 0 {
t.Error("expected results")
}
@@ -862,9 +858,7 @@ func TestGetHistoricCandles(t *testing.T) {
TimeInterval: int64(kline.OneHour.Duration()),
UseDb: true,
})
if err != nil {
t.Error(err)
}
require.NoError(t, err)
if len(results.Candle) == 0 {
t.Error("expected results")
}
@@ -896,9 +890,7 @@ func TestGetHistoricCandles(t *testing.T) {
UseDb: true,
FillMissingWithTrades: true,
})
if err != nil {
t.Error(err)
}
require.NoError(t, err)
if results.Candle[len(results.Candle)-1].Close != 1337 {
t.Error("expected fancy new candle based off fancy new trade data")
}