-
Notifications
You must be signed in to change notification settings - Fork 39
arkd-wallet: unit tests outpointLocker #738
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
Conversation
WalkthroughRemoved the Changes
Sequence Diagram(s)sequenceDiagram
participant KM as KeyManager
participant HD as hdkeychain.ExtendedKey
rect rgba(233,246,255,0.6)
note over KM: newKeyManager()
KM->>HD: deriveForfeitPrvkey(xpub)
note over KM,HD: network parameter removed
HD-->>KM: btcec.PrivateKey / error
end
sequenceDiagram
participant C as Caller
participant OL as OutpointLocker
rect rgba(240,255,240,0.6)
note over C: Lock(outpoints)
C->>OL: Lock(_, outpoints, expiry)
alt outpoints empty
OL-->>C: nil
else
alt any outpoint already locked
OL-->>C: error (duplicate lock)
else
loop for each outpoint
OL->>OL: add/refresh lock entry with expiry
end
OL-->>C: nil
end
end
end
note over C,OL: Get returns only non-expired entries
C->>OL: Get(_)
OL-->>C: set of active locked outpoints
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
pkg/arkd-wallet/core/application/wallet/key_manager.go
(2 hunks)pkg/arkd-wallet/core/application/wallet/outpoint_locker.go
(2 hunks)pkg/arkd-wallet/core/application/wallet/outpoint_locker_test.go
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: unit tests
- GitHub Check: integration tests
pkg/arkd-wallet/core/application/wallet/outpoint_locker_test.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pkg/arkd-wallet/core/application/wallet/outpoint_locker.go
(2 hunks)pkg/arkd-wallet/core/application/wallet/outpoint_locker_test.go
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/arkd-wallet/core/application/wallet/outpoint_locker_test.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: integration tests
- GitHub Check: unit tests
🔇 Additional comments (3)
pkg/arkd-wallet/core/application/wallet/outpoint_locker.go (3)
5-5
: LGTM: fmt import added.The fmt package import is necessary for the error message formatting on line 39.
26-29
: LGTM: Good defensive programming.The signature change using
_
for the unused context parameter is idiomatic Go, and the early return for empty input is an efficient guard clause that avoids unnecessary mutex acquisition.
48-48
: LGTM: Consistent unused-parameter pattern.The underscore for the unused context parameter matches the pattern established in the
lock
method and is idiomatic Go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/arkd-wallet/core/application/wallet/outpoint_locker.go
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: integration tests
- GitHub Check: unit tests
🔇 Additional comments (3)
pkg/arkd-wallet/core/application/wallet/outpoint_locker.go (3)
5-5
: LGTM!The
fmt
import is correctly added for the error message formatting.
27-29
: LGTM!The early return for empty input is a sensible optimization that avoids unnecessary lock acquisition.
55-55
: LGTM!Using
_
for the unused context parameter is appropriate and follows Go conventions.
This PR adds unit tests to our
outpointLocker
struct.@altafan please review
Summary by CodeRabbit
Refactor
Tests
Bug Fixes