Open kurotaky opened 1 year ago
Attention: 39 lines
in your changes are missing coverage. Please review.
Comparison is base (
db8becd
) 99.70% compared to head (4c8d760
) 98.86%.
Files | Patch % | Lines |
---|---|---|
spec/eth/client_spec.rb | 43.13% | 29 Missing :warning: |
lib/eth/client/ws.rb | 68.75% | 10 Missing :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
📝 This test is failing on Ubuntu only. under investigation. https://github.com/q9f/eth.rb/actions/runs/4974153459?pr=222
1) Eth::Client.deploy .deploy_and_wait deploy the contract with constructor params
Failure/Error: raise IOError, output["error"]["message"] unless output["error"].nil?
IOError:
invalid opcode: PUSH0
# ./lib/eth/client.rb:482:in `send_command'
# ./lib/eth/client.rb:393:in `block (2 levels) in <class:Client>'
# ./lib/eth/client.rb:440:in `send_transaction'
# ./lib/eth/client.rb:233:in `deploy'
# ./lib/eth/client.rb:190:in `deploy_and_wait'
# ./spec/eth/client_spec.rb:175:in `block (3 levels) in <top (required)>'
@q9f Thanks for the review. I've just taken in the fixes, please look at it again!
tests fail due to shanghai (or lack thereof)
Is there a way we can abstract the way websockets work away from the client?
I.e., I would like to be able just to call
chain_id
and get a result.lg = Logger.new(STDOUT, level: Logger::FATAL) ws = Client.create("ws://127.0.0.1:8546", logger: lg) ws.chain_id # TypeError: no implicit conversion of Integer into String # from /usr/lib/ruby/3.0.0/json/common.rb:216:in `initialize' ws.default_account # TypeError: no implicit conversion of Integer into String # from /usr/lib/ruby/3.0.0/json/common.rb:216:in `initialize'
Do you think this is possible?
Okay, as a result, it appears that the number of bytes is returned.This is because the send method returns the number of bytes sent.Unlike HTTP, WebSocket is stateful in nature, so I may need to wait for the response before parsing it. I will think about it and try to implement it. 😄
From: /Users/kurotaki/ghq/github.com/q9f/eth.rb/lib/eth/client.rb:487 Eth::Client#send_command:
479: def send_command(command, args)
480: args << "latest" if ["eth_getBalance", "eth_call"].include? command
481: payload = {
482: jsonrpc: "2.0",
483: method: command,
484: params: marshal(args),
485: id: next_id,
486: }
=> 487: binding.pry
488: output = JSON.parse(send_request(payload.to_json))
489: raise IOError, output["error"]["message"] unless output["error"].nil?
490: output
491: end
[1] pry(#<Eth::Client::Ws>)> payload
=> {:jsonrpc=>"2.0", :method=>"eth_chainId", :params=>[], :id=>1}
[2] pry(#<Eth::Client::Ws>)> output = JSON.parse(send_request(payload.to_json))
TypeError: no implicit conversion of Integer into String
from /Users/kurotaki/.rbenv/versions/3.2.0/lib/ruby/3.2.0/json/common.rb:216:in `initialize'
[3] pry(#<Eth::Client::Ws>)> send_request(payload.to_json)
=> 79
I'm back! 😄
Enabling connections via Websocket. Connect using only Ruby libraries. fix: https://github.com/q9f/eth.rb/issues/86
Sample procedure
Eth::Client::Ws.new
Output
cli.send
Output