Skip to content

Commit 8cdabb4

Browse files
authored
Remove test-only WorkerState.with_key_pair. (#4401)
## Motivation This test-only method risks dropping the handles of ongoing tasks with loaded chain state views, and then loading those chains again. It's only used in one test, where we assert that the worker updates its locking block based on a validated block certificate even if it did not sign to confirm that block. Since this feature mainly matters on the client side, and we wanted to make sure it can't sign to confirm, we removed the worker's keys. However, the worker wouldn't sign it anyway, since it is not in the current round. ## Proposal Remove the method; assert instead that the worker didn't sign to confirm. ## Test Plan Only test code was changed. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent f2ac478 commit 8cdabb4

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

linera-core/src/unit_tests/worker_tests.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use linera_chain::{
3333
manager::LockingBlock,
3434
test::{make_child_block, make_first_block, BlockTestExt, MessageTestExt, VoteTestExt},
3535
types::{
36-
CertificateValue, ConfirmedBlock, ConfirmedBlockCertificate, GenericCertificate, Timeout,
37-
ValidatedBlock,
36+
CertificateKind, CertificateValue, ConfirmedBlock, ConfirmedBlockCertificate,
37+
GenericCertificate, Timeout, ValidatedBlock,
3838
},
3939
ChainError, ChainExecutionContext,
4040
};
@@ -3505,9 +3505,10 @@ where
35053505
.await?;
35063506
assert_eq!(response.info.manager.current_round, Round::SingleLeader(8));
35073507

3508-
// The worker updates its locking block even if it's from a past round.
3508+
// The worker updates its locking block even if it's from a past round and it doesn't sign
3509+
// to confirm.
35093510
let certificate = env.make_certificate_with_round(value1, Round::SingleLeader(7));
3510-
let worker = env.worker().clone().with_key_pair(None).await; // Forget validator keys.
3511+
let worker = env.worker().clone();
35113512
worker
35123513
.handle_validated_certificate(certificate.clone())
35133514
.await?;
@@ -3516,6 +3517,10 @@ where
35163517
response.info.manager.requested_locking,
35173518
Some(Box::new(LockingBlock::Regular(certificate)))
35183519
);
3520+
assert_ne!(
3521+
response.info.manager.pending.unwrap().kind(),
3522+
CertificateKind::Confirmed
3523+
);
35193524
Ok(())
35203525
}
35213526

linera-core/src/worker.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,6 @@ where
427427
&self.storage
428428
}
429429

430-
#[instrument(level = "trace", skip(self, key_pair))]
431-
#[cfg(test)]
432-
pub(crate) async fn with_key_pair(mut self, key_pair: Option<Arc<ValidatorSecretKey>>) -> Self {
433-
self.chain_worker_config.key_pair = key_pair;
434-
self.chain_workers.lock().unwrap().clear();
435-
self
436-
}
437-
438430
#[instrument(level = "trace", skip(self, certificate))]
439431
pub(crate) async fn full_certificate(
440432
&self,

0 commit comments

Comments
 (0)