-
Notifications
You must be signed in to change notification settings - Fork 299
feat(entropy-sdk): add MockEntropy contract for local testing #3121
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
- Implements IEntropyV2 interface with two-step request/reveal pattern - requestV2() stores request and returns sequence number - mockReveal() allows manual callback triggering with custom random numbers - Enables testing different interleavings of requests and reveals - Includes comprehensive test suite demonstrating usage patterns - Simplifies testing by removing fee requirements and commitment validation Co-Authored-By: Jayant <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
defaultProvider = _defaultProvider; | ||
|
||
providers[_defaultProvider].sequenceNumber = 1; | ||
providers[_defaultProvider].feeInWei = 0; |
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.
please initialize this to 1
- Set feeInWei to 1 in MockEntropy constructor and _requestV2 - Update package.json version from 2.0.0 to 2.1.0 - Update test assertion to expect feeInWei = 1 Co-Authored-By: Jayant <[email protected]>
Summary
Adds
MockEntropy
contract implementing theIEntropyV2
interface to enable local testing of entropy-dependent contracts. The mock supports a two-phase request/reveal pattern where developers can control the timing and values of random number callbacks.Rationale
Developers need a way to test entropy-based contracts locally without depending on actual entropy providers. The key requirement was enabling testing of different interleavings - developers can request multiple random numbers and then reveal them in any order with custom values.
Two-phase testing pattern:
requestV2()
→ returns sequence number, stores requestmockReveal(provider, sequenceNumber, customRandomBytes)
→ triggers callback with developer-specified random valueThis allows testing scenarios like request A, request B, reveal B first, then reveal A with different random values.
Key Implementation Details
feeInWei
initialized to 1 in provider info, butgetFeeV2()
methods return 0 for testing simplicity_entropyCallback
Requested
andRevealed
events consistent with real Entropy contractHow has this been tested?
Test scenarios include:
Human Review Checklist
IEntropyV2
methods are properly implementedfeeInWei = 1
andgetFeeV2() = 0
Link to Devin run: https://app.devin.ai/sessions/0d7e089bd7eb4ef5bd60d3baff368b69
Requested by: Jayant ([email protected])
Package version bumped:
@pythnetwork/entropy-sdk-solidity
from 2.0.0 → 2.1.0