From d209d157ce72f9fd0563220288d16da04848957d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Moraczy=C5=84ski?= Date: Tue, 26 Oct 2021 16:22:28 +0200 Subject: [PATCH] fix ProtocolValidator for ETH66 (#3549) --- .../ProtocolsManagerTests.cs | 25 ++++++++++++++++--- .../Nethermind.Network/ProtocolValidator.cs | 3 ++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Nethermind/Nethermind.Network.Test/ProtocolsManagerTests.cs b/src/Nethermind/Nethermind.Network.Test/ProtocolsManagerTests.cs index 232f61a50d2..d98c6e4b565 100644 --- a/src/Nethermind/Nethermind.Network.Test/ProtocolsManagerTests.cs +++ b/src/Nethermind/Nethermind.Network.Test/ProtocolsManagerTests.cs @@ -260,10 +260,10 @@ public Context ReceiveHelloNoEth() return this; } - public Context ReceiveHelloWrongEth() + public Context ReceiveHelloEth(int protocolVersion) { HelloMessage msg = new HelloMessage(); - msg.Capabilities = new List {new Capability("eth", 61)}; + msg.Capabilities = new List {new Capability("eth", protocolVersion)}; msg.NodeId = TestItem.PublicKeyB; msg.ClientId = "other client v1"; msg.P2PVersion = 5; @@ -272,6 +272,12 @@ public Context ReceiveHelloWrongEth() return this; } + + public Context ReceiveHelloWrongEth() + { + return ReceiveHelloEth(61); + } + public Context ReceiveStatusWrongChain() { StatusMessage msg = new StatusMessage(); @@ -450,7 +456,7 @@ public void Disconnects_on_wrong_eth() .ReceiveHelloWrongEth() .VerifyDisconnected(); } - + [Test] public void Disconnects_on_wrong_chain_id() { @@ -478,5 +484,18 @@ public void Disconnects_on_wrong_genesis_hash() .ReceiveStatusWrongGenesis() .VerifyDisconnected(); } + + [Test] + public void Initialized_with_eth66_only() + { + When + .CreateIncomingSession() + .ActivateChannel() + .Handshake() + .Init() + .VerifyInitialized() + .ReceiveHelloEth(66) + .VerifyInitialized(); + } } } diff --git a/src/Nethermind/Nethermind.Network/ProtocolValidator.cs b/src/Nethermind/Nethermind.Network/ProtocolValidator.cs index 6d0e1f40e2a..2453f3d6ade 100644 --- a/src/Nethermind/Nethermind.Network/ProtocolValidator.cs +++ b/src/Nethermind/Nethermind.Network/ProtocolValidator.cs @@ -112,7 +112,8 @@ private bool ValidateCapabilities(IEnumerable capabilities) x.Version == 62 || x.Version == 63 || x.Version == 64 || - x.Version == 65)); + x.Version == 65 || + x.Version == 66)); } private bool ValidateChainId(ulong chainId)