Skip to content

Commit

Permalink
fix ProtocolValidator for ETH66 (#3549)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekM25 authored Oct 26, 2021
1 parent 416bc9a commit d209d15
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
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

0 comments on commit d209d15

Please sign in to comment.