@@ -9,6 +9,7 @@ import org.scalatest.matchers.should.Matchers
9
9
import io .iohk .ethereum .Fixtures
10
10
import io .iohk .ethereum .ObjectGenerators
11
11
import io .iohk .ethereum .domain .ChainWeight
12
+ import io .iohk .ethereum .forkid .ForkId
12
13
import io .iohk .ethereum .network .p2p .messages .BaseETH6XMessages .SignedTransactions
13
14
import io .iohk .ethereum .network .p2p .messages .Capability .Capabilities ._
14
15
import io .iohk .ethereum .network .p2p .messages ._
@@ -60,6 +61,8 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
60
61
.fromBytes(Codes .NewBlockHashesCode , NewBlockHashesETH62bytes ) shouldBe newBlockHashesETH62
61
62
decode(ProtocolVersions .ETC64 )
62
63
.fromBytes(Codes .NewBlockHashesCode , NewBlockHashesETH62bytes ) shouldBe newBlockHashesETH62
64
+ decode(ProtocolVersions .ETH64 )
65
+ .fromBytes(Codes .NewBlockHashesCode , NewBlockHashesETH62bytes ) shouldBe newBlockHashesETH62
63
66
}
64
67
65
68
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
81
84
val getBlockHeadersBytes : Array [Byte ] = getBlockHeaders.toBytes
82
85
83
86
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .GetBlockHeadersCode , getBlockHeadersBytes) shouldBe getBlockHeaders
87
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .GetBlockHeadersCode , getBlockHeadersBytes) shouldBe getBlockHeaders
84
88
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .GetBlockHeadersCode , getBlockHeadersBytes) shouldBe getBlockHeaders
85
89
}
86
90
@@ -89,6 +93,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
89
93
val blockHeadersBytes : Array [Byte ] = blockHeaders.toBytes
90
94
91
95
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .BlockHeadersCode , blockHeadersBytes) shouldBe blockHeaders
96
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .BlockHeadersCode , blockHeadersBytes) shouldBe blockHeaders
92
97
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .BlockHeadersCode , blockHeadersBytes) shouldBe blockHeaders
93
98
}
94
99
@@ -97,6 +102,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
97
102
val getBlockBodiesBytes : Array [Byte ] = getBlockBodies.toBytes
98
103
99
104
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .GetBlockBodiesCode , getBlockBodiesBytes) shouldBe getBlockBodies
105
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .GetBlockBodiesCode , getBlockBodiesBytes) shouldBe getBlockBodies
100
106
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .GetBlockBodiesCode , getBlockBodiesBytes) shouldBe getBlockBodies
101
107
}
102
108
@@ -105,6 +111,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
105
111
val blockBodiesBytes : Array [Byte ] = blockBodies.toBytes
106
112
107
113
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .BlockBodiesCode , blockBodiesBytes) shouldBe blockBodies
114
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .BlockBodiesCode , blockBodiesBytes) shouldBe blockBodies
108
115
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .BlockBodiesCode , blockBodiesBytes) shouldBe blockBodies
109
116
}
110
117
@@ -113,6 +120,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
113
120
val getNodeDataBytes : Array [Byte ] = getNodeData.toBytes
114
121
115
122
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .GetNodeDataCode , getNodeDataBytes) shouldBe getNodeData
123
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .GetNodeDataCode , getNodeDataBytes) shouldBe getNodeData
116
124
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .GetNodeDataCode , getNodeDataBytes) shouldBe getNodeData
117
125
}
118
126
@@ -121,6 +129,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
121
129
val nodeDataBytes : Array [Byte ] = nodeData.toBytes
122
130
123
131
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .NodeDataCode , nodeDataBytes) shouldBe nodeData
132
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .NodeDataCode , nodeDataBytes) shouldBe nodeData
124
133
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .NodeDataCode , nodeDataBytes) shouldBe nodeData
125
134
}
126
135
@@ -129,6 +138,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
129
138
val getReceiptsBytes : Array [Byte ] = getReceipts.toBytes
130
139
131
140
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .GetReceiptsCode , getReceiptsBytes) shouldBe getReceipts
141
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .GetReceiptsCode , getReceiptsBytes) shouldBe getReceipts
132
142
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .GetReceiptsCode , getReceiptsBytes) shouldBe getReceipts
133
143
}
134
144
@@ -137,17 +147,21 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
137
147
val receiptsBytes : Array [Byte ] = receipts.toBytes
138
148
139
149
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .ReceiptsCode , receiptsBytes) shouldBe receipts
150
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .ReceiptsCode , receiptsBytes) shouldBe receipts
140
151
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .ReceiptsCode , receiptsBytes) shouldBe receipts
141
152
}
142
153
143
154
it should " decode Status message for all supported versions of protocol" in {
144
155
val status63 = BaseETH6XMessages .Status (ProtocolVersions .ETH63 .version, 1 , BigInt (100 ), exampleHash, exampleHash)
145
156
val status63Bytes : Array [Byte ] = status63.toBytes
146
- val status64 =
157
+ val statusEtc64 =
147
158
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 ))
148
161
149
162
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 statusEtc64
151
165
}
152
166
153
167
it should " decode NewBlock message for all supported versions of protocol" in {
@@ -156,6 +170,7 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
156
170
val newBlock64 = ObjectGenerators .newBlock64Gen(secureRandom, None ).sample.get
157
171
158
172
decode(ProtocolVersions .ETH63 ).fromBytes(Codes .NewBlockCode , newBlock63Bytes) shouldBe newBlock63
173
+ decode(ProtocolVersions .ETH64 ).fromBytes(Codes .NewBlockCode , newBlock63Bytes) shouldBe newBlock63
159
174
decode(ProtocolVersions .ETC64 ).fromBytes(Codes .NewBlockCode , newBlock64.toBytes) shouldBe newBlock64
160
175
}
161
176
@@ -165,6 +180,8 @@ class MessageDecodersSpec extends AnyFlatSpec with Matchers with SecureRandomBui
165
180
166
181
decode(ProtocolVersions .ETH63 )
167
182
.fromBytes(Codes .SignedTransactionsCode , signedTransactionsBytes) shouldBe signedTransactions
183
+ decode(ProtocolVersions .ETH64 )
184
+ .fromBytes(Codes .SignedTransactionsCode , signedTransactionsBytes) shouldBe signedTransactions
168
185
decode(ProtocolVersions .ETC64 )
169
186
.fromBytes(Codes .SignedTransactionsCode , signedTransactionsBytes) shouldBe signedTransactions
170
187
}
0 commit comments