Skip to content

Commit d8a3429

Browse files
committed
Fix tests.
1 parent 9fc502a commit d8a3429

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

beacon_node/lighthouse_network/src/discovery/enr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pub use discv5::enr::CombinedKey;
55
use super::enr_ext::CombinedKeyExt;
66
use super::enr_ext::{EnrExt, QUIC6_ENR_KEY, QUIC_ENR_KEY};
77
use super::ENR_FILENAME;
8-
use crate::config::Config;
98
use crate::types::{Enr, EnrAttestationBitfield, EnrSyncCommitteeBitfield};
109
use crate::NetworkConfig;
1110
use alloy_rlp::bytes::Bytes;

beacon_node/lighthouse_network/src/rpc/codec.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ mod tests {
11351135
let mut dst = BytesMut::new();
11361136

11371137
// Add context bytes if required
1138-
dst.extend_from_slice(&fork_context.to_context_bytes(fork_name).unwrap());
1138+
dst.extend_from_slice(&fork_context.context_bytes(fork_context.digest_epoch()));
11391139

11401140
let mut uvi_codec: Uvi<usize> = Uvi::default();
11411141

@@ -1792,8 +1792,8 @@ mod tests {
17921792
.unwrap();
17931793

17941794
let mut wrong_fork_bytes = BytesMut::new();
1795-
wrong_fork_bytes
1796-
.extend_from_slice(&fork_context.to_context_bytes(ForkName::Altair).unwrap());
1795+
let altair_epoch = chain_spec.altair_fork_epoch.unwrap();
1796+
wrong_fork_bytes.extend_from_slice(&fork_context.context_bytes(altair_epoch));
17971797
wrong_fork_bytes.extend_from_slice(&encoded_bytes.split_off(4));
17981798

17991799
assert!(matches!(
@@ -1817,7 +1817,9 @@ mod tests {
18171817
.unwrap();
18181818

18191819
let mut wrong_fork_bytes = BytesMut::new();
1820-
wrong_fork_bytes.extend_from_slice(&fork_context.to_context_bytes(ForkName::Base).unwrap());
1820+
wrong_fork_bytes.extend_from_slice(
1821+
&fork_context.context_bytes(chain_spec.genesis_slot.epoch(Spec::slots_per_epoch())),
1822+
);
18211823
wrong_fork_bytes.extend_from_slice(&encoded_bytes.split_off(4));
18221824

18231825
assert!(matches!(
@@ -1833,7 +1835,7 @@ mod tests {
18331835

18341836
// Adding context bytes to Protocols that don't require it should return an error
18351837
let mut encoded_bytes = BytesMut::new();
1836-
encoded_bytes.extend_from_slice(&fork_context.to_context_bytes(ForkName::Altair).unwrap());
1838+
encoded_bytes.extend_from_slice(&fork_context.context_bytes(altair_epoch));
18371839
encoded_bytes.extend_from_slice(
18381840
&encode_response(
18391841
SupportedProtocol::MetaDataV2,
@@ -2034,7 +2036,8 @@ mod tests {
20342036
let mut dst = BytesMut::with_capacity(1024);
20352037

20362038
// Insert context bytes
2037-
dst.extend_from_slice(&fork_context.to_context_bytes(ForkName::Altair).unwrap());
2039+
let altair_epoch = fork_context.spec.altair_fork_epoch.unwrap();
2040+
dst.extend_from_slice(&fork_context.context_bytes(altair_epoch));
20382041

20392042
// Insert length-prefix
20402043
uvi_codec

beacon_node/network/src/service/tests.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use lighthouse_network::{Enr, GossipTopic};
1111
use std::str::FromStr;
1212
use std::sync::Arc;
1313
use tokio::runtime::Runtime;
14-
use types::{Epoch, EthSpec, ForkName, MinimalEthSpec, SubnetId};
14+
use types::{Epoch, EthSpec, MinimalEthSpec, SubnetId};
1515

1616
impl<T: BeaconChainTypes> NetworkService<T> {
1717
fn get_topic_params(&self, topic: GossipTopic) -> Option<&gossipsub::TopicScoreParams> {
@@ -106,8 +106,8 @@ fn test_removing_topic_weight_on_old_topics() {
106106
.mock_execution_layer()
107107
.build()
108108
.chain;
109-
let (next_fork_name, _) = beacon_chain.duration_to_next_fork().expect("next fork");
110-
assert_eq!(next_fork_name, ForkName::Capella);
109+
let (next_fork_epoch, _) = beacon_chain.duration_to_next_digest().expect("next fork");
110+
assert_eq!(Some(next_fork_epoch), spec.capella_fork_epoch);
111111

112112
// Build network service.
113113
let (mut network_service, network_globals, _network_senders) = runtime.block_on(async {
@@ -189,9 +189,8 @@ fn test_removing_topic_weight_on_old_topics() {
189189
beacon_chain.slot_clock.advance_slot();
190190
}
191191

192-
// Run `NetworkService::update_next_fork()`.
193192
runtime.block_on(async {
194-
network_service.update_next_fork();
193+
network_service.update_next_fork_digest();
195194
});
196195

197196
// Check that topic_weight on the old topics has been zeroed.

consensus/types/src/enr_fork_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::test_utils::TestRandom;
2-
use crate::{ChainSpec, Epoch};
2+
use crate::Epoch;
33

44
use serde::{Deserialize, Serialize};
55
use ssz_derive::{Decode, Encode};

0 commit comments

Comments
 (0)