Skip to content

Refactor Tests #155

@n8mgr

Description

@n8mgr

When writing tests it’s important to focus on testing the smallest, most isolated piece of functionality you can. This keeps tests focused and makes debugging future regressions easier.

Take the sqlite package as an example. The goal for the tests in this package should be to test how SQLite queries work and interact. Using TestScan as an example: it spins up a whole explorer node and brings in a chain manager, syncer, and all the other unrelated dependencies. Instead, aim to mock the specific database state needed for each test. It can be annoying and take more effort to set up, but it keeps your tests clean and focused. The goal is to test SQL interactions -- not the whole scan process.

If you want to test that scanning is working as expected, that should happen where the scanning code lives -- in the explorer package. The goal of tests isn’t just to say "this works," it's also to make breaking logic changes easier to detect. That way we've got multiple levels of validation that scanning is working as expected.

There are exceptions, but this is a good guidepost to follow.

Glancing through the code, I would recommend creating sub-issues and doing this piece by piece.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions