@@ -9,6 +9,7 @@ import org.scalatest.matchers.should.Matchers
99import io .iohk .ethereum .Fixtures
1010import io .iohk .ethereum .ObjectGenerators
1111import io .iohk .ethereum .domain .ChainWeight
12+ import io .iohk .ethereum .forkid .ForkId
1213import io .iohk .ethereum .network .p2p .messages .BaseETH6XMessages .SignedTransactions
1314import io .iohk .ethereum .network .p2p .messages .Capability .Capabilities ._
1415import io .iohk .ethereum .network .p2p .messages ._
@@ -60,6 +61,8 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
6061 .fromBytes(Codes .NewBlockHashesCode , NewBlockHashesETH62bytes ) shouldBe newBlockHashesETH62
6162 decode(ProtocolVersions .ETC64 )
6263 .fromBytes(Codes .NewBlockHashesCode , NewBlockHashesETH62bytes ) shouldBe newBlockHashesETH62
64+ decode(ProtocolVersions .ETH64 )
65+ .fromBytes(Codes .NewBlockHashesCode , NewBlockHashesETH62bytes ) shouldBe newBlockHashesETH62
6366 }
6467
6568 it should " not decode message from older version of protocol as newer version" in {
@@ -81,6 +84,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
8184 val getBlockHeadersBytes : Array [Byte ] = getBlockHeaders.toBytes
8285
8386 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .GetBlockHeadersCode , getBlockHeadersBytes) shouldBe getBlockHeaders
87+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .GetBlockHeadersCode , getBlockHeadersBytes) shouldBe getBlockHeaders
8488 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .GetBlockHeadersCode , getBlockHeadersBytes) shouldBe getBlockHeaders
8589 }
8690
@@ -89,6 +93,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
8993 val blockHeadersBytes : Array [Byte ] = blockHeaders.toBytes
9094
9195 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .BlockHeadersCode , blockHeadersBytes) shouldBe blockHeaders
96+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .BlockHeadersCode , blockHeadersBytes) shouldBe blockHeaders
9297 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .BlockHeadersCode , blockHeadersBytes) shouldBe blockHeaders
9398 }
9499
@@ -97,6 +102,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
97102 val getBlockBodiesBytes : Array [Byte ] = getBlockBodies.toBytes
98103
99104 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .GetBlockBodiesCode , getBlockBodiesBytes) shouldBe getBlockBodies
105+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .GetBlockBodiesCode , getBlockBodiesBytes) shouldBe getBlockBodies
100106 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .GetBlockBodiesCode , getBlockBodiesBytes) shouldBe getBlockBodies
101107 }
102108
@@ -105,6 +111,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
105111 val blockBodiesBytes : Array [Byte ] = blockBodies.toBytes
106112
107113 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .BlockBodiesCode , blockBodiesBytes) shouldBe blockBodies
114+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .BlockBodiesCode , blockBodiesBytes) shouldBe blockBodies
108115 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .BlockBodiesCode , blockBodiesBytes) shouldBe blockBodies
109116 }
110117
@@ -113,6 +120,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
113120 val getNodeDataBytes : Array [Byte ] = getNodeData.toBytes
114121
115122 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .GetNodeDataCode , getNodeDataBytes) shouldBe getNodeData
123+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .GetNodeDataCode , getNodeDataBytes) shouldBe getNodeData
116124 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .GetNodeDataCode , getNodeDataBytes) shouldBe getNodeData
117125 }
118126
@@ -121,6 +129,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
121129 val nodeDataBytes : Array [Byte ] = nodeData.toBytes
122130
123131 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .NodeDataCode , nodeDataBytes) shouldBe nodeData
132+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .NodeDataCode , nodeDataBytes) shouldBe nodeData
124133 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .NodeDataCode , nodeDataBytes) shouldBe nodeData
125134 }
126135
@@ -129,6 +138,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
129138 val getReceiptsBytes : Array [Byte ] = getReceipts.toBytes
130139
131140 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .GetReceiptsCode , getReceiptsBytes) shouldBe getReceipts
141+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .GetReceiptsCode , getReceiptsBytes) shouldBe getReceipts
132142 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .GetReceiptsCode , getReceiptsBytes) shouldBe getReceipts
133143 }
134144
@@ -137,17 +147,21 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
137147 val receiptsBytes : Array [Byte ] = receipts.toBytes
138148
139149 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .ReceiptsCode , receiptsBytes) shouldBe receipts
150+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .ReceiptsCode , receiptsBytes) shouldBe receipts
140151 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .ReceiptsCode , receiptsBytes) shouldBe receipts
141152 }
142153
143154 it should " decode Status message for all supported versions of protocol" in {
144155 val status63 = BaseETH6XMessages .Status (ProtocolVersions .ETH63 .version, 1 , BigInt (100 ), exampleHash, exampleHash)
145156 val status63Bytes : Array [Byte ] = status63.toBytes
146- val status64 =
157+ val statusEtc64 =
147158 ETC64 .Status (ProtocolVersions .ETH63 .version, 1 , ChainWeight (1 , BigInt (100 )), exampleHash, exampleHash)
159+ val statusEth64 =
160+ ETH64 .Status (ProtocolVersions .ETH64 .version, 1 , BigInt (100 ), exampleHash, exampleHash, ForkId (1L , None ))
148161
149162 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .StatusCode , status63Bytes) shouldBe status63
150- decode(ProtocolVersions .ETC64 ).fromBytes(Codes .StatusCode , status64.toBytes) shouldBe status64
163+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .StatusCode , statusEth64.toBytes) shouldBe statusEth64
164+ decode(ProtocolVersions .ETC64 ).fromBytes(Codes .StatusCode , statusEtc64.toBytes) shouldBe status64
151165 }
152166
153167 it should " decode NewBlock message for all supported versions of protocol" in {
@@ -156,6 +170,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
156170 val newBlock64 = ObjectGenerators .newBlock64Gen(secureRandom, None ).sample.get
157171
158172 decode(ProtocolVersions .ETH63 ).fromBytes(Codes .NewBlockCode , newBlock63Bytes) shouldBe newBlock63
173+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .NewBlockCode , newBlock63Bytes) shouldBe newBlock63
159174 decode(ProtocolVersions .ETC64 ).fromBytes(Codes .NewBlockCode , newBlock64.toBytes) shouldBe newBlock64
160175 }
161176
@@ -165,6 +180,8 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
165180
166181 decode(ProtocolVersions .ETH63 )
167182 .fromBytes(Codes .SignedTransactionsCode , signedTransactionsBytes) shouldBe signedTransactions
183+ decode(ProtocolVersions .ETH64 )
184+ .fromBytes(Codes .SignedTransactionsCode , signedTransactionsBytes) shouldBe signedTransactions
168185 decode(ProtocolVersions .ETC64 )
169186 .fromBytes(Codes .SignedTransactionsCode , signedTransactionsBytes) shouldBe signedTransactions
170187 }
0 commit comments