Use ByteList.init instead of List 2048 (#876)

This commit is contained in:
Kim De Mey 2021-10-22 17:49:23 +02:00 committed by GitHub
parent 4b498356fc
commit 92dfb02ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 6 deletions

View File

@ -50,7 +50,7 @@ func fromSszBytes*(T: type ContentType, data: openArray[byte]):
contentType
func encode*(contentKey: ContentKey): ByteList =
List.init(SSZ.encode(contentKey), 2048)
ByteList.init(SSZ.encode(contentKey))
func decode*(contentKey: ByteList): Option[ContentKey] =
try:

View File

@ -62,7 +62,7 @@ func fromSszBytes*(T: type ContentType, data: openArray[byte]):
contentType
func encode*(contentKey: ContentKey): ByteList =
List.init(SSZ.encode(contentKey), 2048)
ByteList.init(SSZ.encode(contentKey))
# TODO consider if more powerfull error handling is necessary here.
func decode*(contentKey: ByteList): Option[ContentKey] =

View File

@ -111,8 +111,7 @@ suite "Portal Wire Protocol Message Encodings":
test "FindContent Request":
let
contentEncoded: ByteList = List.init(@[1'u8], 2048)
contentEncoded = ByteList.init(@[1'u8])
fn = FindContentMessage(contentKey: contentEncoded)
let encoded = encodeMessage(fn)

View File

@ -123,7 +123,7 @@ procSuite "Portal Wire Protocol Tests":
# table.
test.proto2.start()
let contentKey = List.init(@[1'u8], 2048)
let contentKey = ByteList.init(@[1'u8])
# content does not exist so this should provide us with the closest nodes
# to the content, which is the only node in the routing table.

View File

@ -221,7 +221,7 @@ proc run(config: DiscoveryConf) =
key
# For now just some random bytes
let contentKey = List.init(@[1'u8], 2048)
let contentKey = ByteList.init(@[1'u8])
let foundContent = waitFor portal.findContent(config.findContentTarget,
contentKey)