@@ -43,6 +43,9 @@ pub enum SignedEntityTypeMessagePart {
43
43
/// Full Cardano Immutable Files
44
44
CardanoImmutableFilesFull ( CardanoDbBeaconMessagePart ) ,
45
45
46
+ /// Cardano Database
47
+ CardanoDatabase ( CardanoDbBeacon ) ,
48
+
46
49
/// Cardano Transactions
47
50
CardanoTransactions ( Epoch , BlockNumber ) ,
48
51
}
@@ -110,6 +113,7 @@ impl From<SignedEntityTypeMessagePart> for SignedEntityType {
110
113
SignedEntityTypeMessagePart :: CardanoTransactions ( epoch, block_number) => {
111
114
Self :: CardanoTransactions ( epoch, block_number)
112
115
}
116
+ SignedEntityTypeMessagePart :: CardanoDatabase ( beacon) => Self :: CardanoDatabase ( beacon) ,
113
117
}
114
118
}
115
119
}
@@ -133,6 +137,10 @@ impl PartialEq<SignedEntityTypeMessagePart> for SignedEntityType {
133
137
& SignedEntityType :: CardanoTransactions ( left_epoch, left_block_number) ,
134
138
& SignedEntityTypeMessagePart :: CardanoTransactions ( right_epoch, right_block_number) ,
135
139
) => left_epoch == right_epoch && left_block_number == right_block_number,
140
+ (
141
+ & SignedEntityType :: CardanoDatabase ( left_beacon) ,
142
+ & SignedEntityTypeMessagePart :: CardanoDatabase ( right_beacon) ,
143
+ ) => left_beacon == right_beacon,
136
144
_ => false ,
137
145
}
138
146
}
@@ -163,9 +171,7 @@ impl<N: Into<String>> From<(SignedEntityType, N)> for SignedEntityTypeMessagePar
163
171
SignedEntityType :: CardanoTransactions ( epoch, block_number) => {
164
172
Self :: CardanoTransactions ( epoch, block_number)
165
173
}
166
- SignedEntityType :: CardanoDatabase ( _) => {
167
- panic ! ( "This conversion must not be used, this enum is temporary and will be removed. Use the CardanoDbBeacon from SignedEntityType directly instead." )
168
- }
174
+ SignedEntityType :: CardanoDatabase ( beacon) => Self :: CardanoDatabase ( beacon) ,
169
175
}
170
176
}
171
177
}
@@ -235,6 +241,12 @@ mod tests {
235
241
BlockNumber ( 4678 )
236
242
) )
237
243
) ;
244
+ assert_eq ! (
245
+ SignedEntityType :: CardanoDatabase ( CardanoDbBeacon :: new( 98 , 123 ) ) ,
246
+ SignedEntityType :: from( SignedEntityTypeMessagePart :: CardanoDatabase (
247
+ CardanoDbBeacon :: new( 98 , 123 )
248
+ ) )
249
+ ) ;
238
250
}
239
251
240
252
#[ test]
@@ -269,6 +281,13 @@ mod tests {
269
281
"unused"
270
282
) )
271
283
) ;
284
+ assert_eq ! (
285
+ SignedEntityTypeMessagePart :: CardanoDatabase ( CardanoDbBeacon :: new( 98 , 123 ) ) ,
286
+ SignedEntityTypeMessagePart :: from( (
287
+ SignedEntityType :: CardanoDatabase ( CardanoDbBeacon :: new( 98 , 123 ) ) ,
288
+ "unused"
289
+ ) )
290
+ ) ;
272
291
}
273
292
274
293
#[ test]
@@ -378,5 +397,19 @@ mod tests {
378
397
SignedEntityType :: CardanoTransactions ( epoch, block_number + 3 ) ,
379
398
SignedEntityTypeMessagePart :: CardanoTransactions ( epoch, block_number) ,
380
399
) ;
400
+
401
+ // CardanoDatabase
402
+ assert_commutative_eq (
403
+ SignedEntityType :: CardanoDatabase ( CardanoDbBeacon :: new ( * epoch, immutable) ) ,
404
+ SignedEntityTypeMessagePart :: CardanoDatabase ( CardanoDbBeacon :: new ( * epoch, immutable) ) ,
405
+ ) ;
406
+ assert_commutative_ne (
407
+ SignedEntityType :: CardanoDatabase ( CardanoDbBeacon :: new ( * epoch + 1 , immutable) ) ,
408
+ SignedEntityTypeMessagePart :: CardanoDatabase ( CardanoDbBeacon :: new ( * epoch, immutable) ) ,
409
+ ) ;
410
+ assert_commutative_ne (
411
+ SignedEntityType :: CardanoDatabase ( CardanoDbBeacon :: new ( * epoch, immutable + 3 ) ) ,
412
+ SignedEntityTypeMessagePart :: CardanoDatabase ( CardanoDbBeacon :: new ( * epoch, immutable) ) ,
413
+ ) ;
381
414
}
382
415
}
0 commit comments