Skip to content

Commit d5b8552

Browse files
committed
test: adapt open_message_expiration integration test
It was not verifying `is_expired` condition in `get_current_non_certified_open_message`
1 parent a05ced9 commit d5b8552

File tree

1 file changed

+14
-54
lines changed

1 file changed

+14
-54
lines changed

mithril-aggregator/tests/open_message_expiration.rs

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::time::Duration;
55
use mithril_aggregator::Configuration;
66
use mithril_common::{
77
entities::{
8-
CardanoDbBeacon, Epoch, ProtocolParameters, SignedEntityType,
9-
SignedEntityTypeDiscriminants, StakeDistributionParty, TimePoint,
8+
CardanoDbBeacon, ProtocolParameters, SignedEntityType, SignedEntityTypeDiscriminants,
9+
TimePoint,
1010
},
1111
test_utils::MithrilFixtureBuilder,
1212
};
@@ -59,75 +59,35 @@ async fn open_message_expiration() {
5959
.unwrap();
6060
cycle_err!(tester, "signing");
6161

62-
comment!("signers send their single signature");
63-
tester
64-
.send_single_signatures(
65-
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
66-
&fixture.signers_fixture(),
67-
)
68-
.await
69-
.unwrap();
70-
71-
comment!("The state machine should issue a certificate for the MithrilStakeDistribution");
72-
cycle!(tester, "ready");
73-
assert_last_certificate_eq!(
74-
tester,
75-
ExpectedCertificate::new(
76-
CardanoDbBeacon::new("devnet".to_string(), 1, 2),
77-
StakeDistributionParty::from_signers(fixture.signers_with_stake()).as_slice(),
78-
fixture.compute_and_encode_avk(),
79-
SignedEntityType::MithrilStakeDistribution(Epoch(1)),
80-
ExpectedCertificate::genesis_identifier(&CardanoDbBeacon::new(
81-
"devnet".to_string(),
82-
1,
83-
1
84-
)),
85-
)
86-
);
87-
88-
comment!("The state machine should get back to signing to sign CardanoImmutableFilesFull");
89-
// todo!: remove this immutable increase:
90-
// right now because we only have one state machine for all signed entity type we need it else
91-
// the state machine will stay in the idle state since its beacon didn't change.
92-
// With one state machine per signed entity type this problem will disappear.
93-
tester.increase_immutable_number().await.unwrap();
94-
cycle!(tester, "signing");
95-
9662
comment!(
97-
"Schedule the open message for CardanoImmutableFilesFull to expire, and wait until it does"
63+
"Schedule the open message for MithrilStakeDistribution to expire, and wait until it does"
9864
);
9965
let open_message_timeout = Duration::from_millis(100);
10066
tester
10167
.activate_open_message_expiration(
102-
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
68+
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
10369
open_message_timeout,
10470
)
10571
.await
10672
.unwrap();
10773
tokio::time::sleep(2 * open_message_timeout).await;
108-
let signers_for_immutables = &fixture.signers_fixture()[0..=6];
74+
75+
comment!("signers send their single signature");
10976
tester
11077
.send_single_signatures(
111-
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
112-
signers_for_immutables,
78+
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
79+
&fixture.signers_fixture(),
11380
)
11481
.await
11582
.unwrap();
11683

117-
comment!("The state machine should not issue a certificate for the CardanoImmutableFilesFull");
84+
comment!("The state machine should not issue a certificate for the MithrilStakeDistribution");
11885
cycle!(tester, "ready");
11986
assert_last_certificate_eq!(
12087
tester,
121-
ExpectedCertificate::new(
122-
CardanoDbBeacon::new("devnet".to_string(), 1, 2),
123-
StakeDistributionParty::from_signers(fixture.signers_with_stake()).as_slice(),
124-
fixture.compute_and_encode_avk(),
125-
SignedEntityType::MithrilStakeDistribution(Epoch(1)),
126-
ExpectedCertificate::genesis_identifier(&CardanoDbBeacon::new(
127-
"devnet".to_string(),
128-
1,
129-
1
130-
)),
88+
ExpectedCertificate::new_genesis(
89+
CardanoDbBeacon::new("devnet".to_string(), 1, 1),
90+
fixture.compute_and_encode_avk()
13191
)
13292
);
13393

@@ -150,7 +110,7 @@ async fn open_message_expiration() {
150110
assert_last_certificate_eq!(
151111
tester,
152112
ExpectedCertificate::new(
153-
CardanoDbBeacon::new("devnet".to_string(), 1, 4),
113+
CardanoDbBeacon::new("devnet".to_string(), 1, 3),
154114
&signers_for_immutables
155115
.iter()
156116
.map(|s| s.signer_with_stake.clone().into())
@@ -159,7 +119,7 @@ async fn open_message_expiration() {
159119
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
160120
"devnet".to_string(),
161121
1,
162-
4
122+
3
163123
)),
164124
ExpectedCertificate::genesis_identifier(&CardanoDbBeacon::new(
165125
"devnet".to_string(),

0 commit comments

Comments
 (0)