-
Notifications
You must be signed in to change notification settings - Fork 94
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
Enabling connections with websocket client #222
base: main
Are you sure you want to change the base?
Changes from 1 commit
790dae0
d6098a4
85e4422
66c05e4
2a47fb5
b10cc66
43751be
b9d49bc
20ffb28
86c2246
deacccc
28ed6e0
afb0dc7
f7fca05
5ddd28b
c7b6c96
52656a9
fcaf5db
d25baa3
d6f7dd4
94f71d3
1567a37
e88b2f9
e87f507
efadc4a
fb0563e
4c8d760
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -436,7 +436,7 @@ | |||||
end | ||||||
end | ||||||
|
||||||
describe '.send' do | ||||||
describe ".send" do | ||||||
let(:captured_stdout) { StringIO.new } | ||||||
|
||||||
# Replace $stdout to capture standard output | ||||||
|
@@ -449,37 +449,37 @@ | |||||
$stdout = @orig_stdout | ||||||
end | ||||||
|
||||||
it 'should set up the WebSocket connection' do | ||||||
expect(geth_dev_ws.instance_variable_get('@ws')).to be_instance_of(WebSocket::Client::Simple::Client) | ||||||
it "should set up the WebSocket connection" do | ||||||
expect(geth_dev_ws.instance_variable_get("@ws")).to be_instance_of(WebSocket::Client::Simple::Client) | ||||||
end | ||||||
|
||||||
it 'should send a message to the WebSocket server and receive a response' do | ||||||
it "should send a message to the WebSocket server and receive a response" do | ||||||
payload = { | ||||||
id: 1, | ||||||
jsonrpc: '2.0', | ||||||
method: 'eth_subscribe', | ||||||
jsonrpc: "2.0", | ||||||
method: "eth_subscribe", | ||||||
params: ["newHeads"], | ||||||
} | ||||||
received_data = nil | ||||||
|
||||||
geth_dev_ws.instance_variable_get('@ws').on :message do |msg| | ||||||
geth_dev_ws.instance_variable_get("@ws").on :message do |msg| | ||||||
received_data = JSON.parse(msg.data) | ||||||
end | ||||||
|
||||||
sleep 0.001 | ||||||
geth_dev_ws.send(payload) | ||||||
sleep 0.001 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a way to avoid sleeping here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll look into ways to avoid using sleeping. |
||||||
|
||||||
expect(received_data['id']).to eq(payload[:id]) | ||||||
expect(received_data['jsonrpc']).to eq(payload[:jsonrpc]) | ||||||
expect(received_data['result']).to start_with('0x') | ||||||
expect(received_data["id"]).to eq(payload[:id]) | ||||||
expect(received_data["jsonrpc"]).to eq(payload[:jsonrpc]) | ||||||
expect(received_data["result"]).to start_with("0x") | ||||||
|
||||||
contract = Eth::Contract.from_file(file: "spec/fixtures/contracts/dummy.sol") | ||||||
geth_http.deploy_and_wait(contract) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
expect(received_data['method']).to eq("eth_subscription") | ||||||
expect(received_data['params']["subscription"]).to start_with('0x') | ||||||
expect(received_data['params']["result"]["parentHash"]).to start_with('0x') | ||||||
expect(received_data["method"]).to eq("eth_subscription") | ||||||
expect(received_data["params"]["subscription"]).to start_with("0x") | ||||||
expect(received_data["params"]["result"]["parentHash"]).to start_with("0x") | ||||||
end | ||||||
end | ||||||
end |
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.
shall we expose
@ws
with a getter?