fix(net): correct EthMessageID::max for eth70 and later versions (#22076)

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Georgios Konstantopoulos
2026-02-12 10:53:11 -05:00
committed by GitHub
parent 0b8e6c6ed3
commit 4f5fafc8f3

View File

@@ -589,7 +589,7 @@ impl EthMessageID {
/// Returns the max value for the given version.
pub const fn max(version: EthVersion) -> u8 {
if version.is_eth69() {
if version as u8 >= EthVersion::Eth69 as u8 {
Self::BlockRangeUpdate.to_u8()
} else {
Self::Receipts.to_u8()
@@ -937,6 +937,13 @@ mod tests {
assert!(matches!(decoded, StatusMessage::Legacy(s) if s == status));
}
#[test]
fn eth_message_id_max_includes_block_range_update() {
assert_eq!(EthMessageID::max(EthVersion::Eth69), EthMessageID::BlockRangeUpdate.to_u8(),);
assert_eq!(EthMessageID::max(EthVersion::Eth70), EthMessageID::BlockRangeUpdate.to_u8(),);
assert_eq!(EthMessageID::max(EthVersion::Eth68), EthMessageID::Receipts.to_u8());
}
#[test]
fn decode_status_rejects_non_status() {
let msg = EthMessage::<EthNetworkPrimitives>::GetBlockBodies(RequestPair {