Add tests#110
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive integration tests for the Ethscriptions system, including creation and transfer scenarios, along with test infrastructure to support these tests.
- Adds a comprehensive test helper module with DSL for creating mock L1 blocks and transactions
- Implements integration tests for ethscription creation via input and events (ESIP-3)
- Adds integration tests for various transfer mechanisms (input, events, ESIP-1, ESIP-2, ESIP-5)
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| spec/support/ethscriptions_test_helper.rb | Test helper module providing DSL and mock infrastructure for L1/L2 testing |
| spec/integration/ethscriptions_creation_spec.rb | Integration tests for ethscription creation scenarios |
| spec/integration/ethscription_transfers_spec.rb | Integration tests for ethscription transfer scenarios |
| app/services/eth_block_importer.rb | Minor change to expose prefetcher attribute for testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| original_methods = {} | ||
|
|
||
| # Stub the SysConfig methods and store originals | ||
| %w[esip1_enabled? esip2_enabled? esip3_enabled? esip5_enabled? esip7_enabled?].each do |method| |
There was a problem hiding this comment.
Using string array with %w[] for method names makes this code brittle to refactoring. Consider defining these method names as constants or using symbols to make them easier to find and maintain.
| end | ||
|
|
||
| def build_l1_transaction(descriptor, index) | ||
| # binding.irb |
There was a problem hiding this comment.
Remove debugging code (binding.irb) that was left in the codebase.
| # binding.irb |
| mock_ethereum_client = instance_double(EthRpcClient, | ||
| get_block_number: block_number, | ||
| get_block: block_data, | ||
| get_transaction_receipts: receipts_data | ||
| ) |
There was a problem hiding this comment.
The variable mock_ethereum_client is declared twice (lines 519 and 521), with the first declaration being unused. Remove the duplicate declaration on line 519.
| end | ||
|
|
||
| # Convert hex strings to integers where appropriate | ||
| %w[blockNumber gasUsed cumulativeGasUsed effectiveGasPrice status transactionIndex nonce value gas depositNonce mint depositReceiptVersion gasPrice].each do |key| |
There was a problem hiding this comment.
This hardcoded list of field names for hex conversion is brittle and difficult to maintain. Consider defining these as a constant or using a more systematic approach to identify hex fields.
| ] | ||
| ) | ||
| ]) | ||
| # binding.irb |
There was a problem hiding this comment.
Remove debugging code (binding.irb) that was left in the codebase.
| # binding.irb |
| it "transfers via event (happy path)" do | ||
| # Setup: create ethscription | ||
| id1 = create_test_ethscription(creator: alice, to: alice, content: "Test content2a") | ||
| # binding.irb |
There was a problem hiding this comment.
Remove debugging code (binding.irb) that was left in the codebase.
| # binding.irb |
No description provided.