-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ethereumjs/ethereumjs-monorepo in…
…to ethjs-repl
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { assert, describe, it } from 'vitest' | ||
|
||
import { createClient, createManager, getRPCClient, startRPC } from '../helpers.js' | ||
|
||
const method = 'debug_verbosity' | ||
|
||
const logLevels: { [key: number]: string } = { | ||
0: 'error', | ||
1: 'warn', | ||
2: 'info', | ||
3: 'debug', | ||
} | ||
|
||
describe(method, () => { | ||
it('works', async () => { | ||
const manager = createManager(await createClient({ opened: true, noPeers: true })) | ||
const rpc = getRPCClient(startRPC(manager.getMethods())) | ||
const client = manager['_client'] | ||
|
||
let res | ||
|
||
// lowest level; e.g. only show errors | ||
const levelError = 0 | ||
res = await rpc.request(method, [levelError]) | ||
assert.equal(res.result, 'level: error', 'verbosity level successfully lowered') | ||
assert.equal(client.config.logger.level, logLevels[levelError]) | ||
|
||
// highest level; e.g. be very verbose and show even debug logs | ||
const levelDebug = 3 | ||
res = await rpc.request(method, [levelDebug]) | ||
assert.equal(res.result, 'level: debug', 'verbosity level successfully increased') | ||
assert.equal(client.config.logger.level, logLevels[levelDebug]) | ||
}) | ||
}) |