-
Notifications
You must be signed in to change notification settings - Fork 201
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
test(evm): more e2e test contracts for edge cases #1901
Conversation
WalkthroughThe recent updates enhance the EVM testing suite by adding new end-to-end test contracts and cases, particularly focusing on edge scenarios and smart contract interactions involving ERC-20 tokens. Key changes include the introduction of new Solidity contracts for handling infinite loops and token transfers, updates to configuration files for better test management, and the inclusion of comprehensive test cases to validate these functionalities. Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant EVM
participant Contract as Smart Contract
User->>Contract: Call sendViaTransfer()
Contract->>EVM: Transfer Nibi
EVM-->>Contract: Confirm transfer
Contract-->>User: Transfer successful
User->>Contract: Call forever()
Contract->>EVM: Execute infinite loop
EVM-->>Contract: Gas exhaustion, revert transaction
Contract-->>User: Transaction failed
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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: 6
Outside diff range and nitpick comments (1)
e2e/evm/README.md (1)
Line range hint
4-4
: Fix markdown issues.- Folder contains ethers.js test bundle which executes main + Folder contains ethers.js test bundle which executes main - Contract is compiled via HardHat into [json file](./contracts/FunTokenCompiled.json) + Contract is compiled via HardHat into [json file](./contracts/FunTokenCompiled.json)Also applies to: 12-12
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
e2e/evm/contracts/InfiniteLoopGasCompiled.json
is excluded by!**/*.json
e2e/evm/contracts/ReceiveNibiCompiled.json
is excluded by!**/*.json
e2e/evm/contracts/SendNibiCompiled.json
is excluded by!**/*.json
Files selected for processing (10)
- CHANGELOG.md (1 hunks)
- e2e/evm/README.md (1 hunks)
- e2e/evm/contracts/InfiniteLoopGas.sol (1 hunks)
- e2e/evm/contracts/SendReceiveNibi.sol (1 hunks)
- e2e/evm/jest.config.js (1 hunks)
- e2e/evm/test/basic_queries.test.js (1 hunks)
- e2e/evm/test/contract_infinite_loop_gas.test.js (1 hunks)
- e2e/evm/test/contract_send_nibi.test.js (1 hunks)
- e2e/evm/test/erc20.test.js (1 hunks)
- e2e/evm/test/setup.js (1 hunks)
Additional context used
Biome
e2e/evm/jest.config.js
[error] 5-5: The computed expression can be simplified without the use of a string literal.
e2e/evm/test/setup.js
[error] 3-3: A Node.js builtin module should be imported with the node: protocol.
[error] 18-18: The computed expression can be simplified without the use of a string literal.
[error] 19-19: The computed expression can be simplified without the use of a string literal.
e2e/evm/test/erc20.test.js
[error] 13-13: This let declares a variable that is only assigned once.
[error] 23-23: This let declares a variable that is only assigned once.
e2e/evm/test/contract_send_nibi.test.js
[error] 14-14: This let declares a variable that is only assigned once.
LanguageTool
e2e/evm/README.md
[uncategorized] ~7-~7: You might be missing the article “an” here.
Context: ...sol) represents simple ERC20 token with initial supply1000,000 * 10e18
tokens. Cont...
[uncategorized] ~7-~7: Possible missing preposition found.
Context: ... simple ERC20 token with initial supply1000,000 * 10e18
tokens. Contract is c...
[uncategorized] ~17-~17: You might be missing the article “a” here.
Context: ...Run ### Run Nibiru node Tests require Nibiru node running with JSON RPC enabled. Lo...
Markdownlint
e2e/evm/README.md
4-4: Expected: 0 or 2; Actual: 1
Trailing spaces
12-12: Expected: 1; Actual: 2
Multiple consecutive blank lines
Additional comments not posted (7)
e2e/evm/jest.config.js (1)
3-3
: Updated testMatch pattern to include only.test.js
files is a good practice for clarity and specificity in test execution.e2e/evm/contracts/InfiniteLoopGas.sol (1)
4-17
: TheInfiniteLoopGas
contract is well-implemented for its purpose of testing gas limit behavior in transactions. Good use of comments to explain the expected outcome when the gas runs out.e2e/evm/test/contract_infinite_loop_gas.test.js (1)
3-23
: The test for theInfiniteLoopGas
contract is correctly implemented. It effectively checks for the 'out of gas' error and ensures that the state is not changed after failure, which is crucial for this scenario.e2e/evm/test/setup.js (1)
2-2
: Proper use of dotenv for environment configuration enhances maintainability and security by managing sensitive information outside of the codebase.e2e/evm/contracts/SendReceiveNibi.sol (2)
21-29
: LGTM! TheReceiveNibi
contract functions are well implemented.
33-50
: LGTM! TheSendNibi
contract methods are correctly implemented and documented.CHANGELOG.md (1)
68-68
: The changelog entry for PR #1901 is correctly formatted and provides the necessary information.
@@ -0,0 +1,31 @@ | |||
const {ethers} = require("ethers"); | |||
const {config} = require('dotenv') | |||
const fs = require("fs"); |
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.
Import the fs
module using the node:
protocol to ensure compatibility and clarity.
- const fs = require("fs");
+ const fs = require("node:fs");
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const fs = require("fs"); | |
const fs = require("node:fs"); |
const bytecode = contractJSON['bytecode'] | ||
const abi = contractJSON['abi'] |
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.
Simplify the access to JSON properties by removing the string literals.
- const bytecode = contractJSON['bytecode']
- const abi = contractJSON['abi']
+ const { bytecode, abi } = contractJSON
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const bytecode = contractJSON['bytecode'] | |
const abi = contractJSON['abi'] | |
const { bytecode, abi } = contractJSON |
|
||
// Execute contract: ERC20 transfer | ||
const shrimpAddress = ethers.Wallet.createRandom().address | ||
let ownerInitialBalance = ethers.parseUnits("1000000", 18) |
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.
Consider using const
instead of let
for variables that are not reassigned, which enhances code clarity and intent.
- let ownerInitialBalance = ethers.parseUnits("1000000", 18)
- let tx = await contract.transfer(shrimpAddress, amountToSend)
+ const ownerInitialBalance = ethers.parseUnits("1000000", 18)
+ const tx = await contract.transfer(shrimpAddress, amountToSend)
Also applies to: 23-23
Committable suggestion was skipped due low confidence.
e2e/evm/README.md
Outdated
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.
JavaScript is insanely slow
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- e2e/evm/test/basic_queries.test.js (1 hunks)
- e2e/evm/test/contract_send_nibi.test.js (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- e2e/evm/test/basic_queries.test.js
- e2e/evm/test/contract_send_nibi.test.js
Introduces 2 more test types: