@@ -21,6 +21,13 @@ pub struct RegisterSignatureMessage {
21
21
/// The indexes of the won lotteries that lead to the single signatures
22
22
#[ serde( rename = "indexes" ) ]
23
23
pub won_indexes : Vec < LotteryIndex > ,
24
+
25
+ /// Message that is signed by the signer
26
+ ///
27
+ /// Used to buffer the signature for later if the aggregator has yet to create an open message
28
+ /// for the signed entity type.
29
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
30
+ pub signed_message : Option < String > ,
24
31
}
25
32
26
33
impl RegisterSignatureMessage {
@@ -32,6 +39,7 @@ impl RegisterSignatureMessage {
32
39
party_id: "party_id" . to_string( ) ,
33
40
signature: fake_keys:: single_signature( ) [ 0 ] . to_string( ) ,
34
41
won_indexes: vec![ 1 , 3 ] ,
42
+ signed_message: None ,
35
43
}
36
44
}
37
45
}
@@ -62,28 +70,58 @@ mod tests {
62
70
63
71
use super :: * ;
64
72
65
- fn golden_message ( ) -> RegisterSignatureMessage {
73
+ #[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
74
+ pub struct RegisterSignatureMessagePrevious {
75
+ #[ serde( rename = "entity_type" ) ]
76
+ pub signed_entity_type : SignedEntityType ,
77
+ pub party_id : PartyId ,
78
+ pub signature : HexEncodedSingleSignature ,
79
+ #[ serde( rename = "indexes" ) ]
80
+ pub won_indexes : Vec < LotteryIndex > ,
81
+ }
82
+
83
+ fn golden_message_previous ( ) -> RegisterSignatureMessagePrevious {
84
+ RegisterSignatureMessagePrevious {
85
+ signed_entity_type : SignedEntityType :: MithrilStakeDistribution ( Epoch ( 246 ) ) ,
86
+ party_id : "party_id" . to_string ( ) ,
87
+ signature : "7b227369676d61223a5b3133302c3137372c31352c3232392c32342c3235312c3234372c3137312c3139362c3231302c3134332c3131332c38362c3138392c39322c35362c3131322c33332c3139332c3231322c35342c3231342c32382c3231362c3232372c3137332c3130302c3132372c3137382c34302c39382c38372c32392c3138312c3235352c3131312c3135372c3232342c3233352c34362c3130302c3136392c3233322c3138392c3235322c38322c3133392c33365d2c22696e6465786573223a5b302c312c332c342c362c382c392c31302c31312c31322c31342c31382c32312c32322c32332c32352c32362c32372c33302c33332c33342c33382c34312c34332c35302c35382c35392c36302c36312c36322c36372c36392c37312c37332c37352c37362c37372c38312c38322c38332c38342c39302c39312c39322c39332c39372c39385d2c227369676e65725f696e646578223a327d" . to_string ( ) ,
88
+ won_indexes : vec ! [ 1 , 3 ] ,
89
+ }
90
+ }
91
+
92
+ fn golden_message_actual ( ) -> RegisterSignatureMessage {
66
93
RegisterSignatureMessage {
67
94
signed_entity_type : SignedEntityType :: MithrilStakeDistribution ( Epoch ( 246 ) ) ,
68
95
party_id : "party_id" . to_string ( ) ,
69
96
signature : "7b227369676d61223a5b3133302c3137372c31352c3232392c32342c3235312c3234372c3137312c3139362c3231302c3134332c3131332c38362c3138392c39322c35362c3131322c33332c3139332c3231322c35342c3231342c32382c3231362c3232372c3137332c3130302c3132372c3137382c34302c39382c38372c32392c3138312c3235352c3131312c3135372c3232342c3233352c34362c3130302c3136392c3233322c3138392c3235322c38322c3133392c33365d2c22696e6465786573223a5b302c312c332c342c362c382c392c31302c31312c31322c31342c31382c32312c32322c32332c32352c32362c32372c33302c33332c33342c33382c34312c34332c35302c35382c35392c36302c36312c36322c36372c36392c37312c37332c37352c37362c37372c38312c38322c38332c38342c39302c39312c39322c39332c39372c39385d2c227369676e65725f696e646578223a327d" . to_string ( ) ,
70
97
won_indexes : vec ! [ 1 , 3 ] ,
98
+ signed_message : Some ( "6a7e737c312972d2346b65ac3075696e04286d046dddaf8004121e3d5e27cc0d" . to_string ( ) ) ,
71
99
}
72
100
}
73
101
74
- // Test the retro compatibility with possible future upgrades.
102
+ const ACTUAL_JSON : & str = r#"{
103
+ "entity_type": { "MithrilStakeDistribution": 246 },
104
+ "party_id": "party_id",
105
+ "signature": "7b227369676d61223a5b3133302c3137372c31352c3232392c32342c3235312c3234372c3137312c3139362c3231302c3134332c3131332c38362c3138392c39322c35362c3131322c33332c3139332c3231322c35342c3231342c32382c3231362c3232372c3137332c3130302c3132372c3137382c34302c39382c38372c32392c3138312c3235352c3131312c3135372c3232342c3233352c34362c3130302c3136392c3233322c3138392c3235322c38322c3133392c33365d2c22696e6465786573223a5b302c312c332c342c362c382c392c31302c31312c31322c31342c31382c32312c32322c32332c32352c32362c32372c33302c33332c33342c33382c34312c34332c35302c35382c35392c36302c36312c36322c36372c36392c37312c37332c37352c37362c37372c38312c38322c38332c38342c39302c39312c39322c39332c39372c39385d2c227369676e65725f696e646578223a327d",
106
+ "indexes": [1, 3],
107
+ "signed_message": "6a7e737c312972d2346b65ac3075696e04286d046dddaf8004121e3d5e27cc0d"
108
+ }"# ;
109
+
110
+ #[ test]
111
+ fn test_actual_json_deserialized_into_previous_message ( ) {
112
+ let json = ACTUAL_JSON ;
113
+ let message: RegisterSignatureMessagePrevious = serde_json:: from_str ( json) . unwrap ( ) ;
114
+
115
+ assert_eq ! ( golden_message_previous( ) , message) ;
116
+ }
117
+
75
118
#[ test]
76
- fn test_v1 ( ) {
77
- let json = r#"{
78
- "entity_type": { "MithrilStakeDistribution": 246 },
79
- "party_id": "party_id",
80
- "signature": "7b227369676d61223a5b3133302c3137372c31352c3232392c32342c3235312c3234372c3137312c3139362c3231302c3134332c3131332c38362c3138392c39322c35362c3131322c33332c3139332c3231322c35342c3231342c32382c3231362c3232372c3137332c3130302c3132372c3137382c34302c39382c38372c32392c3138312c3235352c3131312c3135372c3232342c3233352c34362c3130302c3136392c3233322c3138392c3235322c38322c3133392c33365d2c22696e6465786573223a5b302c312c332c342c362c382c392c31302c31312c31322c31342c31382c32312c32322c32332c32352c32362c32372c33302c33332c33342c33382c34312c34332c35302c35382c35392c36302c36312c36322c36372c36392c37312c37332c37352c37362c37372c38312c38322c38332c38342c39302c39312c39322c39332c39372c39385d2c227369676e65725f696e646578223a327d",
81
- "indexes": [1, 3]
82
- }"# ;
119
+ fn test_actual_json_deserialized_into_actual_message ( ) {
120
+ let json = ACTUAL_JSON ;
83
121
let message: RegisterSignatureMessage = serde_json:: from_str ( json) . expect (
84
122
"This JSON is expected to be successfully parsed into a RegisterSignatureMessage instance." ,
85
123
) ;
86
124
87
- assert_eq ! ( golden_message ( ) , message) ;
125
+ assert_eq ! ( golden_message_actual ( ) , message) ;
88
126
}
89
127
}
0 commit comments