@@ -2,7 +2,7 @@ use std::collections::BTreeSet;
2
2
3
3
use serde:: { Deserialize , Serialize } ;
4
4
5
- use crate :: entities:: SignedEntityTypeDiscriminants ;
5
+ use crate :: entities:: { CardanoTransactionsSigningConfig , SignedEntityTypeDiscriminants } ;
6
6
7
7
/// Message advertised by an Aggregator to inform about its features
8
8
#[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
@@ -28,6 +28,7 @@ impl AggregatorFeaturesMessage {
28
28
SignedEntityTypeDiscriminants :: MithrilStakeDistribution ,
29
29
] ) ,
30
30
cardano_transactions_prover : None ,
31
+ cardano_transactions_signing_config : None ,
31
32
} ,
32
33
}
33
34
}
@@ -42,6 +43,10 @@ pub struct AggregatorCapabilities {
42
43
/// Cardano transactions prover capabilities
43
44
#[ serde( skip_serializing_if = "Option::is_none" ) ]
44
45
pub cardano_transactions_prover : Option < CardanoTransactionsProverCapabilities > ,
46
+
47
+ /// Cardano transactions signing configuration
48
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
49
+ pub cardano_transactions_signing_config : Option < CardanoTransactionsSigningConfig > ,
45
50
}
46
51
47
52
/// Cardano transactions prover capabilities
@@ -53,9 +58,40 @@ pub struct CardanoTransactionsProverCapabilities {
53
58
54
59
#[ cfg( test) ]
55
60
mod tests {
61
+ use crate :: entities:: BlockNumber ;
62
+
56
63
use super :: * ;
57
64
58
- fn golden_message ( ) -> AggregatorFeaturesMessage {
65
+ #[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
66
+ struct AggregatorFeaturesMessagePrevious {
67
+ pub open_api_version : String ,
68
+ pub documentation_url : String ,
69
+ pub capabilities : AggregatorCapabilitiesPrevious ,
70
+ }
71
+
72
+ #[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
73
+ struct AggregatorCapabilitiesPrevious {
74
+ pub signed_entity_types : BTreeSet < SignedEntityTypeDiscriminants > ,
75
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
76
+ pub cardano_transactions_prover : Option < CardanoTransactionsProverCapabilities > ,
77
+ }
78
+
79
+ fn golden_message_v1 ( ) -> AggregatorFeaturesMessagePrevious {
80
+ AggregatorFeaturesMessagePrevious {
81
+ open_api_version : "0.0.1" . to_string ( ) ,
82
+ documentation_url : "https://example.com" . to_string ( ) ,
83
+ capabilities : AggregatorCapabilitiesPrevious {
84
+ signed_entity_types : BTreeSet :: from ( [
85
+ SignedEntityTypeDiscriminants :: CardanoTransactions ,
86
+ ] ) ,
87
+ cardano_transactions_prover : Some ( CardanoTransactionsProverCapabilities {
88
+ max_hashes_allowed_by_request : 100 ,
89
+ } ) ,
90
+ } ,
91
+ }
92
+ }
93
+
94
+ fn golden_message_v2 ( ) -> AggregatorFeaturesMessage {
59
95
AggregatorFeaturesMessage {
60
96
open_api_version : "0.0.1" . to_string ( ) ,
61
97
documentation_url : "https://example.com" . to_string ( ) ,
@@ -66,6 +102,10 @@ mod tests {
66
102
cardano_transactions_prover : Some ( CardanoTransactionsProverCapabilities {
67
103
max_hashes_allowed_by_request : 100 ,
68
104
} ) ,
105
+ cardano_transactions_signing_config : Some ( CardanoTransactionsSigningConfig {
106
+ security_parameter : BlockNumber ( 70 ) ,
107
+ step : BlockNumber ( 20 ) ,
108
+ } ) ,
69
109
} ,
70
110
}
71
111
}
@@ -84,8 +124,30 @@ mod tests {
84
124
}
85
125
}"# ;
86
126
127
+ let message: AggregatorFeaturesMessagePrevious = serde_json:: from_str ( json) . unwrap ( ) ;
128
+
129
+ assert_eq ! ( golden_message_v1( ) , message) ;
130
+ }
131
+
132
+ #[ test]
133
+ fn test_v2 ( ) {
134
+ let json = r#"{
135
+ "open_api_version": "0.0.1",
136
+ "documentation_url": "https://example.com",
137
+ "capabilities": {
138
+ "signed_entity_types": ["CardanoTransactions"],
139
+ "cardano_transactions_prover": {
140
+ "max_hashes_allowed_by_request": 100
141
+ },
142
+ "cardano_transactions_signing_config": {
143
+ "security_parameter": 70,
144
+ "step": 20
145
+ }
146
+ }
147
+ }"# ;
148
+
87
149
let message: AggregatorFeaturesMessage = serde_json:: from_str ( json) . unwrap ( ) ;
88
150
89
- assert_eq ! ( golden_message ( ) , message) ;
151
+ assert_eq ! ( golden_message_v2 ( ) , message) ;
90
152
}
91
153
}
0 commit comments