@@ -9,8 +9,8 @@ use std::{
9
9
use crate :: {
10
10
certificate_chain:: CertificateGenesisProducer ,
11
11
crypto_helper:: {
12
- ProtocolAggregateVerificationKey , ProtocolGenesisSigner , ProtocolInitializer ,
13
- ProtocolOpCert , ProtocolSigner , ProtocolSignerVerificationKey ,
12
+ ProtocolAggregateVerificationKey , ProtocolClosedKeyRegistration , ProtocolGenesisSigner ,
13
+ ProtocolInitializer , ProtocolOpCert , ProtocolSigner , ProtocolSignerVerificationKey ,
14
14
ProtocolSignerVerificationKeySignature , ProtocolStakeDistribution ,
15
15
} ,
16
16
entities:: {
@@ -19,6 +19,7 @@ use crate::{
19
19
StakeDistributionParty ,
20
20
} ,
21
21
protocol:: { SignerBuilder , ToMessage } ,
22
+ StdResult ,
22
23
} ;
23
24
24
25
/// A fixture of Mithril data types.
@@ -40,10 +41,30 @@ pub struct SignerFixture {
40
41
pub protocol_signer : ProtocolSigner ,
41
42
/// A [ProtocolSigner].
42
43
pub protocol_initializer : ProtocolInitializer ,
44
+ /// A [ProtocolClosedKeyRegistration].
45
+ pub protocol_closed_key_registration : ProtocolClosedKeyRegistration ,
43
46
/// The path to this signer kes secret key file
44
47
pub kes_secret_key_path : Option < PathBuf > ,
45
48
}
46
49
50
+ impl SignerFixture {
51
+ /// Create a new SignerFixture with specific protocol parameters.
52
+ /// This is useful to simulate some adversarial behaviors.
53
+ pub fn try_new_with_protocol_parameters (
54
+ self ,
55
+ protocol_parameters : ProtocolParameters ,
56
+ ) -> StdResult < Self > {
57
+ let mut protocol_initializer = self . protocol_initializer . clone ( ) ;
58
+ protocol_initializer. override_protocol_parameters ( & protocol_parameters. into ( ) ) ;
59
+ let protocol_signer =
60
+ protocol_initializer. new_signer ( self . protocol_closed_key_registration . clone ( ) ) ?;
61
+ Ok ( Self {
62
+ protocol_signer,
63
+ ..self
64
+ } )
65
+ }
66
+ }
67
+
47
68
impl From < SignerFixture > for SignerWithStake {
48
69
fn from ( fixture : SignerFixture ) -> Self {
49
70
fixture. signer_with_stake
0 commit comments