use axplicit 127.0.0.1 instead of localhost string

on windows, using "localhost" for rpc test is very slow.
both pyspec_sim and engine_sim will need more than one hour.
while on linux and macos only few minutes.
This commit is contained in:
jangko 2023-07-24 21:50:39 +07:00
parent edc87b702b
commit 18587c3abe
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
9 changed files with 16 additions and 20 deletions

View File

@ -3,7 +3,7 @@ import
test_env, test_env,
unittest2, unittest2,
chronicles, chronicles,
nimcrypto/[hmac, utils], nimcrypto/[hmac],
json_rpc/[rpcclient], json_rpc/[rpcclient],
./types ./types
@ -28,7 +28,7 @@ proc getClient(t: TestEnv, token: string): RpcHttpClient =
@[("Authorization", "Bearer " & token)] @[("Authorization", "Bearer " & token)]
let client = newRpcHttpClient(getHeaders = authHeaders) let client = newRpcHttpClient(getHeaders = authHeaders)
waitFor client.connect("localhost", t.conf.rpcPort, false) waitFor client.connect("127.0.0.1", t.conf.rpcPort, false)
return client return client
template genAuthTest(procName: untyped, timeDriftSeconds: int64, customAuthSecretBytes: string, authOK: bool) = template genAuthTest(procName: untyped, timeDriftSeconds: int64, customAuthSecretBytes: string, authOK: bool) =

View File

@ -6,8 +6,7 @@ import
json_rpc/[rpcclient, errors, jsonmarshal], json_rpc/[rpcclient, errors, jsonmarshal],
../../../tests/rpcclient/eth_api, ../../../tests/rpcclient/eth_api,
../../../premix/parser, ../../../premix/parser,
../../../nimbus/rpc/hexstrings, ../../../nimbus/rpc/hexstrings
../../../premix/parser
import web3/engine_api as web3_engine_api import web3/engine_api as web3_engine_api

View File

@ -1,6 +1,5 @@
import import
"."/[types, test_env, engine_tests, auths_tests], "."/[types, test_env, engine_tests, auths_tests],
unittest2,
../sim_utils ../sim_utils
proc combineTests(): seq[TestSpec] = proc combineTests(): seq[TestSpec] =

View File

@ -1,10 +1,9 @@
import import
std/[typetraits, json], std/[typetraits],
nimcrypto/sysrand, nimcrypto/sysrand,
test_env, test_env,
eth/[common, rlp, keys], eth/[common, rlp, keys],
json_rpc/[rpcclient], json_rpc/[rpcclient],
../../../nimbus/rpc/hexstrings,
../../../nimbus/transaction ../../../nimbus/transaction
import eth/common/eth_types as common_eth_types import eth/common/eth_types as common_eth_types

View File

@ -1,5 +1,5 @@
import import
std/[os, json, times, math], std/[os, times, math],
eth/keys, eth/keys,
eth/p2p as eth_p2p, eth/p2p as eth_p2p,
stew/[results, byteutils], stew/[results, byteutils],
@ -99,7 +99,7 @@ proc setupELClient*(t: TestEnv, chainFile: string, enableAuth: bool) =
else: else:
@[] @[]
t.rpcServer = newRpcHttpServer(["localhost:" & $t.conf.rpcPort], hooks) t.rpcServer = newRpcHttpServer(["127.0.0.1:" & $t.conf.rpcPort], hooks)
t.sealingEngine = SealingEngineRef.new( t.sealingEngine = SealingEngineRef.new(
t.chainRef, t.ctx, t.conf.engineSigner, t.chainRef, t.ctx, t.conf.engineSigner,
txPool, EngineStopped txPool, EngineStopped
@ -120,7 +120,7 @@ proc setupELClient*(t: TestEnv, chainFile: string, enableAuth: bool) =
t.rpcServer.start() t.rpcServer.start()
t.rpcClient = newRpcHttpClient() t.rpcClient = newRpcHttpClient()
waitFor t.rpcClient.connect("localhost", t.conf.rpcPort, false) waitFor t.rpcClient.connect("127.0.0.1", t.conf.rpcPort, false)
t.gHeader = t.com.genesisHeader t.gHeader = t.com.genesisHeader
let kRes = PrivateKey.fromHex(vaultKeyHex) let kRes = PrivateKey.fromHex(vaultKeyHex)

View File

@ -62,7 +62,7 @@ proc setupELClient*(t: TestEnv, conf: ChainConfig, node: JsonNode) =
doAssert(t.com.db.getCanonicalHead().blockHash == genesisHeader.blockHash) doAssert(t.com.db.getCanonicalHead().blockHash == genesisHeader.blockHash)
let txPool = TxPoolRef.new(t.com, engineSigner) let txPool = TxPoolRef.new(t.com, engineSigner)
t.rpcServer = newRpcHttpServer(["localhost:8545"]) t.rpcServer = newRpcHttpServer(["127.0.0.1:8545"])
t.sealingEngine = SealingEngineRef.new( t.sealingEngine = SealingEngineRef.new(
t.chainRef, t.ctx, engineSigner, t.chainRef, t.ctx, engineSigner,
txPool, EngineStopped txPool, EngineStopped
@ -76,7 +76,7 @@ proc setupELClient*(t: TestEnv, conf: ChainConfig, node: JsonNode) =
t.rpcServer.start() t.rpcServer.start()
t.rpcClient = newRpcHttpClient() t.rpcClient = newRpcHttpClient()
waitFor t.rpcClient.connect("localhost", 8545.Port, false) waitFor t.rpcClient.connect("127.0.0.1", 8545.Port, false)
proc stopELClient*(t: TestEnv) = proc stopELClient*(t: TestEnv) =
waitFor t.rpcClient.close() waitFor t.rpcClient.close()

View File

@ -166,11 +166,10 @@ proc handle_newPayload(sealingEngine: SealingEngineRef, api: EngineApiRef, com:
# We have an existing parent, do some sanity checks to avoid the beacon client # We have an existing parent, do some sanity checks to avoid the beacon client
# triggering too early # triggering too early
let let ttd = com.ttd.get(high(common.BlockNumber))
td = db.getScore(header.parentHash)
ttd = com.ttd.get(high(common.BlockNumber))
when payload is ExecutionPayloadV1: when payload is ExecutionPayloadV1:
let td = db.getScore(header.parentHash)
if (not com.forkGTE(MergeFork)) and td < ttd: if (not com.forkGTE(MergeFork)) and td < ttd:
warn "Ignoring pre-merge payload", warn "Ignoring pre-merge payload",
number = header.blockNumber, hash = blockHash, td, ttd number = header.blockNumber, hash = blockHash, td, ttd

View File

@ -90,7 +90,7 @@ proc runTest(steps: Steps) =
com.initializeEmptyDb() com.initializeEmptyDb()
var var
rpcServer = newRpcSocketServer(["localhost:" & $conf.rpcPort]) rpcServer = newRpcSocketServer(["127.0.0.1:" & $conf.rpcPort])
client = newRpcSocketClient() client = newRpcSocketClient()
txPool = TxPoolRef.new(com, conf.engineSigner) txPool = TxPoolRef.new(com, conf.engineSigner)
sealingEngine = SealingEngineRef.new( sealingEngine = SealingEngineRef.new(
@ -104,7 +104,7 @@ proc runTest(steps: Steps) =
sealingEngine.start() sealingEngine.start()
rpcServer.start() rpcServer.start()
waitFor client.connect("localhost", conf.rpcPort) waitFor client.connect("127.0.0.1", conf.rpcPort)
suite "Engine API tests": suite "Engine API tests":
for i, step in steps.list: for i, step in steps.list:

View File

@ -170,7 +170,7 @@ proc rpcMain*() =
# Create Ethereum RPCs # Create Ethereum RPCs
let RPC_PORT = 8545 let RPC_PORT = 8545
var var
rpcServer = newRpcSocketServer(["localhost:" & $RPC_PORT]) rpcServer = newRpcSocketServer(["127.0.0.1:" & $RPC_PORT])
client = newRpcSocketClient() client = newRpcSocketClient()
txPool = TxPoolRef.new(com, conf.engineSigner) txPool = TxPoolRef.new(com, conf.engineSigner)
@ -179,7 +179,7 @@ proc rpcMain*() =
# Begin tests # Begin tests
rpcServer.start() rpcServer.start()
waitFor client.connect("localhost", Port(RPC_PORT)) waitFor client.connect("127.0.0.1", Port(RPC_PORT))
# TODO: add more tests here # TODO: add more tests here
test "web3_clientVersion": test "web3_clientVersion":