Skip to content
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

refactor: remove btc deposit fee v1 and improve unit tests #2899

Merged
merged 11 commits into from
Sep 23, 2024

Conversation

ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Sep 19, 2024

Description

  • remove CalcDepositorFeeV1
  • improved related unit tests by migration to mockery
  • Unified bitcoin confirmation check using IsBlockConfirmed; Both WatchInbound and WatchInboundTracker tickers use it.

Closes: #2766

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features

    • Introduced a method to check if a Bitcoin block is confirmed.
    • Added a new data structure for handling incoming Bitcoin transactions, enhancing transaction data clarity.
    • Enhanced event structure to include depositor fee information.
  • Refactor

    • Simplified transaction fee calculation by replacing the previous method with a more efficient version.
    • Streamlined mock Bitcoin RPC client implementation for improved testing.
  • Bug Fixes

    • Updated test cases to ensure accurate handling of Bitcoin transaction fees and improved error handling.
  • Documentation

    • Added a new JSON file representing a Bitcoin transaction structure for better understanding of transaction components.

Copy link
Contributor

coderabbitai bot commented Sep 19, 2024

Important

Review skipped

Auto incremental 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 @coderabbitai review command.

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

Walkthrough

Walkthrough

The pull request introduces several significant changes across multiple files, primarily focusing on the simplification and refactoring of Bitcoin transaction handling. Key modifications include the removal of the depositorFee variable, the introduction of new methods for block confirmation, and a complete overhaul of the CalcDepositorFee function. Additionally, a new data structure, BTCInboundEvent, is implemented for better organization of incoming transaction data, while test files are updated for improved clarity and maintainability.

Changes

Files Change Summary
e2e/runner/bitcoin.go Removed depositorFee variable from SendToTSSFromDeployerWithMemo function, affecting transaction processing.
zetaclient/chains/base/observer.go Added IsBlockConfirmed method to Observer struct to check block confirmation status.
zetaclient/chains/bitcoin/fee.go Refactored CalcDepositorFee to CalcDepositorFeeV2, changing input parameters from block to transaction results.
zetaclient/chains/bitcoin/observer/inbound.go Introduced BTCInboundEvent struct for incoming Bitcoin transactions and updated related functions to utilize this new structure.
zetaclient/chains/bitcoin/observer/inbound_test.go Removed createRPCClientAndLoadTx and replaced it with testrpc.CreateBTCRPCAndLoadTx, updating tests accordingly.
zetaclient/chains/bitcoin/observer/observer.go Removed BTCInboundEvent struct and GetSenderAddressByVin function, indicating a refactor in transaction handling.
zetaclient/chains/bitcoin/observer/observer_test.go Updated mock client usage to improve test clarity and maintainability.
zetaclient/chains/bitcoin/observer/outbound_test.go Modified MockBTCObserverMainnet to use a more versatile mock client for better testing fidelity.
zetaclient/chains/bitcoin/observer/witness.go Added DepositorFee field to BTCInboundEvent struct to enhance transaction data representation.
zetaclient/chains/bitcoin/rpc/rpc_live_test.go Removed a floating-point parameter and renamed LiveTest_CalcDepositorFeeV2 to LiveTest_CalcDepositorFee.
zetaclient/testdata/btc/... Added new JSON file representing a Bitcoin transaction structure.
zetaclient/testutils/mocks/btc_rpc.go Overhauled mock implementation for BTCRPCClient, enhancing functionality and usability in tests.
zetaclient/testutils/testrpc/rpc_btc.go Introduced CreateBTCRPCAndLoadTx function for loading raw Bitcoin transactions into a mock RPC client for testing.

Sequence Diagram(s)

sequenceDiagram
    participant Observer
    participant BTCInboundEvent
    participant TransactionHandler

    Observer->>TransactionHandler: ObserveInbound()
    TransactionHandler->>BTCInboundEvent: Create new event
    TransactionHandler->>Observer: Return BTCInboundEvent
Loading

Assessment against linked issues

Objective Addressed Explanation
Clean up the usage of CalcDepositorFeeV1 once upgrade height reached (2766)

Possibly related issues

Possibly related PRs

Suggested labels

breaking:cli, no-changelog, UPGRADE_TESTS


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai 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:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

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

Documentation and Community

  • 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.

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 69.73684% with 23 lines in your changes missing coverage. Please review.

Project coverage is 67.27%. Comparing base (d14b200) to head (49f3fef).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/bitcoin/observer/inbound.go 46.51% 23 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2899      +/-   ##
===========================================
+ Coverage    67.20%   67.27%   +0.06%     
===========================================
  Files          380      380              
  Lines        21170    21175       +5     
===========================================
+ Hits         14227    14245      +18     
+ Misses        6276     6264      -12     
+ Partials       667      666       -1     
Files with missing lines Coverage Δ
zetaclient/chains/base/observer.go 87.19% <100.00%> (+0.25%) ⬆️
zetaclient/chains/bitcoin/fee.go 41.52% <ø> (+3.54%) ⬆️
zetaclient/chains/bitcoin/observer/observer.go 32.63% <ø> (-5.68%) ⬇️
zetaclient/chains/bitcoin/observer/witness.go 71.73% <100.00%> (+0.95%) ⬆️
zetaclient/chains/bitcoin/tx_script.go 90.12% <100.00%> (+1.00%) ⬆️
zetaclient/testutils/testdata.go 87.41% <100.00%> (+0.45%) ⬆️
zetaclient/chains/bitcoin/observer/inbound.go 18.11% <46.51%> (+3.98%) ⬆️

Copy link

!!!WARNING!!!
nosec detected in the following files: zetaclient/chains/bitcoin/observer/inbound.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Sep 19, 2024
@ws4charlie ws4charlie marked this pull request as ready for review September 19, 2024 17:57
@ws4charlie ws4charlie changed the title chore: remove btc deposit fee v1 and unit tests chore: remove btc deposit fee v1 and improve unit tests Sep 19, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Outside diff range and nitpick comments (4)
zetaclient/chains/base/observer.go (1)

232-235: Add test coverage for IsBlockConfirmed.

The static analysis tool reports that this new function is not covered by tests. To maintain a high-quality codebase and prevent potential bugs, it's crucial to add unit tests that verify the correctness of this function.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 232-235: zetaclient/chains/base/observer.go#L232-L235
Added lines #L232 - L235 were not covered by tests

zetaclient/chains/bitcoin/observer/witness_test.go (1)

Line range hint 97-97: Use field-by-field comparison for structs containing floating-point fields

Comparing structs with floating-point fields using require.Equal may lead to test failures due to precision discrepancies. It's advisable to compare each field individually, using require.InDelta for floating-point numbers to account for minor differences.

Suggestion:

Replace:

require.Equal(t, eventExpected, event)

With:

require.Equal(t, eventExpected.FromAddress, event.FromAddress)
require.Equal(t, eventExpected.ToAddress, event.ToAddress)
require.InDelta(t, eventExpected.Value, event.Value, 1e-8)
require.Equal(t, eventExpected.DepositorFee, event.DepositorFee)
require.Equal(t, eventExpected.MemoBytes, event.MemoBytes)
require.Equal(t, eventExpected.BlockNumber, event.BlockNumber)
require.Equal(t, eventExpected.TxHash, event.TxHash)

This ensures that floating-point comparisons for Value are precise within an acceptable delta, improving test reliability.

Also applies to: 136-136, 164-164

zetaclient/testutils/mocks/btc_rpc.go (1)

24-547: Avoid Using Underscores in Receiver Names for Idiomatic Go Code

The receiver for the methods is named _m, which includes an underscore prefix. In Go, it's idiomatic to use concise receiver names without underscores. Consider renaming the receiver to m or client to improve code readability and adhere to Go conventions.

Apply this diff to rename the receiver variable:

-func (_m *BTCRPCClient) CreateWallet(name string, opts ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error) {
+func (m *BTCRPCClient) CreateWallet(name string, opts ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error) {

Repeat this change for all methods to ensure consistency.

zetaclient/chains/bitcoin/observer/inbound.go (1)

Line range hint 168-182: Enhance error handling to process all events reliably

Currently, if PostVoteInbound returns an error for an event, the function returns immediately, and subsequent events are not processed. This could lead to delays in handling other valid events. It would be more robust to log the error for the failed event and continue processing the remaining events.

Here's a suggested modification:

 for _, event := range events {
     msg := ob.GetInboundVoteMessageFromBtcEvent(event)
     if msg != nil {
         zetaHash, ballot, err := zetaCoreClient.PostVoteInbound(
             ctx,
             zetacore.PostVoteInboundGasLimit,
             zetacore.PostVoteInboundExecutionGasLimit,
             msg,
         )
         if err != nil {
             ob.logger.Inbound.Error().
                 Err(err).
-                Msgf("observeInboundBTC: error posting to zetacore for tx %s", event.TxHash)
-            return err // we have to re-scan this block next time
+                Msgf("observeInboundBTC: error posting to zetacore for tx %s; continuing with next event", event.TxHash)
+            continue // Proceed to the next event
         } else if zetaHash != "" {
             ob.logger.Inbound.Info().Msgf("observeInboundBTC: PostVoteInbound zeta tx hash: %s inbound %s ballot %s fee %v",
                 zetaHash, event.TxHash, ballot, event.DepositorFee)
         }
     }
 }

This change ensures that all events are attempted, improving the resilience of the observer.

Tools
GitHub Check: codecov/patch

[warning] 180-180: zetaclient/chains/bitcoin/observer/inbound.go#L180
Added line #L180 was not covered by tests


[warning] 184-184: zetaclient/chains/bitcoin/observer/inbound.go#L184
Added line #L184 was not covered by tests

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9b704a5 and e38ca8e.

Files selected for processing (14)
  • e2e/runner/bitcoin.go (0 hunks)
  • zetaclient/chains/base/observer.go (1 hunks)
  • zetaclient/chains/bitcoin/fee.go (1 hunks)
  • zetaclient/chains/bitcoin/observer/inbound.go (8 hunks)
  • zetaclient/chains/bitcoin/observer/inbound_test.go (22 hunks)
  • zetaclient/chains/bitcoin/observer/observer.go (0 hunks)
  • zetaclient/chains/bitcoin/observer/observer_test.go (8 hunks)
  • zetaclient/chains/bitcoin/observer/outbound_test.go (1 hunks)
  • zetaclient/chains/bitcoin/observer/witness.go (1 hunks)
  • zetaclient/chains/bitcoin/observer/witness_test.go (8 hunks)
  • zetaclient/chains/bitcoin/rpc/rpc_live_test.go (2 hunks)
  • zetaclient/testdata/btc/chain_8332_msgtx_847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa.json (1 hunks)
  • zetaclient/testutils/mocks/btc_rpc.go (1 hunks)
  • zetaclient/testutils/testrpc/rpc_btc.go (2 hunks)
Files not reviewed due to no reviewable changes (2)
  • e2e/runner/bitcoin.go
  • zetaclient/chains/bitcoin/observer/observer.go
Files skipped from review due to trivial changes (1)
  • zetaclient/chains/bitcoin/rpc/rpc_live_test.go
Additional context used
Path-based instructions (10)
zetaclient/chains/base/observer.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/chains/bitcoin/fee.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/chains/bitcoin/observer/inbound.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/chains/bitcoin/observer/inbound_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/chains/bitcoin/observer/observer_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/chains/bitcoin/observer/outbound_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/chains/bitcoin/observer/witness.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/chains/bitcoin/observer/witness_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/testutils/mocks/btc_rpc.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/testutils/testrpc/rpc_btc.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

GitHub Check: codecov/patch
zetaclient/chains/base/observer.go

[warning] 232-235: zetaclient/chains/base/observer.go#L232-L235
Added lines #L232 - L235 were not covered by tests

zetaclient/chains/bitcoin/observer/inbound.go

[warning] 131-132: zetaclient/chains/bitcoin/observer/inbound.go#L131-L132
Added lines #L131 - L132 were not covered by tests


[warning] 143-144: zetaclient/chains/bitcoin/observer/inbound.go#L143-L144
Added lines #L143 - L144 were not covered by tests


[warning] 152-152: zetaclient/chains/bitcoin/observer/inbound.go#L152
Added line #L152 was not covered by tests


[warning] 168-169: zetaclient/chains/bitcoin/observer/inbound.go#L168-L169
Added lines #L168 - L169 were not covered by tests


[warning] 180-180: zetaclient/chains/bitcoin/observer/inbound.go#L180
Added line #L180 was not covered by tests


[warning] 184-184: zetaclient/chains/bitcoin/observer/inbound.go#L184
Added line #L184 was not covered by tests


[warning] 294-296: zetaclient/chains/bitcoin/observer/inbound.go#L294-L296
Added lines #L294 - L296 were not covered by tests


[warning] 337-337: zetaclient/chains/bitcoin/observer/inbound.go#L337
Added line #L337 was not covered by tests


[warning] 355-355: zetaclient/chains/bitcoin/observer/inbound.go#L355
Added line #L355 was not covered by tests


[warning] 362-364: zetaclient/chains/bitcoin/observer/inbound.go#L362-L364
Added lines #L362 - L364 were not covered by tests


[warning] 367-367: zetaclient/chains/bitcoin/observer/inbound.go#L367
Added line #L367 was not covered by tests


[warning] 373-374: zetaclient/chains/bitcoin/observer/inbound.go#L373-L374
Added lines #L373 - L374 were not covered by tests


[warning] 378-378: zetaclient/chains/bitcoin/observer/inbound.go#L378
Added line #L378 was not covered by tests

Additional comments not posted (17)
zetaclient/testdata/btc/chain_8332_msgtx_847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa.json (1)

1-27: Approve the addition of the Bitcoin transaction test data file.

The new JSON file provides a valid Bitcoin transaction structure for testing purposes. It includes essential components such as version, inputs, outputs, and lock time, making it a suitable test case for validating transaction handling in the codebase.

The file is appropriately placed in the testdata directory, ensuring it does not interfere with the production code.

zetaclient/testutils/testrpc/rpc_btc.go (1)

61-80: LGTM!

The CreateBTCRPCAndLoadTx function is a well-structured and useful addition to the testrpc package. It enhances the testing capabilities by allowing for the simulation of Bitcoin RPC interactions with pre-defined transaction data.

The function follows a clear logic flow:

  1. It creates a mock RPC client using the mocks.NewBTCRPCClient function.
  2. For each transaction hash provided, it constructs the file path for the corresponding MsgTx, loads the transaction data using the testutils.LoadObjectFromJSONFile function, and sets up the mock client to return the transaction when queried with its hash.
  3. Finally, it returns the mock RPC client.

The function uses appropriate naming conventions and follows the Go best practices.

zetaclient/chains/bitcoin/observer/witness.go (1)

71-77: LGTM!

The addition of the DepositorFee field to the BTCInboundEvent struct enhances the event's data representation by including the depositor's fee information. The depositorFee parameter is used consistently throughout the function to validate the amount and calculate the actual deposit amount. The changes are logically sound and syntactically correct.

zetaclient/chains/bitcoin/observer/observer_test.go (4)

75-77: LGTM!

The changes made to the MockBTCObserver function improve the testability and clarity of the mock interactions by using a more structured approach with the stretchr/testify/mock package. The initialization of the mock Bitcoin client and setting expectations for the GetBlockCount method call are consistent with the overall refactoring theme of the pull request.


105-108: LGTM!

The changes made to the Test_NewObserver function improve the consistency and clarity of the mock client usage across the test cases by using the new mock client structure. The creation of the mock Bitcoin client with a block height of 100 and setting expectations for the GetBlockCount method call are in line with the overall refactoring theme of the pull request.

Also applies to: 126-126, 134-134, 143-143


208-208: LGTM!

The changes made to the Test_BlockCache function improve the testability and clarity of the mock interactions by using a more structured approach with the stretchr/testify/mock package. The creation of the mock Bitcoin client and setting expectations for various method calls like GetBlockHash, GetBlockHeader, and GetBlockVerboseTx are consistent with the overall refactoring theme of the pull request.

Also applies to: 215-217


254-256: LGTM!

The changes made to the Test_LoadLastBlockScanned function improve the consistency and clarity of the mock client usage across the test cases by using the new mock client structure. The creation of the mock Bitcoin client with a block height of 200 and setting expectations for the GetBlockCount method call are in line with the overall refactoring theme of the pull request.

The additional test case for handling RPC errors, where a mock Bitcoin client that returns an RPC error is attached, enhances the test coverage and ensures proper error handling in the observer.

Also applies to: 288-291, 295-295

zetaclient/chains/base/observer.go (1)

232-235: LGTM!

The IsBlockConfirmed function correctly determines if a given block is confirmed by comparing it against the last observed block and the configured confirmation count. The logic and implementation are accurate.

Tools
GitHub Check: codecov/patch

[warning] 232-235: zetaclient/chains/base/observer.go#L232-L235
Added lines #L232 - L235 were not covered by tests

zetaclient/chains/bitcoin/observer/outbound_test.go (1)

30-32: LGTM!

The updated mock client instantiation using mocks.NewBTCRPCClient(t) and the subsequent configuration of the GetBlockCount method response enhances the test's ability to simulate interactions with the Bitcoin RPC client more accurately. This change improves the test's fidelity and allows for more precise control over the responses during testing.

zetaclient/chains/bitcoin/fee.go (1)

Line range hint 228-245: Implementation of CalcDepositorFee is clear and efficient.

The refactored function accurately calculates the depositor fee based on the transaction fee rate. It properly handles different network parameters, ensures precise fee computations, and includes appropriate error handling.

zetaclient/chains/bitcoin/observer/witness_test.go (6)

8-8: Importing 'github.com/pkg/errors' is appropriate

The "github.com/pkg/errors" package is correctly imported and utilized for error handling within the tests, enhancing the clarity and robustness of error messages.


12-12: Inclusion of 'github.com/stretchr/testify/mock' for mocking

The "github.com/stretchr/testify/mock" package is appropriately imported and used for creating mock objects in your tests, which improves test isolation and reliability.


19-19: Utilization of 'testutils/testrpc' enhances test maintainability

Importing "github.com/zeta-chain/node/zetaclient/testutils/testrpc" streamlines the setup of mock RPC clients, improving test readability and maintainability by reducing boilerplate code.


62-62: Accurate calculation of 'depositorFee' for realistic testing

The depositorFee is correctly calculated using a fee rate of 28 sat/vB multiplied by the outbound gas price multiplier. This provides a more accurate simulation of transaction fees in your tests.


85-85: Refactored mock RPC client setup improves test clarity

Using testrpc.CreateBTCRPCAndLoadTx to create the mock RPC client and load transaction data simplifies the test setup, enhancing code readability and reducing the potential for setup errors.


225-226: Proper mocking of RPC client errors enhances test robustness

By configuring the mock RPC client to return an error on GetRawTransaction, you effectively simulate error conditions, which is crucial for testing error handling logic.

zetaclient/testutils/mocks/btc_rpc.go (1)

24-547: Adoption of testify/mock Improves Test Maintainability and Standardization

The migration from a custom MockBTCRPCClient to an autogenerated mock using testify/mock is a commendable improvement. Utilizing testify/mock standardizes the mocking framework across the codebase, reduces manual coding errors, and leverages a well-supported library. This change enhances the expressiveness and maintainability of your tests, ensuring they are concise and production-grade.

changelog.md Outdated Show resolved Hide resolved
zetaclient/chains/bitcoin/observer/inbound.go Outdated Show resolved Hide resolved
zetaclient/chains/bitcoin/observer/inbound.go Outdated Show resolved Hide resolved
@ws4charlie ws4charlie changed the title chore: remove btc deposit fee v1 and improve unit tests refactor: remove btc deposit fee v1 and improve unit tests Sep 20, 2024
@ws4charlie ws4charlie added this pull request to the merge queue Sep 23, 2024
Merged via the queue into develop with commit 3eba701 Sep 23, 2024
31 checks passed
@ws4charlie ws4charlie deleted the remove-btc-deposit-fee-V1 branch September 23, 2024 02:21
@coderabbitai coderabbitai bot mentioned this pull request Oct 3, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: remove CalcDepositorFeeV1 once the upgrade height DynamicDepositorFeeHeightV2 is reached
4 participants