Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ProtocolValidator for ETH66 #3549

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/Nethermind/Nethermind.Network.Test/ProtocolsManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Capability> {new Capability("eth", 61)};
msg.Capabilities = new List<Capability> {new Capability("eth", protocolVersion)};
msg.NodeId = TestItem.PublicKeyB;
msg.ClientId = "other client v1";
msg.P2PVersion = 5;
Expand All @@ -272,6 +272,12 @@ public Context ReceiveHelloWrongEth()
return this;
}


public Context ReceiveHelloWrongEth()
{
return ReceiveHelloEth(61);
}

public Context ReceiveStatusWrongChain()
{
StatusMessage msg = new StatusMessage();
Expand Down Expand Up @@ -450,7 +456,7 @@ public void Disconnects_on_wrong_eth()
.ReceiveHelloWrongEth()
.VerifyDisconnected();
}

[Test]
public void Disconnects_on_wrong_chain_id()
{
Expand Down Expand Up @@ -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();
}
}
}
3 changes: 2 additions & 1 deletion src/Nethermind/Nethermind.Network/ProtocolValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ private bool ValidateCapabilities(IEnumerable<Capability> capabilities)
x.Version == 62 ||
x.Version == 63 ||
x.Version == 64 ||
x.Version == 65));
x.Version == 65 ||
x.Version == 66));
}

private bool ValidateChainId(ulong chainId)
Expand Down