mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(network): move test helpers to test-utils mod (#901)
This commit is contained in:
461
Cargo.lock
generated
461
Cargo.lock
generated
@ -8,7 +8,7 @@ version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -21,7 +21,7 @@ dependencies = [
|
||||
"cipher 0.3.0",
|
||||
"cpufeatures",
|
||||
"ctr 0.8.0",
|
||||
"opaque-debug",
|
||||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -199,6 +199,18 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "auto_impl"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7862e21c893d65a1650125d157eaeec691439379a1cee17ee49031b79236ada4"
|
||||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro2 1.0.49",
|
||||
"quote 1.0.23",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "auto_impl"
|
||||
version = "1.0.1"
|
||||
@ -235,6 +247,28 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce"
|
||||
|
||||
[[package]]
|
||||
name = "base58"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83"
|
||||
|
||||
[[package]]
|
||||
name = "base58check"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ee2fe4c9a0c84515f136aaae2466744a721af6d63339c18689d9e995d74d99b"
|
||||
dependencies = [
|
||||
"base58",
|
||||
"sha2 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.1"
|
||||
@ -253,6 +287,12 @@ version = "1.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf"
|
||||
|
||||
[[package]]
|
||||
name = "bech32"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dabbe35f96fb9507f7330793dc490461b2962659ac5d427181e451a623751d1"
|
||||
|
||||
[[package]]
|
||||
name = "beef"
|
||||
version = "0.5.2"
|
||||
@ -312,6 +352,16 @@ version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "0.17.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c"
|
||||
dependencies = [
|
||||
"either",
|
||||
"radium 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "1.0.1"
|
||||
@ -319,18 +369,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
|
||||
dependencies = [
|
||||
"funty",
|
||||
"radium",
|
||||
"radium 0.7.0",
|
||||
"tap",
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blake2"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
|
||||
dependencies = [
|
||||
"digest 0.10.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
|
||||
dependencies = [
|
||||
"block-padding 0.1.5",
|
||||
"byte-tools",
|
||||
"byteorder",
|
||||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -339,7 +410,16 @@ version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-padding"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
|
||||
dependencies = [
|
||||
"byte-tools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -348,7 +428,7 @@ version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a90ec2df9600c28a01c56c4784c9207a96d2451833aeceb8cc97e4c9548bb78"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -384,6 +464,12 @@ version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c"
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
@ -504,7 +590,7 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -613,6 +699,63 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "coins-bip32"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "634c509653de24b439672164bbf56f5f582a2ab0e313d3b0f6af0b7345cf2560"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bs58",
|
||||
"coins-core",
|
||||
"digest 0.10.6",
|
||||
"getrandom 0.2.8",
|
||||
"hmac",
|
||||
"k256",
|
||||
"lazy_static",
|
||||
"serde",
|
||||
"sha2 0.10.6",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "coins-bip39"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a11892bcac83b4c6e95ab84b5b06c76d9d70ad73548dd07418269c5c7977171"
|
||||
dependencies = [
|
||||
"bitvec 0.17.4",
|
||||
"coins-bip32",
|
||||
"getrandom 0.2.8",
|
||||
"hex",
|
||||
"hmac",
|
||||
"pbkdf2",
|
||||
"rand 0.8.5",
|
||||
"sha2 0.10.6",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "coins-core"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c94090a6663f224feae66ab01e41a2555a8296ee07b5f20dab8888bdefc9f617"
|
||||
dependencies = [
|
||||
"base58check",
|
||||
"base64 0.12.3",
|
||||
"bech32",
|
||||
"blake2",
|
||||
"digest 0.10.6",
|
||||
"generic-array 0.14.6",
|
||||
"hex",
|
||||
"ripemd",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"sha2 0.10.6",
|
||||
"sha3",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "confy"
|
||||
version = "0.5.1"
|
||||
@ -637,6 +780,15 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
||||
dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.3"
|
||||
@ -768,7 +920,7 @@ version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
@ -780,7 +932,7 @@ version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
@ -1010,20 +1162,29 @@ version = "0.99.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"convert_case 0.4.0",
|
||||
"proc-macro2 1.0.49",
|
||||
"quote 1.0.23",
|
||||
"rustc_version",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
||||
dependencies = [
|
||||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1195,7 +1356,7 @@ dependencies = [
|
||||
"der",
|
||||
"digest 0.10.6",
|
||||
"ff",
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
"group",
|
||||
"pkcs8",
|
||||
"rand_core 0.6.4",
|
||||
@ -1329,6 +1490,28 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "eth-keystore"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab"
|
||||
dependencies = [
|
||||
"aes 0.8.2",
|
||||
"ctr 0.9.2",
|
||||
"digest 0.10.6",
|
||||
"hex",
|
||||
"hmac",
|
||||
"pbkdf2",
|
||||
"rand 0.8.5",
|
||||
"scrypt",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.10.6",
|
||||
"sha3",
|
||||
"thiserror",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethabi"
|
||||
version = "18.0.0"
|
||||
@ -1377,39 +1560,99 @@ dependencies = [
|
||||
"uint",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethers-contract"
|
||||
version = "1.0.2"
|
||||
source = "git+https://github.com/gakonst/ethers-rs#72e94f02dd80241a500d9c6d39c4166e77bc73ef"
|
||||
dependencies = [
|
||||
"ethers-core",
|
||||
"ethers-providers",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"once_cell",
|
||||
"pin-project",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethers-core"
|
||||
version = "1.0.2"
|
||||
source = "git+https://github.com/gakonst/ethers-rs#2eb56e69b777b093ae8c2937d7b3c764f1347280"
|
||||
source = "git+https://github.com/gakonst/ethers-rs#72e94f02dd80241a500d9c6d39c4166e77bc73ef"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"convert_case 0.6.0",
|
||||
"elliptic-curve",
|
||||
"ethabi",
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
"hex",
|
||||
"k256",
|
||||
"num_enum",
|
||||
"open-fastrlp",
|
||||
"proc-macro2 1.0.49",
|
||||
"rand 0.8.5",
|
||||
"rlp",
|
||||
"rlp-derive",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"syn 1.0.107",
|
||||
"thiserror",
|
||||
"tiny-keccak",
|
||||
"unicode-xid 0.2.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethers-providers"
|
||||
name = "ethers-etherscan"
|
||||
version = "1.0.2"
|
||||
source = "git+https://github.com/gakonst/ethers-rs#2eb56e69b777b093ae8c2937d7b3c764f1347280"
|
||||
source = "git+https://github.com/gakonst/ethers-rs#72e94f02dd80241a500d9c6d39c4166e77bc73ef"
|
||||
dependencies = [
|
||||
"ethers-core",
|
||||
"getrandom 0.2.8",
|
||||
"reqwest",
|
||||
"semver 1.0.16",
|
||||
"serde",
|
||||
"serde-aux",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethers-middleware"
|
||||
version = "1.0.2"
|
||||
source = "git+https://github.com/gakonst/ethers-rs#72e94f02dd80241a500d9c6d39c4166e77bc73ef"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"auto_impl",
|
||||
"auto_impl 0.5.0",
|
||||
"ethers-contract",
|
||||
"ethers-core",
|
||||
"ethers-etherscan",
|
||||
"ethers-providers",
|
||||
"ethers-signers",
|
||||
"futures-locks",
|
||||
"futures-util",
|
||||
"instant",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-futures",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethers-providers"
|
||||
version = "1.0.2"
|
||||
source = "git+https://github.com/gakonst/ethers-rs#72e94f02dd80241a500d9c6d39c4166e77bc73ef"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"auto_impl 1.0.1",
|
||||
"base64 0.21.0",
|
||||
"enr 0.7.0",
|
||||
"ethers-core",
|
||||
@ -1438,6 +1681,23 @@ dependencies = [
|
||||
"ws_stream_wasm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethers-signers"
|
||||
version = "1.0.2"
|
||||
source = "git+https://github.com/gakonst/ethers-rs#72e94f02dd80241a500d9c6d39c4166e77bc73ef"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"coins-bip32",
|
||||
"coins-bip39",
|
||||
"elliptic-curve",
|
||||
"eth-keystore",
|
||||
"ethers-core",
|
||||
"hex",
|
||||
"rand 0.8.5",
|
||||
"sha2 0.10.6",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethnum"
|
||||
version = "1.3.2"
|
||||
@ -1460,6 +1720,12 @@ dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.8.0"
|
||||
@ -1584,6 +1850,16 @@ dependencies = [
|
||||
"waker-fn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-locks"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-task",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.25"
|
||||
@ -1644,6 +1920,15 @@ dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.6"
|
||||
@ -1684,7 +1969,7 @@ version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99"
|
||||
dependencies = [
|
||||
"opaque-debug",
|
||||
"opaque-debug 0.3.0",
|
||||
"polyval",
|
||||
]
|
||||
|
||||
@ -2185,8 +2470,8 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"generic-array",
|
||||
"block-padding 0.3.2",
|
||||
"generic-array 0.14.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2880,6 +3165,12 @@ version = "11.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.3.0"
|
||||
@ -2893,7 +3184,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"auto_impl",
|
||||
"auto_impl 1.0.1",
|
||||
"bytes",
|
||||
"ethereum-types",
|
||||
"open-fastrlp-derive",
|
||||
@ -2955,7 +3246,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitvec",
|
||||
"bitvec 1.0.1",
|
||||
"byte-slice-cast",
|
||||
"bytes",
|
||||
"impl-trait-for-tuples",
|
||||
@ -3043,12 +3334,35 @@ dependencies = [
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "password-hash"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917"
|
||||
dependencies = [
|
||||
"digest 0.10.6",
|
||||
"hmac",
|
||||
"password-hash",
|
||||
"sha2 0.10.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peeking_take_while"
|
||||
version = "0.1.2"
|
||||
@ -3168,7 +3482,7 @@ checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"opaque-debug",
|
||||
"opaque-debug 0.3.0",
|
||||
"universal-hash",
|
||||
]
|
||||
|
||||
@ -3360,6 +3674,12 @@ dependencies = [
|
||||
"proc-macro2 1.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "radium"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac"
|
||||
|
||||
[[package]]
|
||||
name = "radium"
|
||||
version = "0.7.0"
|
||||
@ -3557,6 +3877,7 @@ dependencies = [
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
"log",
|
||||
@ -3564,15 +3885,19 @@ dependencies = [
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustls",
|
||||
"rustls-pemfile",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tower-service",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"webpki-roots",
|
||||
"winreg",
|
||||
]
|
||||
|
||||
@ -3661,7 +3986,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"async-trait",
|
||||
"auto_impl",
|
||||
"auto_impl 1.0.1",
|
||||
"bytes",
|
||||
"futures",
|
||||
"reth-executor",
|
||||
@ -3719,7 +4044,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"discv5",
|
||||
"enr 0.7.0",
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
"hex",
|
||||
"rand 0.8.5",
|
||||
"reth-net-common",
|
||||
@ -3781,7 +4106,7 @@ name = "reth-ecies"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aes 0.8.2",
|
||||
"block-padding",
|
||||
"block-padding 0.3.2",
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"cipher 0.4.3",
|
||||
@ -3789,7 +4114,7 @@ dependencies = [
|
||||
"digest 0.10.6",
|
||||
"educe",
|
||||
"futures",
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
"hex-literal",
|
||||
"hmac",
|
||||
"pin-project",
|
||||
@ -3845,7 +4170,7 @@ name = "reth-executor"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"auto_impl",
|
||||
"auto_impl 1.0.1",
|
||||
"hash-db",
|
||||
"hashbrown 0.13.1",
|
||||
"plain_hasher",
|
||||
@ -3869,7 +4194,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"async-trait",
|
||||
"auto_impl",
|
||||
"auto_impl 1.0.1",
|
||||
"bytes",
|
||||
"futures",
|
||||
"hex-literal",
|
||||
@ -3977,11 +4302,13 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"aquamarine",
|
||||
"async-trait",
|
||||
"auto_impl",
|
||||
"auto_impl 1.0.1",
|
||||
"bytes",
|
||||
"enr 0.7.0",
|
||||
"ethers-core",
|
||||
"ethers-middleware",
|
||||
"ethers-providers",
|
||||
"ethers-signers",
|
||||
"fnv",
|
||||
"futures",
|
||||
"hex",
|
||||
@ -3999,6 +4326,7 @@ dependencies = [
|
||||
"reth-interfaces",
|
||||
"reth-metrics-derive",
|
||||
"reth-net-common",
|
||||
"reth-network",
|
||||
"reth-network-api",
|
||||
"reth-primitives",
|
||||
"reth-provider",
|
||||
@ -4068,7 +4396,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"async-trait",
|
||||
"auto_impl",
|
||||
"auto_impl 1.0.1",
|
||||
"bytes",
|
||||
"futures",
|
||||
"heapless",
|
||||
@ -4096,7 +4424,7 @@ name = "reth-rlp"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"auto_impl",
|
||||
"auto_impl 1.0.1",
|
||||
"bytes",
|
||||
"criterion",
|
||||
"enr 0.7.0",
|
||||
@ -4253,7 +4581,7 @@ name = "revm"
|
||||
version = "2.3.1"
|
||||
source = "git+https://github.com/bluealloy/revm?rev=a05fb262d87c78ee52d400e6c0f4708d4c527f32#a05fb262d87c78ee52d400e6c0f4708d4c527f32"
|
||||
dependencies = [
|
||||
"auto_impl",
|
||||
"auto_impl 1.0.1",
|
||||
"bytes",
|
||||
"hashbrown 0.13.1",
|
||||
"hex",
|
||||
@ -4471,6 +4799,15 @@ version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
|
||||
|
||||
[[package]]
|
||||
name = "salsa20"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"
|
||||
dependencies = [
|
||||
"cipher 0.4.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
@ -4526,6 +4863,18 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2"
|
||||
|
||||
[[package]]
|
||||
name = "scrypt"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d"
|
||||
dependencies = [
|
||||
"hmac",
|
||||
"pbkdf2",
|
||||
"salsa20",
|
||||
"sha2 0.10.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.7.0"
|
||||
@ -4544,7 +4893,7 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928"
|
||||
dependencies = [
|
||||
"base16ct",
|
||||
"der",
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
"pkcs8",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
@ -4658,6 +5007,16 @@ dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-aux"
|
||||
version = "4.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c599b3fd89a75e0c18d6d2be693ddb12cccaf771db4ff9e39097104808a014c0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.152"
|
||||
@ -4755,7 +5114,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug",
|
||||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4769,6 +5128,18 @@ dependencies = [
|
||||
"digest 0.10.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69"
|
||||
dependencies = [
|
||||
"block-buffer 0.7.3",
|
||||
"digest 0.8.1",
|
||||
"fake-simd",
|
||||
"opaque-debug 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.9.9"
|
||||
@ -4779,7 +5150,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug",
|
||||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -5648,6 +6019,12 @@ dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.10"
|
||||
@ -5672,7 +6049,7 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.6",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
@ -5704,6 +6081,16 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||
dependencies = [
|
||||
"getrandom 0.2.8",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
|
||||
@ -63,16 +63,27 @@ secp256k1 = { version = "0.24", features = [
|
||||
"recovery",
|
||||
] }
|
||||
|
||||
enr = { version = "0.7.0", features = ["serde", "rust-secp256k1"], optional = true }
|
||||
ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false, optional = true }
|
||||
tempfile = { version = "3.3", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
# reth
|
||||
reth-discv4 = { path = "../discv4", features = ["test-utils"] }
|
||||
reth-interfaces = { path = "../../interfaces", features = ["test-utils"] }
|
||||
|
||||
# we need to enable the test-utils feature in our own crate to use utils in
|
||||
# integration tests
|
||||
reth-network = { path = ".", features = ["test-utils"] }
|
||||
|
||||
reth-provider = { path = "../../storage/provider", features = ["test-utils"] }
|
||||
reth-tracing = { path = "../../tracing" }
|
||||
reth-transaction-pool = { path = "../../transaction-pool", features = ["test-utils"] }
|
||||
|
||||
ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
|
||||
ethers-providers = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
|
||||
ethers-signers = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
|
||||
ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
|
||||
|
||||
enr = { version = "0.7.0", features = ["serde", "rust-secp256k1"] }
|
||||
|
||||
@ -83,3 +94,4 @@ serial_test = "0.10"
|
||||
|
||||
[features]
|
||||
serde = ["dep:serde", "dep:humantime-serde"]
|
||||
test-utils = ["reth-provider/test-utils", "dep:enr", "dep:ethers-core", "dep:tempfile"]
|
||||
|
||||
@ -113,6 +113,10 @@
|
||||
//!
|
||||
//! - `serde`: Enable serde support for configuration types.
|
||||
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
/// Common helpers for network testing.
|
||||
pub mod test_utils;
|
||||
|
||||
mod builder;
|
||||
mod cache;
|
||||
pub mod config;
|
||||
|
||||
46
crates/net/network/src/test_utils/init.rs
Normal file
46
crates/net/network/src/test_utils/init.rs
Normal file
@ -0,0 +1,46 @@
|
||||
use enr::{k256::ecdsa::SigningKey, Enr, EnrPublicKey};
|
||||
use reth_primitives::PeerId;
|
||||
use std::{net::SocketAddr, time::Duration};
|
||||
|
||||
/// The timeout for tests that create a GethInstance
|
||||
pub const GETH_TIMEOUT: Duration = Duration::from_secs(60);
|
||||
|
||||
/// Obtains a PeerId from an ENR. In this case, the PeerId represents the public key contained in
|
||||
/// the ENR.
|
||||
pub fn enr_to_peer_id(enr: Enr<SigningKey>) -> PeerId {
|
||||
// In the following tests, methods which accept a public key expect it to contain the public
|
||||
// key in its 64-byte encoded (uncompressed) form.
|
||||
enr.public_key().encode_uncompressed().into()
|
||||
}
|
||||
|
||||
// copied from ethers-rs
|
||||
/// A bit of hack to find an unused TCP port.
|
||||
///
|
||||
/// Does not guarantee that the given port is unused after the function exists, just that it was
|
||||
/// unused before the function started (i.e., it does not reserve a port).
|
||||
pub fn unused_port() -> u16 {
|
||||
let listener = std::net::TcpListener::bind("127.0.0.1:0")
|
||||
.expect("Failed to create TCP listener to find unused port");
|
||||
|
||||
let local_addr =
|
||||
listener.local_addr().expect("Failed to read TCP listener local_addr to find unused port");
|
||||
local_addr.port()
|
||||
}
|
||||
|
||||
/// Creates two unused SocketAddrs, intended for use as the p2p (TCP) and discovery ports (UDP) for
|
||||
/// new reth instances.
|
||||
pub fn unused_tcp_udp() -> (SocketAddr, SocketAddr) {
|
||||
let tcp_listener = std::net::TcpListener::bind("127.0.0.1:0")
|
||||
.expect("Failed to create TCP listener to find unused port");
|
||||
let tcp_addr = tcp_listener
|
||||
.local_addr()
|
||||
.expect("Failed to read TCP listener local_addr to find unused port");
|
||||
|
||||
let udp_listener = std::net::UdpSocket::bind("127.0.0.1:0")
|
||||
.expect("Failed to create UDP listener to find unused port");
|
||||
let udp_addr = udp_listener
|
||||
.local_addr()
|
||||
.expect("Failed to read UDP listener local_addr to find unused port");
|
||||
|
||||
(tcp_addr, udp_addr)
|
||||
}
|
||||
9
crates/net/network/src/test_utils/mod.rs
Normal file
9
crates/net/network/src/test_utils/mod.rs
Normal file
@ -0,0 +1,9 @@
|
||||
#![warn(missing_docs, unreachable_pub)]
|
||||
|
||||
//! Common helpers for network testing.
|
||||
|
||||
mod init;
|
||||
mod testnet;
|
||||
|
||||
pub use init::{enr_to_peer_id, unused_port, unused_tcp_udp, GETH_TIMEOUT};
|
||||
pub use testnet::{NetworkEventStream, PeerConfig, Testnet};
|
||||
@ -1,12 +1,12 @@
|
||||
//! A network implementation for testing purposes.
|
||||
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use pin_project::pin_project;
|
||||
use reth_eth_wire::DisconnectReason;
|
||||
use reth_network::{
|
||||
use crate::{
|
||||
error::NetworkError, eth_requests::EthRequestHandler, NetworkConfig, NetworkEvent,
|
||||
NetworkHandle, NetworkManager,
|
||||
};
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use pin_project::pin_project;
|
||||
use reth_eth_wire::DisconnectReason;
|
||||
use reth_primitives::PeerId;
|
||||
use reth_provider::{test_utils::NoopProvider, BlockProvider, HeaderProvider};
|
||||
use secp256k1::SecretKey;
|
||||
@ -52,22 +52,28 @@ where
|
||||
Ok(this)
|
||||
}
|
||||
|
||||
/// Return a mutable slice of all peers.
|
||||
pub fn peers_mut(&mut self) -> &mut [Peer<C>] {
|
||||
&mut self.peers
|
||||
}
|
||||
|
||||
/// Return a slice of all peers.
|
||||
pub fn peers(&self) -> &[Peer<C>] {
|
||||
&self.peers
|
||||
}
|
||||
|
||||
/// Return a mutable iterator over all peers.
|
||||
pub fn peers_iter_mut(&mut self) -> impl Iterator<Item = &mut Peer<C>> + '_ {
|
||||
self.peers.iter_mut()
|
||||
}
|
||||
|
||||
/// Return an iterator over all peers.
|
||||
pub fn peers_iter(&self) -> impl Iterator<Item = &Peer<C>> + '_ {
|
||||
self.peers.iter()
|
||||
}
|
||||
|
||||
/// Extend the list of peers with new peers that are configured with each of the given
|
||||
/// [`PeerConfig`]s.
|
||||
pub async fn extend_peer_with_config(
|
||||
&mut self,
|
||||
configs: impl IntoIterator<Item = PeerConfig<C>>,
|
||||
@ -78,6 +84,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Add a peer to the [`Testnet`] with the given [`PeerConfig`].
|
||||
pub async fn add_peer_with_config(
|
||||
&mut self,
|
||||
config: PeerConfig<C>,
|
||||
@ -155,6 +162,7 @@ impl Testnet<NoopProvider> {
|
||||
Ok(this)
|
||||
}
|
||||
|
||||
/// Add a peer to the [`Testnet`]
|
||||
pub async fn add_peer(&mut self) -> Result<(), NetworkError> {
|
||||
self.add_peer_with_config(Default::default()).await
|
||||
}
|
||||
@ -181,6 +189,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// A handle to a [`Testnet`] that can be shared.
|
||||
pub struct TestnetHandle<C> {
|
||||
_handle: JoinHandle<()>,
|
||||
terminate: oneshot::Sender<oneshot::Sender<Testnet<C>>>,
|
||||
@ -213,6 +222,7 @@ impl<C> Peer<C>
|
||||
where
|
||||
C: BlockProvider + HeaderProvider,
|
||||
{
|
||||
/// Returns the number of connected peers.
|
||||
pub fn num_peers(&self) -> usize {
|
||||
self.network.num_connected_peers()
|
||||
}
|
||||
@ -222,6 +232,7 @@ where
|
||||
self.network.local_addr()
|
||||
}
|
||||
|
||||
/// Returns the [`NetworkHandle`] of this peer.
|
||||
pub fn handle(&self) -> NetworkHandle {
|
||||
self.network.handle().clone()
|
||||
}
|
||||
@ -253,6 +264,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper config for setting up the reth networking stack.
|
||||
pub struct PeerConfig<C = NoopProvider> {
|
||||
config: NetworkConfig<C>,
|
||||
client: Arc<C>,
|
||||
@ -265,11 +277,15 @@ impl<C> PeerConfig<C>
|
||||
where
|
||||
C: BlockProvider + HeaderProvider,
|
||||
{
|
||||
/// Initialize the network with a random secret key, allowing the devp2p and discovery to bind
|
||||
/// to any available IP and port.
|
||||
pub fn new(client: Arc<C>) -> Self {
|
||||
let secret_key = SecretKey::new(&mut rand::thread_rng());
|
||||
Self::with_secret_key(client, secret_key)
|
||||
}
|
||||
|
||||
/// Initialize the network with a given secret key, allowing devp2p and discovery to bind any
|
||||
/// available IP and port.
|
||||
pub fn with_secret_key(client: Arc<C>, secret_key: SecretKey) -> Self {
|
||||
let config = NetworkConfig::builder(Arc::clone(&client), secret_key)
|
||||
.listener_addr(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0)))
|
||||
@ -295,10 +311,12 @@ pub struct NetworkEventStream {
|
||||
// === impl NetworkEventStream ===
|
||||
|
||||
impl NetworkEventStream {
|
||||
/// Create a new [`NetworkEventStream`] from the given network event receiver stream.
|
||||
pub fn new(inner: UnboundedReceiverStream<NetworkEvent>) -> Self {
|
||||
Self { inner }
|
||||
}
|
||||
|
||||
/// Awaits the next event for a session to be closed
|
||||
pub async fn next_session_closed(&mut self) -> Option<(PeerId, Option<DisconnectReason>)> {
|
||||
while let Some(ev) = self.inner.next().await {
|
||||
match ev {
|
||||
@ -308,6 +326,7 @@ impl NetworkEventStream {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Awaits the next event for an established session
|
||||
pub async fn next_session_established(&mut self) -> Option<PeerId> {
|
||||
while let Some(ev) = self.inner.next().await {
|
||||
@ -318,4 +337,21 @@ impl NetworkEventStream {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Ensures that the first two events are a [`PeerAdded`] and [`SessionEstablished`],
|
||||
/// returning the [`PeerId`] of the established session.
|
||||
pub async fn peer_added_and_established(&mut self) -> Option<PeerId> {
|
||||
let peer_id = match self.inner.next().await {
|
||||
Some(NetworkEvent::PeerAdded(peer_id)) => peer_id,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
match self.inner.next().await {
|
||||
Some(NetworkEvent::SessionEstablished { peer_id: peer_id2, .. }) => {
|
||||
debug_assert_eq!(peer_id, peer_id2, "PeerAdded peer_id {peer_id} does not match SessionEstablished peer_id {peer_id2}");
|
||||
Some(peer_id)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,9 @@
|
||||
//! Connection tests
|
||||
|
||||
use super::testnet::Testnet;
|
||||
use crate::{NetworkEventStream, PeerConfig};
|
||||
use enr::{k256::ecdsa::SigningKey, Enr, EnrPublicKey};
|
||||
use ethers_core::utils::Geth;
|
||||
|
||||
use ethers_providers::{Http, Middleware, Provider};
|
||||
|
||||
use futures::StreamExt;
|
||||
use reth_discv4::{bootnodes::mainnet_nodes, Discv4Config};
|
||||
use reth_eth_wire::DisconnectReason;
|
||||
@ -13,7 +12,12 @@ use reth_interfaces::{
|
||||
sync::{SyncState, SyncStateUpdater},
|
||||
};
|
||||
use reth_net_common::ban_list::BanList;
|
||||
use reth_network::{NetworkConfig, NetworkEvent, NetworkManager, PeersConfig};
|
||||
use reth_network::{
|
||||
test_utils::{
|
||||
enr_to_peer_id, unused_tcp_udp, NetworkEventStream, PeerConfig, Testnet, GETH_TIMEOUT,
|
||||
},
|
||||
NetworkConfig, NetworkEvent, NetworkManager, PeersConfig,
|
||||
};
|
||||
use reth_network_api::{NetworkInfo, PeersInfo};
|
||||
use reth_primitives::{HeadersDirection, NodeRecord, PeerId};
|
||||
use reth_provider::test_utils::NoopProvider;
|
||||
@ -22,17 +26,6 @@ use secp256k1::SecretKey;
|
||||
use std::{collections::HashSet, net::SocketAddr, sync::Arc, time::Duration};
|
||||
use tokio::task;
|
||||
|
||||
// The timeout for tests that create a GethInstance
|
||||
const GETH_TIMEOUT: Duration = Duration::from_secs(60);
|
||||
|
||||
/// Obtains a PeerId from an ENR. In this case, the PeerId represents the public key contained in
|
||||
/// the ENR.
|
||||
fn enr_to_peer_id(enr: Enr<SigningKey>) -> PeerId {
|
||||
// In the following tests, methods which accept a public key expect it to contain the public
|
||||
// key in its 64-byte encoded (uncompressed) form.
|
||||
enr.public_key().encode_uncompressed().into()
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_establish_connections() {
|
||||
reth_tracing::init_test_tracing();
|
||||
@ -337,11 +330,10 @@ async fn test_incoming_node_id_blacklist() {
|
||||
let ban_list = BanList::new(vec![geth_peer_id], HashSet::new());
|
||||
let peer_config = PeersConfig::default().with_ban_list(ban_list);
|
||||
|
||||
let reth_p2p_socket = SocketAddr::new([127, 0, 0, 1].into(), 30303);
|
||||
let reth_disc_socket = SocketAddr::new([127, 0, 0, 1].into(), 30304);
|
||||
let (reth_p2p, reth_disc) = unused_tcp_udp();
|
||||
let config = NetworkConfig::builder(Arc::new(NoopProvider::default()), secret_key)
|
||||
.listener_addr(reth_p2p_socket)
|
||||
.discovery_addr(reth_disc_socket)
|
||||
.listener_addr(reth_p2p)
|
||||
.discovery_addr(reth_disc)
|
||||
.peer_config(peer_config)
|
||||
.build();
|
||||
|
||||
@ -353,7 +345,7 @@ async fn test_incoming_node_id_blacklist() {
|
||||
tokio::task::spawn(network);
|
||||
|
||||
// make geth connect to us
|
||||
let our_enode = NodeRecord::new(reth_p2p_socket, *handle.peer_id());
|
||||
let our_enode = NodeRecord::new(reth_p2p, *handle.peer_id());
|
||||
|
||||
provider.add_peer(our_enode.to_string()).await.unwrap();
|
||||
|
||||
@ -387,11 +379,10 @@ async fn test_incoming_connect_with_single_geth() {
|
||||
// get the peer id we should be expecting
|
||||
let geth_peer_id = enr_to_peer_id(provider.node_info().await.unwrap().enr);
|
||||
|
||||
let reth_p2p_socket = SocketAddr::new([127, 0, 0, 1].into(), 30305);
|
||||
let reth_disc_socket = SocketAddr::new([127, 0, 0, 1].into(), 30306);
|
||||
let (reth_p2p, reth_disc) = unused_tcp_udp();
|
||||
let config = NetworkConfig::builder(Arc::new(NoopProvider::default()), secret_key)
|
||||
.listener_addr(reth_p2p_socket)
|
||||
.discovery_addr(reth_disc_socket)
|
||||
.listener_addr(reth_p2p)
|
||||
.discovery_addr(reth_disc)
|
||||
.build();
|
||||
|
||||
let network = NetworkManager::new(config).await.unwrap();
|
||||
@ -403,7 +394,7 @@ async fn test_incoming_connect_with_single_geth() {
|
||||
let mut event_stream = NetworkEventStream::new(events);
|
||||
|
||||
// make geth connect to us
|
||||
let our_enode = NodeRecord::new(reth_p2p_socket, *handle.peer_id());
|
||||
let our_enode = NodeRecord::new(reth_p2p, *handle.peer_id());
|
||||
|
||||
provider.add_peer(our_enode.to_string()).await.unwrap();
|
||||
|
||||
@ -422,11 +413,10 @@ async fn test_outgoing_connect_with_single_geth() {
|
||||
tokio::time::timeout(GETH_TIMEOUT, async move {
|
||||
let secret_key = SecretKey::new(&mut rand::thread_rng());
|
||||
|
||||
let reth_p2p_socket = SocketAddr::new([127, 0, 0, 1].into(), 30307);
|
||||
let reth_disc_socket = SocketAddr::new([127, 0, 0, 1].into(), 30308);
|
||||
let (reth_p2p, reth_disc) = unused_tcp_udp();
|
||||
let config = NetworkConfig::builder(Arc::new(NoopProvider::default()), secret_key)
|
||||
.listener_addr(reth_p2p_socket)
|
||||
.discovery_addr(reth_disc_socket)
|
||||
.listener_addr(reth_p2p)
|
||||
.discovery_addr(reth_disc)
|
||||
.build();
|
||||
let network = NetworkManager::new(config).await.unwrap();
|
||||
|
||||
@ -448,8 +438,7 @@ async fn test_outgoing_connect_with_single_geth() {
|
||||
let provider = Provider::<Http>::try_from(format!("http://{geth_endpoint}")).unwrap();
|
||||
|
||||
// get the peer id we should be expecting
|
||||
let geth_peer_id: PeerId =
|
||||
provider.node_info().await.unwrap().enr.public_key().encode_uncompressed().into();
|
||||
let geth_peer_id: PeerId = enr_to_peer_id(provider.node_info().await.unwrap().enr);
|
||||
|
||||
// add geth as a peer then wait for a `SessionEstablished` event
|
||||
handle.add_peer(geth_peer_id, geth_socket);
|
||||
@ -469,11 +458,10 @@ async fn test_geth_disconnect() {
|
||||
tokio::time::timeout(GETH_TIMEOUT, async move {
|
||||
let secret_key = SecretKey::new(&mut rand::thread_rng());
|
||||
|
||||
let reth_p2p_socket = SocketAddr::new([127, 0, 0, 1].into(), 30309);
|
||||
let reth_disc_socket = SocketAddr::new([127, 0, 0, 1].into(), 30310);
|
||||
let (reth_p2p, reth_disc) = unused_tcp_udp();
|
||||
let config = NetworkConfig::builder(Arc::new(NoopProvider::default()), secret_key)
|
||||
.listener_addr(reth_p2p_socket)
|
||||
.discovery_addr(reth_disc_socket)
|
||||
.listener_addr(reth_p2p)
|
||||
.discovery_addr(reth_disc)
|
||||
.build();
|
||||
let network = NetworkManager::new(config).await.unwrap();
|
||||
|
||||
@ -494,8 +482,7 @@ async fn test_geth_disconnect() {
|
||||
let provider = Provider::<Http>::try_from(format!("http://{geth_endpoint}")).unwrap();
|
||||
|
||||
// get the peer id we should be expecting
|
||||
let geth_peer_id: PeerId =
|
||||
provider.node_info().await.unwrap().enr.public_key().encode_uncompressed().into();
|
||||
let geth_peer_id: PeerId = enr_to_peer_id(provider.node_info().await.unwrap().enr);
|
||||
|
||||
// add geth as a peer then wait for `PeerAdded` and `SessionEstablished` events.
|
||||
handle.add_peer(geth_peer_id, geth_socket);
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
mod connect;
|
||||
mod requests;
|
||||
mod testnet;
|
||||
pub use testnet::*;
|
||||
|
||||
fn main() {}
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
//! Tests for eth related requests
|
||||
|
||||
use super::testnet::Testnet;
|
||||
use crate::NetworkEventStream;
|
||||
use rand::Rng;
|
||||
use reth_eth_wire::BlockBody;
|
||||
use reth_interfaces::p2p::{
|
||||
bodies::client::BodiesClient,
|
||||
headers::client::{HeadersClient, HeadersRequest},
|
||||
};
|
||||
use reth_network::test_utils::{NetworkEventStream, Testnet};
|
||||
use reth_network_api::NetworkInfo;
|
||||
use reth_primitives::{
|
||||
Block, Bytes, Header, HeadersDirection, Signature, Transaction, TransactionKind,
|
||||
|
||||
Reference in New Issue
Block a user