Skip to content

refactor: break up transformer and rpc package logic into smaller func and add unit tests#1313

Merged
Monika-Bitfly merged 1 commit intostagingfrom
m/refactor-indexing-v2
Feb 12, 2025
Merged

refactor: break up transformer and rpc package logic into smaller func and add unit tests#1313
Monika-Bitfly merged 1 commit intostagingfrom
m/refactor-indexing-v2

Conversation

@Monika-Bitfly
Copy link
Contributor

Changes:

  • Refactored transformer.go functions in the /executionlayer package by breaking them into smaller, more readable functions
  • Simplified erigon.go and geth.go functions in the /rpc package by splitting them into smaller functions and introduced utils.go to share common functionality between them
  • Added unit tests utils_test.go and erigon_test.go in the /rpc package
  • Added unit tests transformer_test.go in the /executionlayer package

@Monika-Bitfly Monika-Bitfly marked this pull request as ready for review February 5, 2025 18:55
Copy link
Contributor

@Tangui-Bitfly Tangui-Bitfly left a comment

Choose a reason for hiding this comment

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

There is a lot of good things in that pr but I'm wondering if some changes go maybe too far (too many little functions, too many tests that test not exported func without direct link to usage, ...) and will be a burden in the long run.


// TestGetMaxFeePerBlobGas tests the getMaxFeePerBlobGas function
// which extracts the max fee per blob gas from a transaction
func TestGetMaxFeePerBlobGas(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to test each individual function like that ? Too much tests is like too much codes, harder to maintain, more complex and prone to brake.
I mean what this test is really testing ? Following this logic we could do a test for each field of a block. IMO it's better to create one test where we test each field all together.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 11, 2025

Deploying beaconchain with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0113175
Status: ✅  Deploy successful!
Preview URL: https://466875fb.beaconchain.pages.dev
Branch Preview URL: https://m-refactor-indexing-v2.beaconchain.pages.dev

View logs

Copy link
Contributor

@mccreedy-bitfly mccreedy-bitfly left a comment

Choose a reason for hiding this comment

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

lgtm, definitely a measurable improvement in readability of the code and testing.

@Monika-Bitfly Monika-Bitfly merged commit 21b0586 into staging Feb 12, 2025
3 checks passed
@Monika-Bitfly Monika-Bitfly deleted the m/refactor-indexing-v2 branch February 12, 2025 16:09
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.

3 participants