1
- // Copyright © 2022 Kaleido, Inc.
1
+ // Copyright © 2024 Kaleido, Inc.
2
2
//
3
3
// SPDX-License-Identifier: Apache-2.0
4
4
//
@@ -460,7 +460,7 @@ func TestAddSubStatusActionFail(t *testing.T) {
460
460
461
461
tx := newTestTX ("0x1234" , apitypes .TxStatusPending )
462
462
463
- err := p .AddSubStatusAction (ctx , tx .ID , apitypes .TxSubStatusTracking , apitypes .TxActionAssignNonce , nil , nil )
463
+ err := p .AddSubStatusAction (ctx , tx .ID , apitypes .TxSubStatusTracking , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
464
464
assert .Error (t , err )
465
465
466
466
}
@@ -834,7 +834,7 @@ func TestManagedTXSubStatus(t *testing.T) {
834
834
// Adding the same sub-status lots of times in succession should only result
835
835
// in a single entry for that instance
836
836
for i := 0 ; i < 100 ; i ++ {
837
- err := p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil )
837
+ err := p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
838
838
assert .NoError (t , err )
839
839
}
840
840
@@ -845,7 +845,7 @@ func TestManagedTXSubStatus(t *testing.T) {
845
845
846
846
// Adding a different type of sub-status should result in
847
847
// a new entry in the list
848
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusTracking , apitypes .TxActionAssignNonce , nil , nil )
848
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusTracking , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
849
849
assert .NoError (t , err )
850
850
851
851
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
@@ -855,9 +855,9 @@ func TestManagedTXSubStatus(t *testing.T) {
855
855
// Even if many new types are added we shouldn't go over the
856
856
// configured upper limit
857
857
for i := 0 ; i < 100 ; i ++ {
858
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusStale , apitypes .TxActionAssignNonce , nil , nil )
858
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusStale , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
859
859
assert .NoError (t , err )
860
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusTracking , apitypes .TxActionAssignNonce , nil , nil )
860
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusTracking , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
861
861
assert .NoError (t , err )
862
862
}
863
863
@@ -875,22 +875,22 @@ func TestManagedTXSubStatusRepeat(t *testing.T) {
875
875
assert .NoError (t , err )
876
876
877
877
// Add a sub-status
878
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil )
878
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
879
879
assert .NoError (t , err )
880
880
txh , err := p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
881
881
assert .NoError (t , err )
882
882
assert .Equal (t , 1 , len (txh .History ))
883
883
assert .Equal (t , 2 , len (txh .DeprecatedHistorySummary ))
884
884
885
885
// Add another sub-status
886
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusTracking , apitypes .TxActionSubmitTransaction , nil , nil )
886
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusTracking , apitypes .TxActionSubmitTransaction , nil , nil , fftypes . Now () )
887
887
assert .NoError (t , err )
888
888
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
889
889
assert .Equal (t , 2 , len (txh .History ))
890
890
assert .Equal (t , 4 , len (txh .DeprecatedHistorySummary ))
891
891
892
892
// Add another that we've seen before
893
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , nil , nil )
893
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , nil , nil , fftypes . Now () )
894
894
assert .NoError (t , err )
895
895
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
896
896
assert .Equal (t , 3 , len (txh .History )) // This goes up
@@ -902,30 +902,30 @@ func TestManagedTXSubStatusAction(t *testing.T) {
902
902
defer done ()
903
903
mtx := newTestTX ("0x12345" , apitypes .TxStatusPending )
904
904
905
- err := p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil )
905
+ err := p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
906
906
assert .Regexp (t , "FF21067" , err )
907
907
908
908
err = p .InsertTransactionWithNextNonce (ctx , mtx , func (ctx context.Context , signer string ) (uint64 , error ) { return 12345 , nil })
909
909
assert .NoError (t , err )
910
910
911
911
// Add an action
912
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil )
912
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
913
913
assert .NoError (t , err )
914
914
txh , err := p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
915
915
assert .NoError (t , err )
916
916
assert .Equal (t , 1 , len (txh .History [0 ].Actions ))
917
917
assert .Nil (t , txh .History [0 ].Actions [0 ].LastErrorTime )
918
918
919
919
// Add another action
920
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionRetrieveGasPrice , nil , fftypes .JSONAnyPtr (`{"gasError":"Acme Gas Oracle RC=12345"}` ))
920
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionRetrieveGasPrice , nil , fftypes .JSONAnyPtr (`{"gasError":"Acme Gas Oracle RC=12345"}` ), fftypes . Now () )
921
921
assert .NoError (t , err )
922
922
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
923
923
assert .NoError (t , err )
924
924
assert .Equal (t , 2 , len (txh .History [0 ].Actions ))
925
925
assert .Equal (t , (* txh .History [0 ].Actions [1 ].LastError ).String (), `{"gasError":"Acme Gas Oracle RC=12345"}` )
926
926
927
927
// Add the same action which should cause the previous one to inc its counter
928
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionRetrieveGasPrice , fftypes .JSONAnyPtr (`{"info":"helloworld"}` ), fftypes .JSONAnyPtr (`{"error":"nogood"}` ))
928
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionRetrieveGasPrice , fftypes .JSONAnyPtr (`{"info":"helloworld"}` ), fftypes .JSONAnyPtr (`{"error":"nogood"}` ), fftypes . Now () )
929
929
assert .NoError (t , err )
930
930
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
931
931
assert .NoError (t , err )
@@ -934,7 +934,7 @@ func TestManagedTXSubStatusAction(t *testing.T) {
934
934
assert .Equal (t , 2 , txh .History [0 ].Actions [1 ].OccurrenceCount )
935
935
936
936
// Add the same action but with new error information should update the last error field
937
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionRetrieveGasPrice , nil , fftypes .JSONAnyPtr (`{"gasError":"Acme Gas Oracle RC=67890"}` ))
937
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionRetrieveGasPrice , nil , fftypes .JSONAnyPtr (`{"gasError":"Acme Gas Oracle RC=67890"}` ), fftypes . Now () )
938
938
assert .NoError (t , err )
939
939
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
940
940
assert .NoError (t , err )
@@ -944,7 +944,7 @@ func TestManagedTXSubStatusAction(t *testing.T) {
944
944
945
945
// Add a new type of action
946
946
reason := "known_transaction"
947
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , fftypes .JSONAnyPtr (`{"reason":"` + reason + `"}` ), nil )
947
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , fftypes .JSONAnyPtr (`{"reason":"` + reason + `"}` ), nil , fftypes . Now () )
948
948
assert .NoError (t , err )
949
949
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
950
950
assert .NoError (t , err )
@@ -956,7 +956,7 @@ func TestManagedTXSubStatusAction(t *testing.T) {
956
956
// Add one more type of action
957
957
958
958
receiptId := "123456"
959
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionReceiveReceipt , fftypes .JSONAnyPtr (`{"receiptId":"` + receiptId + `"}` ), nil )
959
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionReceiveReceipt , fftypes .JSONAnyPtr (`{"receiptId":"` + receiptId + `"}` ), nil , fftypes . Now () )
960
960
assert .NoError (t , err )
961
961
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
962
962
assert .NoError (t , err )
@@ -972,13 +972,13 @@ func TestManagedTXSubStatusAction(t *testing.T) {
972
972
973
973
// Add some new sub-status and actions to check max lengths are correct
974
974
// Seen one of these before - should increase summary length by 1
975
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusConfirmed , apitypes .TxActionReceiveReceipt , fftypes .JSONAnyPtr (`{"receiptId":"` + receiptId + `"}` ), nil )
975
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusConfirmed , apitypes .TxActionReceiveReceipt , fftypes .JSONAnyPtr (`{"receiptId":"` + receiptId + `"}` ), nil , fftypes . Now () )
976
976
assert .NoError (t , err )
977
977
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
978
978
assert .Equal (t , 6 , len (txh .DeprecatedHistorySummary ))
979
979
980
980
// Seen both of these before - no change expected
981
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil )
981
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
982
982
assert .NoError (t , err )
983
983
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
984
984
assert .NoError (t , err )
@@ -1070,7 +1070,7 @@ func TestManagedTXSubStatusInvalidJSON(t *testing.T) {
1070
1070
reason := "\" cannot-marshall\" "
1071
1071
1072
1072
// Add a new type of action
1073
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , fftypes .JSONAnyPtr (`{"reason":"` + reason + `"}` ), nil )
1073
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , fftypes .JSONAnyPtr (`{"reason":"` + reason + `"}` ), nil , fftypes . Now () )
1074
1074
assert .NoError (t , err )
1075
1075
txh , err := p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
1076
1076
assert .NoError (t , err )
@@ -1095,7 +1095,7 @@ func TestManagedTXSubStatusMaxEntries(t *testing.T) {
1095
1095
// first 50
1096
1096
for i := 0 ; i < 100 ; i ++ {
1097
1097
nextSubStatus = apitypes .TxSubStatus (fmt .Sprint (i ))
1098
- p .AddSubStatusAction (ctx , mtx .ID , nextSubStatus , apitypes .TxActionAssignNonce , nil , nil )
1098
+ p .AddSubStatusAction (ctx , mtx .ID , nextSubStatus , apitypes .TxActionAssignNonce , nil , nil , fftypes . Now () )
1099
1099
assert .NoError (t , err )
1100
1100
}
1101
1101
@@ -1114,7 +1114,7 @@ func TestMaxHistoryCountSetToZero(t *testing.T) {
1114
1114
err := p .InsertTransactionWithNextNonce (ctx , mtx , func (ctx context.Context , signer string ) (uint64 , error ) { return 12345 , nil })
1115
1115
assert .NoError (t , err )
1116
1116
1117
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , nil , nil )
1117
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , nil , nil , fftypes . Now () )
1118
1118
assert .NoError (t , err )
1119
1119
1120
1120
txh , err := p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
@@ -1141,7 +1141,7 @@ func TestAddReceivedStatusWhenNothingSet(t *testing.T) {
1141
1141
assert .NoError (t , err )
1142
1142
assert .Nil (t , txh .History )
1143
1143
1144
- err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , nil , nil )
1144
+ err = p .AddSubStatusAction (ctx , mtx .ID , apitypes .TxSubStatusReceived , apitypes .TxActionSubmitTransaction , nil , nil , fftypes . Now () )
1145
1145
assert .NoError (t , err )
1146
1146
1147
1147
txh , err = p .GetTransactionByIDWithStatus (ctx , mtx .ID , true )
0 commit comments