-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(p2p): test bench scaffold #11758
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
66d27dd
exp: flood publishing disabled
Maddiaa0 216c045
exp: add 64 validators yaml
Maddiaa0 27d7733
chore: alter gossip params
Maddiaa0 cd041cc
fix: mplex fix
Maddiaa0 5a270a8
tmp
Maddiaa0 4bf1c24
worker test
Maddiaa0 61d2b17
tmp score changes
Maddiaa0 dc109ea
misc
Maddiaa0 ee936ab
chore: log source peer id
Maddiaa0 59e4572
feat: testbench
Maddiaa0 fd35372
clean spartan changes
Maddiaa0 d45bebd
chore: add some testing env vars
Maddiaa0 e21be41
fix: config
Maddiaa0 bfcfd8e
chore: add readme
Maddiaa0 329a470
fix: update test helpers name
Maddiaa0 4935ac8
fix: include flood publish env var
Maddiaa0 44a9012
fix: reset libp2p parameter changes
Maddiaa0 c6fe12c
fix: set min peer count
Maddiaa0 9b5bc3d
fix: rm 64
Maddiaa0 012b5f6
fix: paths
Maddiaa0 f883701
Merge branch 'master' into md/worker-test
Maddiaa0 2d3ac41
fix: review comments
Maddiaa0 09956da
Merge branch 'master' into md/worker-test
Maddiaa0 f74e18d
fix: merge fix
Maddiaa0 fd03b2a
fmt
Maddiaa0 53d7645
fix: reqresp dirty merge
Maddiaa0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -11,14 +11,23 @@ import { getLogLevelFromFilters, parseEnv } from './log-filters.js'; | |
import { type LogLevel } from './log-levels.js'; | ||
import { type LogData, type LogFn } from './log_fn.js'; | ||
|
||
export function createLogger(module: string): Logger { | ||
export function createLogger(module: string, fixedTerms = {}): Logger { | ||
module = logNameHandlers.reduce((moduleName, handler) => handler(moduleName), module.replace(/^aztec:/, '')); | ||
const pinoLogger = logger.child({ module }, { level: getLogLevelFromFilters(logFilters, module) }); | ||
|
||
// Only perform copy of data if fixed terms are provided | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used in the libp2p logger to enable tagging the sourcePeer to all messages. If fixed terms are not set, then we should skip doing the extra allocation in the ternary operation below |
||
const hasFixedTerms = Object.keys(fixedTerms).length > 0; | ||
|
||
// We check manually for isLevelEnabled to avoid calling processLogData unnecessarily. | ||
// Note that isLevelEnabled is missing from the browser version of pino. | ||
const logFn = (level: LogLevel, msg: string, data?: unknown) => | ||
isLevelEnabled(pinoLogger, level) && pinoLogger[level](processLogData((data as LogData) ?? {}), msg); | ||
isLevelEnabled(pinoLogger, level) && | ||
pinoLogger[level]( | ||
hasFixedTerms | ||
? processLogData({ ...fixedTerms, ...(data ?? {}) } as LogData) | ||
: processLogData((data as LogData) ?? {}), | ||
msg, | ||
); | ||
|
||
return { | ||
silent: () => {}, | ||
|
@@ -149,7 +158,10 @@ function makeLogger() { | |
if (!isNode) { | ||
// We are on the browser. | ||
return pino({ ...pinoOpts, browser: { asObject: false } }); | ||
} else if (process.env.JEST_WORKER_ID) { | ||
} | ||
// If running in a child process then cancel this if statement section by uncommenting below | ||
// else if (false) { | ||
else if (process.env.JEST_WORKER_ID) { | ||
// We are on jest, so we need sync logging and stream to stderr. | ||
// We expect jest/setup.mjs to kick in later and replace set up a pretty logger, | ||
// but if for some reason it doesn't, at least we're covered with a default logger. | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interface added to make mocking simpler in the mock p2p client