Skip to content

feat: print logs of failed test when error is thrown in bouncer test.#6071

Merged
dandanlen merged 6 commits intomainfrom
feat/print-error-logs-in-bouncer-tests
Aug 29, 2025
Merged

feat: print logs of failed test when error is thrown in bouncer test.#6071
dandanlen merged 6 commits intomainfrom
feat/print-error-logs-in-bouncer-tests

Conversation

@MxmUrw
Copy link
Contributor

@MxmUrw MxmUrw commented Aug 27, 2025

Pull Request

Stores all logs of a logger in a custom logStorage attribute. If a test fails, we can print out all logs that this logger accumulated, giving more context into the reason for failure.

Example output:

...

   ↓ ConcurrentTests > BrokerLevelScreening
   ↓ ConcurrentTests > VaultSwaps
   × ConcurrentTests > SpecialBitcoinSwaps 23322ms
     → Error: something happened!

history:
[2025-08-27T08:13:10.736Z] INFO: 🧪 Starting test SpecialBitcoinSwaps
[2025-08-27T08:13:10.744Z] TRACE: Observing event swapping:SwapDepositAddressReady
[2025-08-27T08:13:11.080Z] TRACE: Found event 1 swapping:SwapDepositAddressReady events in block 28934
[2025-08-27T08:13:13.901Z] DEBUG: $Deposit address: bcrt1p8henkz3pfgks3r0w9g0r7hqcx82vagg2z2ul59heqtnr8am5g5gsm60m2e
[2025-08-27T08:13:13.901Z] DEBUG: Destination address is: 0x7b8e81adf4352e31cf52f49772fb4db1b49357f6 Channel ID is: 39
[2025-08-27T08:13:14.085Z] DEBUG: Sending bitcoin tx with multiple outputs: [object Object]
[2025-08-27T08:13:14.085Z] TRACE: Observing event bitcoinIngressEgress:DepositFinalised
[2025-08-27T08:13:14.085Z] TRACE: Observing event bitcoinIngressEgress:DepositFinalised
[2025-08-27T08:13:14.085Z] TRACE: Observing event bitcoinIngressEgress:DepositFinalised
[2025-08-27T08:13:14.085Z] TRACE: Observing event bitcoinIngressEgress:DepositFinalised
[2025-08-27T08:13:34.052Z] TRACE: Found event 1 bitcoinIngressEgress:DepositFinalised events in block 28957
[2025-08-27T08:13:34.052Z] TRACE: Found event 1 bitcoinIngressEgress:DepositFinalised events in block 28957
[2025-08-27T08:13:34.052Z] TRACE: Found event 1 bitcoinIngressEgress:DepositFinalised events in block 28957
[2025-08-27T08:13:34.053Z] TRACE: Found event 1 bitcoinIngressEgress:DepositFinalised events in block 28957
[2025-08-27T08:13:34.053Z] DEBUG: Deposit of 50,000,000 finalised for channel 39
[2025-08-27T08:13:34.053Z] DEBUG: Deposit of 30,000,000 finalised for channel 39
[2025-08-27T08:13:34.053Z] DEBUG: Deposit of 80,000,000 finalised for channel 39
[2025-08-27T08:13:34.053Z] DEBUG: Deposit of 1,000,000 finalised for channel 39

   ↓ ConcurrentTests > DelegateFlip
   ↓ ConcurrentTests > CheckSolEventAccountsClosure
...

@coderabbitai
Copy link

coderabbitai bot commented Aug 27, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbit review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/print-error-logs-in-bouncer-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@MxmUrw MxmUrw force-pushed the feat/print-error-logs-in-bouncer-tests branch from 3494d9d to 86b3f26 Compare August 27, 2025 08:21
@MxmUrw MxmUrw marked this pull request as ready for review August 27, 2025 08:22
@MxmUrw MxmUrw requested review from albert-llimos and dandanlen and removed request for martin-chainflip August 27, 2025 08:22
@codecov
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment on lines +49 to +52
const testLogFile = getTestLogFile(this);
if (!existsSync(dirname(testLogFile))) {
mkdirSync(dirname(testLogFile), { recursive: true });
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking in this file and saw:

  pino.multistream([
    { stream: prettyConsoleTransport, level: process.env.BOUNCER_LOG_LEVEL ?? 'info' },
    { stream: logFileDestination, level: 'trace' },
  ]),

Maybe there's a way to do what we want using pino? Something like this:

  pino.multistream([
    { stream: prettyConsoleTransport, level: process.env.BOUNCER_LOG_LEVEL ?? 'info' },
    { stream: globalLogFileDestination, level: 'debug' },
    { stream: testLogFileDestination, level: 'trace' },
  ]),

Basically, I wonder if we need to define a shared 'globalLogger' at all - maybe we can just instantiate a logger for each test that logs to some common 'globalDestination' and to a test-specific file...

Copy link
Contributor Author

@MxmUrw MxmUrw Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't see an obvious way to do that. Here's someone who tried to do something similar, and his solution doesn't really sound easier in terms of implementation complexity. pinojs/pino#2104

EDIT:

Basically, I wonder if we need to define a shared 'globalLogger' at all - maybe we can just instantiate a logger for each test that logs to some common 'globalDestination' and to a test-specific file...

Hmm, I see what you mean. I'll think about it... But I think it will again involve more changes?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, let's avoid going down the pino rabbit hole and leave it as is.

@MxmUrw MxmUrw force-pushed the feat/print-error-logs-in-bouncer-tests branch from 37160dc to bed494c Compare August 27, 2025 12:04
@MxmUrw MxmUrw added this pull request to the merge queue Aug 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 28, 2025
@MxmUrw MxmUrw added this pull request to the merge queue Aug 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 28, 2025
@dandanlen dandanlen added this pull request to the merge queue Aug 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 28, 2025
@MxmUrw MxmUrw added this pull request to the merge queue Aug 29, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 29, 2025
@dandanlen dandanlen added this pull request to the merge queue Aug 29, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 29, 2025
…#6071)

* feat: print logs of failed test when error is thrown in bouncer test.

* refactor: use files instead of local storage to store test logs.

* refactor: use files instead of storage to log test-specific logs to.

* fix: log in observe event only every 5 blocks.

* chore: don't write test-logs for 'trace' level.

* fix: handle test timeout ourselves.
Merged via the queue into main with commit 307ac19 Aug 29, 2025
54 checks passed
@dandanlen dandanlen deleted the feat/print-error-logs-in-bouncer-tests branch August 29, 2025 17:19
dandanlen pushed a commit that referenced this pull request Sep 5, 2025
…#6071)

* feat: print logs of failed test when error is thrown in bouncer test.

* refactor: use files instead of local storage to store test logs.

* refactor: use files instead of storage to log test-specific logs to.

* fix: log in observe event only every 5 blocks.

* chore: don't write test-logs for 'trace' level.

* fix: handle test timeout ourselves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants