@@ -948,6 +948,42 @@ func TestBlock(t *testing.T) {
948
948
},
949
949
},
950
950
}
951
+ relatedMissingTransaction := & types.Transaction {
952
+ TransactionIdentifier : & types.TransactionIdentifier {
953
+ Hash : "blah" ,
954
+ },
955
+ Operations : []* types.Operation {
956
+ {
957
+ OperationIdentifier : & types.OperationIdentifier {
958
+ Index : int64 (0 ),
959
+ },
960
+ Type : "PAYMENT" ,
961
+ Status : types .String ("SUCCESS" ),
962
+ Account : validAccount ,
963
+ Amount : validAmount ,
964
+ },
965
+ {
966
+ OperationIdentifier : & types.OperationIdentifier {
967
+ Index : int64 (1 ),
968
+ },
969
+ RelatedOperations : []* types.OperationIdentifier {},
970
+ Type : "PAYMENT" ,
971
+ Status : types .String ("SUCCESS" ),
972
+ Account : validAccount ,
973
+ Amount : validAmount ,
974
+ },
975
+ {
976
+ OperationIdentifier : & types.OperationIdentifier {
977
+ Index : int64 (2 ),
978
+ },
979
+ RelatedOperations : []* types.OperationIdentifier {},
980
+ Type : "PAYMENT" ,
981
+ Status : types .String ("SUCCESS" ),
982
+ Account : validAccount ,
983
+ Amount : validAmount ,
984
+ },
985
+ },
986
+ }
951
987
invalidRelatedTransaction := & types.Transaction {
952
988
TransactionIdentifier : & types.TransactionIdentifier {
953
989
Hash : "blah" ,
@@ -1044,10 +1080,11 @@ func TestBlock(t *testing.T) {
1044
1080
}
1045
1081
1046
1082
var tests = map [string ]struct {
1047
- block * types.Block
1048
- genesisIndex int64
1049
- startIndex * int64
1050
- err error
1083
+ block * types.Block
1084
+ validationFilePath string
1085
+ genesisIndex int64
1086
+ startIndex * int64
1087
+ err error
1051
1088
}{
1052
1089
"valid block" : {
1053
1090
block : & types.Block {
@@ -1132,6 +1169,16 @@ func TestBlock(t *testing.T) {
1132
1169
},
1133
1170
err : ErrRelatedOperationIndexDuplicate ,
1134
1171
},
1172
+ "missing related transaction operations" : {
1173
+ block : & types.Block {
1174
+ BlockIdentifier : validBlockIdentifier ,
1175
+ ParentBlockIdentifier : validParentBlockIdentifier ,
1176
+ Timestamp : MinUnixEpoch + 1 ,
1177
+ Transactions : []* types.Transaction {relatedMissingTransaction },
1178
+ },
1179
+ err : ErrRelatedOperationMissing ,
1180
+ validationFilePath : "data/validation_balanced_related_ops.json" ,
1181
+ },
1135
1182
"nil block" : {
1136
1183
block : nil ,
1137
1184
err : ErrBlockIsNil ,
@@ -1280,7 +1327,7 @@ func TestBlock(t *testing.T) {
1280
1327
TimestampStartIndex : test .startIndex ,
1281
1328
},
1282
1329
},
1283
- "" ,
1330
+ test . validationFilePath ,
1284
1331
)
1285
1332
assert .NotNil (t , asserter )
1286
1333
assert .NoError (t , err )
0 commit comments