-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial impl of state network bridge 1902 (#1948)
- Loading branch information
1 parent
79c6bdc
commit 7001342
Showing
12 changed files
with
365 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Fluffy | ||
# Copyright (c) 2023-2024 Status Research & Development GmbH | ||
# Licensed and distributed under either of | ||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). | ||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). | ||
# at your option. This file may not be copied, modified, or distributed except according to those terms. | ||
|
||
import | ||
std/[os, json, sequtils], | ||
testutils/unittests, | ||
stew/[byteutils, io2], | ||
eth/keys, | ||
../../network/state/state_content | ||
|
||
const testVectorDir = | ||
"./vendor/portal-spec-tests/tests/mainnet/state/" | ||
|
||
procSuite "State Content": | ||
let rng = newRng() | ||
|
||
test "Encode/decode accountTrieProof": | ||
let file = testVectorDir & "/proofs.full.block.0.json" | ||
let content = readAllFile(file).valueOr: | ||
quit(1) | ||
|
||
let decoded = | ||
try: | ||
Json.decode(content, state_content.JsonProofVector) | ||
except SerializationError: | ||
quit(1) | ||
|
||
let proof = decoded.proofs[0].proof.map(hexToSeqByte) | ||
|
||
var accountTrieProof = AccountTrieProof(@[]) | ||
for witness in proof: | ||
let witnessNode = ByteList(witness) | ||
discard accountTrieProof.add(witnessNode) | ||
|
||
let | ||
encodedProof = SSZ.encode(accountTrieProof) | ||
decodedProof = decodeSsz(encodedProof, AccountTrieProof).get() | ||
|
||
check decodedProof == accountTrieProof | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-d:"chronicles_sinks=textlines[dynamic],json[dynamic]" |
Oops, something went wrong.