@@ -22,6 +22,7 @@ import (
2222 "fmt"
2323 "testing"
2424
25+ "github.com/hyperledger/firefly-common/pkg/config"
2526 "github.com/hyperledger/firefly-common/pkg/fftypes"
2627 "github.com/hyperledger/firefly-transaction-manager/internal/tmconfig"
2728 "github.com/hyperledger/firefly-transaction-manager/pkg/apitypes"
@@ -201,6 +202,34 @@ func TestManagedTXSubStatusMaxEntries(t *testing.T) {
201202
202203}
203204
205+ func TestMaxHistoryCountSetToZero (t * testing.T ) {
206+ tmconfig .Reset ()
207+ config .Set (tmconfig .TransactionsMaxHistoryCount , 0 )
208+ ctx , cancelCtx := context .WithCancel (context .Background ())
209+ h := NewTxHistoryManager (ctx ).(* manager )
210+ defer cancelCtx ()
211+ mtx := & apitypes.ManagedTX {}
212+
213+ h .SetSubStatus (ctx , mtx , apitypes .TxSubStatusReceived )
214+ h .AddSubStatusAction (ctx , mtx , apitypes .TxActionSubmitTransaction , nil , nil )
215+ assert .Equal (t , 0 , len (mtx .History ))
216+ assert .Equal (t , 0 , len (mtx .HistorySummary ))
217+
218+ }
219+
220+ func TestAddReceivedStatusWhenNothingSet (t * testing.T ) {
221+ ctx , h , done := newTestTxHistoryManager (t )
222+
223+ defer done ()
224+ mtx := & apitypes.ManagedTX {}
225+
226+ assert .Equal (t , 0 , len (mtx .History ))
227+ h .AddSubStatusAction (ctx , mtx , apitypes .TxActionSubmitTransaction , nil , nil )
228+ assert .Equal (t , 1 , len (mtx .History ))
229+ assert .Equal (t , 1 , len (mtx .History [0 ].Actions ))
230+ assert .Equal (t , apitypes .TxSubStatusReceived , mtx .History [0 ].Status )
231+ assert .Equal (t , apitypes .TxActionSubmitTransaction , mtx .History [0 ].Actions [0 ].Action )
232+ }
204233func TestJSONOrStringNull (t * testing.T ) {
205234 assert .Nil (t , jsonOrString (nil ))
206235}
0 commit comments