Closed Flouse closed 11 months ago
After local debugging, I found that running eth_getCode_4
and eth_getCode_9
simultaneously causes this issue. (Test method: skip other test cases and only keep 4 and 9, then execute jest tests/e2e/src/eth_getCode.test.js
).
eth_getCode
interface behaves as expected. It does not exhibit problems when first called with the latest block height as a parameter and then immediately followed by a call with an invalid parameter.
response=$(curl -s http://localhost:8000 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params": [],"id":1}')
blockNumber=$(echo $response | jq -r '.result')
curl -X POST \ -H "Content-Type: application/json" \ --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "'"$blockNumber"'"],"id":1}' \ http://localhost:8000
curl -X POST \ -H "Content-Type: application/json" \ --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", ""],"id":2}' \ http://localhost:8000
``` json
{"jsonrpc":"2.0","result":"0x","id":1}
{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params","data":"Invalid block number: missing 0x prefix at line 1 column 3"},"id":2}
eth_getCode_4
and eth_getCode_9
on http://localhost:8080/eth_getCode.html
. The behavior observed was as expected.Therefore, combining points 1 and 2, we can make a preliminary judgment: Normal use of MetaMask does not cause issues; the problem may lie with the testing framework.
eth_getCode_4
and eth_getCode_9
, the test results align with expectations. This might be because MetaMask has a bug when handling rapid, consecutive executions. By continuously adjusting the waiting time after executing eth_getCode_4
, I found that 20 seconds is the threshold.
Tests: 1 failed, 8 skipped, 1 passed, 10 total
Snapshots: 0 total
Time: 19.727 s, estimated 21 s
Tests: 8 skipped, 2 passed, 10 total Snapshots: 0 total Time: 20.562 s
A pull request has been submitted: https://github.com/axonweb3/axon/pull/1593.
Examples
Current Behavior
Expected Behavior
Test results should be deterministic