@@ -66,45 +66,50 @@ mod tests {
66
66
67
67
#[ tokio:: test]
68
68
async fn should_compute_valid_artifact_with_merkleroot ( ) {
69
- let certificate = {
70
- let mut certificate = fake_data:: certificate ( "certificate-123" . to_string ( ) ) ;
71
- let mut message = ProtocolMessage :: new ( ) ;
72
- message. set_message_part (
69
+ let mut mock_prover = MockProverService :: new ( ) ;
70
+ mock_prover. expect_compute_cache ( ) . returning ( |_| Ok ( ( ) ) ) ;
71
+ let cardano_transaction_artifact_builder =
72
+ CardanoTransactionsArtifactBuilder :: new ( Arc :: new ( mock_prover) ) ;
73
+
74
+ let certificate_with_merkle_root = {
75
+ let mut protocol_message = ProtocolMessage :: new ( ) ;
76
+ protocol_message. set_message_part (
73
77
ProtocolMessagePartKey :: CardanoTransactionsMerkleRoot ,
74
78
"merkleroot" . to_string ( ) ,
75
79
) ;
76
- certificate. protocol_message = message;
77
- certificate
80
+ Certificate {
81
+ protocol_message,
82
+ ..fake_data:: certificate ( "certificate-123" . to_string ( ) )
83
+ }
78
84
} ;
79
-
80
85
let beacon = 100 ;
81
- let mut mock_prover = MockProverService :: new ( ) ;
82
- mock_prover. expect_compute_cache ( ) . returning ( |_| Ok ( ( ) ) ) ;
83
- let cardano_transaction_artifact_builder =
84
- CardanoTransactionsArtifactBuilder :: new ( Arc :: new ( mock_prover) ) ;
86
+
85
87
let artifact = cardano_transaction_artifact_builder
86
- . compute_artifact ( beacon, & certificate )
88
+ . compute_artifact ( beacon, & certificate_with_merkle_root )
87
89
. await
88
90
. unwrap ( ) ;
89
- let artifact_expected = CardanoTransactionsSnapshot :: new ( "merkleroot" . to_string ( ) , beacon) ;
90
- assert_eq ! ( artifact_expected, artifact) ;
91
+
92
+ assert_eq ! (
93
+ CardanoTransactionsSnapshot :: new( "merkleroot" . to_string( ) , beacon) ,
94
+ artifact
95
+ ) ;
91
96
}
92
97
93
98
#[ tokio:: test]
94
99
async fn should_fail_to_compute_artifact_without_merkle_root ( ) {
95
- let certificate = {
96
- let mut certificate = fake_data:: certificate ( "certificate-123" . to_string ( ) ) ;
97
- let message = ProtocolMessage :: new ( ) ;
98
- certificate. protocol_message = message;
99
- certificate
100
- } ;
101
-
102
100
let mut mock_prover = MockProverService :: new ( ) ;
103
101
mock_prover. expect_compute_cache ( ) . returning ( |_| Ok ( ( ) ) ) ;
104
102
let cardano_transaction_artifact_builder =
105
103
CardanoTransactionsArtifactBuilder :: new ( Arc :: new ( mock_prover) ) ;
104
+
105
+ let certificate_without_merkle_root = Certificate {
106
+ protocol_message : ProtocolMessage :: new ( ) ,
107
+ ..fake_data:: certificate ( "certificate-123" . to_string ( ) )
108
+ } ;
109
+ let beacon = 100 ;
110
+
106
111
cardano_transaction_artifact_builder
107
- . compute_artifact ( 12390 , & certificate )
112
+ . compute_artifact ( beacon , & certificate_without_merkle_root )
108
113
. await
109
114
. expect_err ( "The artifact building must fail since there is no CardanoTransactionsMerkleRoot part in its message." ) ;
110
115
}
0 commit comments