Closed 5chdn closed 7 years ago
Works on ruby 2.3 on OS X. Can you make the tests pass? I guessing adding 'require 'forwardable' on top of contract.rb should solve the problem.
No, tests fail:
ethereum.rb $ rspec
Ethereum::Abi
parses abi
parses empty abi
parse type
parse array type
Ethereum::Client
.encode_params
should eq [true, false, "0x0", "0x3039", "0x7d84abf0f241b10927b567bd636d95fa9f66ae34", "0x4d5e07d4057dd0c3849c2295d20ee1778fc29d69150e8d75a07207347dce17fa", "0x7d84abf0f241b10927b567bd636d95fa9f66ae34"]
.web3_client_version
behaves like json rpc method
is called
.net_version
behaves like json rpc method
is called
.eth_protocol_version
behaves like json rpc method
is called
.shh_new_identity
behaves like json rpc method
is called
.eth_call
behaves like json rpc method
is called
.eth_get_balance
behaves like json rpc method
is called
.get_balance
returns account balance as integer
.get_chain
returns chain no
.get_nonce
returns chain no
Ethereum
builds, deploys, call methods, receives events and kills contract (FAILED - 1)
Ethereum::Contract
create filter
succeed (FAILED - 2)
get filter logs
succeed (FAILED - 3)
get filter changes
succeed (FAILED - 4)
Ethereum::Contract
estimate
estimate
rises if wrong number of args for constructor
deploy
async
async with locked account
async with insufficient funds
async with custom gas price
async with custom gas limit
sync
rises if wrong number of args for constructor
transact
behaves like communicate with node
communicate with node
transact with custom gas
communicate with node
transact with custom gas price
communicate with node
transact with insufficient funds
communicate with node
transact_and_wait
communicate with node
call
behaves like communicate with node
communicate with node
call_raw
behaves like communicate with node
communicate with node
Ethereum::Encoder
parse type
uint
should encode and decode 20
should encode and decode 5
should encode and decode 5
should encode and decode 5
should eq 16
int
should encode and decode 20
should encode and decode 5
should encode and decode 5
should encode and decode 5
should encode and decode -20
should encode and decode -1
should eq 16
bool
should encode and decode true
should encode and decode false
address
should encode and decode "0000000000000000000000000000000000000000"
should raise ArgumentError
should raise ArgumentError
should eq "0000000000000000000000000000000000000000000000000000000000000000"
should eq "0000000000000000000000000000000000000000"
should eq "0000000000000000000000000000000000000002"
bytes32
should encode and decode "dave"
fixed
should encode and decode 2.125
should encode and decode 8.5
should eq "0000000000000000000000000000000880000000000000000000000000000000"
should eq "0000000000000000000000000000000000000000000000000000000000000088"
should eq 8.5
should eq 8.5
bytes
should eq "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000046461766500000000000000000000000000000000000000000000000000000000"
should eq "dave"
string
should eq "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000046461766500000000000000000000000000000000000000000000000000000000"
should eq "dave"
should eq "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c6d69c5826f62c499647a6b610000000000000000000000000000000000000000"
should eq "miłobędzka"
long string
should eq "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
decode function outputs
should eq [20, "miłobędzka"]
encode simple function input
should eq "00000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001"
encode bytes function input
should eq "0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000...000000000000000000000000000000000046461766500000000000000000000000000000000000000000000000000000000"
encode and decode string argument
should eq "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000008c5bcc3b3c582c487000000000000000000000000000000000000000000000000"
should eq ["żółć"]
encode and decode 2 string arguments
should eq "0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000...00000000000000000000000000000000008c5bcc3b3c582c487000000000000000000000000000000000000000000000000"
should eq ["żółć", "żółć"]
encode static array of ints
should eq "00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000014"
should eq [[5, 20]]
encode static array of ints with int before in arg list
should eq "000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000014"
should eq [2, [5, 20]]
encode string and static array of ints
should eq "0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000...00000000000000000000000000000000008c5bcc3b3c582c487000000000000000000000000000000000000000000000000"
should eq ["żółć", [5, 20]]
encode two int arrays
should eq "0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000...000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000003"
should eq [[7, 3], [7, 3]]
encode two byte32 arrays
should eq "0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000...000000000000000000000000000000000006200000000000000000000000000000000000000000000000000000000000000"
should eq [["a", "b"], ["a", "b"]]
encode two byte32 arrays and 2 ints
should eq "0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000...000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000003"
should eq [["a", "b"], ["a", "b"], [7, 3], [7, 3]]
encode simple dynamic array
should eq "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000...000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000014"
should eq [[5, 20]]
encode dynamic array with extra string
should eq ["żółć", [5, 20]]
should eq "0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000...000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000014"
raise exception if too many args
should raise Exception with "Wrong number of arguments"
raise exception if not enough args
should raise Exception with "Wrong number of arguments"
Ethereum::Solidity
link_to_tx
link_to_address
Ethereum::Function
calculates id
calculates signature without synonyms
simple
calculates signature with synonyms
simple
Ethereum::HttpClient
is able to connect
Ethereum::IpcClient
is able to connect
should find default path
should support batching
Ethereum Node
has supported JSON RPC version
has suported Ethereum version
has at least one account
has coinbase
Ethereum::Singleton.instance
should setup to IpcClient
should setup to HttpClient
should setup default account
should pick first account as default account if no account specifed
should be IpcCLient by default
Ethereum
/home/user/.gem/ruby/2.4.0/gems/money-tree-0.9.0/lib/money-tree/key.rb:73: warning: constant ::Bignum is deprecated
deploys with key set value and checks value (FAILED - 5)
/home/user/.gem/ruby/2.4.0/gems/money-tree-0.9.0/lib/money-tree/key.rb:73: warning: constant ::Bignum is deprecated
transfers ether (FAILED - 6)
Ethereum::Solidity
compiles contract (FAILED - 7)
compilation error
should raise Ethereum::CompilationError with message matching /.*Error: Identifier not found or not unique.*/ (FAILED - 8)
compilator not installed
should raise SystemCallError
Failures:
1) Ethereum builds, deploys, call methods, receives events and kills contract
Failure/Error: raise SystemCallError, "Unanable to run solc compliers" if status.exitstatus == 127
SystemCallError:
unknown error - Unanable to run solc compliers
# ./lib/ethereum/solidity.rb:35:in `execute_solc'
# ./lib/ethereum/solidity.rb:22:in `compile'
# ./lib/ethereum/initializer.rb:8:in `initialize'
# ./lib/ethereum/contract.rb:29:in `new'
# ./lib/ethereum/contract.rb:29:in `create'
# ./spec/ethereum/contract_blockchain_spec.rb:9:in `block (2 levels) in <top (required)>'
2) Ethereum::Contract create filter succeed
Failure/Error: raise SystemCallError, "Unanable to run solc compliers" if status.exitstatus == 127
SystemCallError:
unknown error - Unanable to run solc compliers
# ./lib/ethereum/solidity.rb:35:in `execute_solc'
# ./lib/ethereum/solidity.rb:22:in `compile'
# ./lib/ethereum/initializer.rb:8:in `initialize'
# ./lib/ethereum/contract.rb:29:in `new'
# ./lib/ethereum/contract.rb:29:in `create'
# ./spec/ethereum/contract_event_spec.rb:17:in `block (3 levels) in <top (required)>'
# ./spec/ethereum/contract_event_spec.rb:20:in `block (3 levels) in <top (required)>'
3) Ethereum::Contract get filter logs succeed
Failure/Error: raise SystemCallError, "Unanable to run solc compliers" if status.exitstatus == 127
SystemCallError:
unknown error - Unanable to run solc compliers
# ./lib/ethereum/solidity.rb:35:in `execute_solc'
# ./lib/ethereum/solidity.rb:22:in `compile'
# ./lib/ethereum/initializer.rb:8:in `initialize'
# ./lib/ethereum/contract.rb:29:in `new'
# ./lib/ethereum/contract.rb:29:in `create'
# ./spec/ethereum/contract_event_spec.rb:28:in `block (3 levels) in <top (required)>'
# ./spec/ethereum/contract_event_spec.rb:31:in `block (3 levels) in <top (required)>'
4) Ethereum::Contract get filter changes succeed
Failure/Error: raise SystemCallError, "Unanable to run solc compliers" if status.exitstatus == 127
SystemCallError:
unknown error - Unanable to run solc compliers
# ./lib/ethereum/solidity.rb:35:in `execute_solc'
# ./lib/ethereum/solidity.rb:22:in `compile'
# ./lib/ethereum/initializer.rb:8:in `initialize'
# ./lib/ethereum/contract.rb:29:in `new'
# ./lib/ethereum/contract.rb:29:in `create'
# ./spec/ethereum/contract_event_spec.rb:39:in `block (3 levels) in <top (required)>'
# ./spec/ethereum/contract_event_spec.rb:42:in `block (3 levels) in <top (required)>'
5) Ethereum deploys with key set value and checks value
Failure/Error: output = JSON.parse(send_single(payload.to_json))
JSON::ParserError:
743: unexpected token at ''
# ./lib/ethereum/client.rb:126:in `send_command'
# ./lib/ethereum/client.rb:137:in `block (2 levels) in <class:Client>'
# ./lib/ethereum/client.rb:81:in `transfer_to'
# ./lib/ethereum/client.rb:85:in `transfer_to_and_wait'
# ./spec/ethereum/signed_transaction_blockchain_spec.rb:13:in `block (2 levels) in <top (required)>'
6) Ethereum transfers ether
Failure/Error: socket = UNIXSocket.new(@ipcpath)
Errno::ENOENT:
No such file or directory - connect(2) for /home/user/.local/share/io.parity.ethereum/jsonrpc.ipc
# ./lib/ethereum/ipc_client.rb:27:in `initialize'
# ./lib/ethereum/ipc_client.rb:27:in `new'
# ./lib/ethereum/ipc_client.rb:27:in `send_single'
# ./lib/ethereum/client.rb:126:in `send_command'
# ./lib/ethereum/client.rb:137:in `block (2 levels) in <class:Client>'
# ./lib/ethereum/client.rb:81:in `transfer_to'
# ./lib/ethereum/client.rb:85:in `transfer_to_and_wait'
# ./spec/ethereum/signed_transaction_blockchain_spec.rb:22:in `block (2 levels) in <top (required)>'
7) Ethereum::Solidity compiles contract
Failure/Error: raise SystemCallError, "Unanable to run solc compliers" if status.exitstatus == 127
SystemCallError:
unknown error - Unanable to run solc compliers
# ./lib/ethereum/solidity.rb:35:in `execute_solc'
# ./lib/ethereum/solidity.rb:22:in `compile'
# ./spec/ethereum/solidity_spec.rb:11:in `block (2 levels) in <top (required)>'
# ./spec/ethereum/solidity_spec.rb:14:in `block (2 levels) in <top (required)>'
8) Ethereum::Solidity compilation error should raise Ethereum::CompilationError with message matching /.*Error: Identifier not found or not unique.*/
Failure/Error: it { expect{ subject }.to raise_error(Ethereum::CompilationError, /.*Error: Identifier not found or not unique.*/) }
expected Ethereum::CompilationError with message matching /.*Error: Identifier not found or not unique.*/, got #<SystemCallError: unknown error - Unanable to run solc compliers> with backtrace:
# ./lib/ethereum/solidity.rb:35:in `execute_solc'
# ./lib/ethereum/solidity.rb:22:in `compile'
# ./spec/ethereum/solidity_spec.rb:11:in `block (2 levels) in <top (required)>'
# ./spec/ethereum/solidity_spec.rb:22:in `block (4 levels) in <top (required)>'
# ./spec/ethereum/solidity_spec.rb:22:in `block (3 levels) in <top (required)>'
# ./spec/ethereum/solidity_spec.rb:22:in `block (3 levels) in <top (required)>'
Finished in 3 minutes 57.1 seconds (files took 0.35891 seconds to load)
117 examples, 8 failures
Failed examples:
rspec ./spec/ethereum/contract_blockchain_spec.rb:8 # Ethereum builds, deploys, call methods, receives events and kills contract
rspec ./spec/ethereum/contract_event_spec.rb:18 # Ethereum::Contract create filter succeed
rspec ./spec/ethereum/contract_event_spec.rb:29 # Ethereum::Contract get filter logs succeed
rspec ./spec/ethereum/contract_event_spec.rb:40 # Ethereum::Contract get filter changes succeed
rspec ./spec/ethereum/signed_transaction_blockchain_spec.rb:12 # Ethereum deploys with key set value and checks value
rspec ./spec/ethereum/signed_transaction_blockchain_spec.rb:21 # Ethereum transfers ether
rspec ./spec/ethereum/solidity_spec.rb:13 # Ethereum::Solidity compiles contract
rspec ./spec/ethereum/solidity_spec.rb:22 # Ethereum::Solidity compilation error should raise Ethereum::CompilationError with message matching /.*Error: Identifier not found or not unique.*/
Oh bummer, ... installing solidity :dagger: ...
Your suggested fix works for me.
Also thanks for adding custom gas price and limits.
Thank you for the fix, merged :)
(irb):1:in `
greeter = Greeter.new("Pat")
^^^^^^^
from loop' from /home/ney/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/irb-1.13.1/exe/irb:9:in
<top (required)>'
from /home/ney/.asdf/installs/ruby/3.3.1/bin/irb:25:in load' from /home/ney/.asdf/installs/ruby/3.3.1/bin/irb:25:in
uninitialized constant Greeter (NameError)
greeter = Greeter.new("Pat")
^^^^^from loop' from /home/ney/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/irb-1.13.1/exe/irb:9:in
<top (required)>'
from /home/ney/.asdf/installs/ruby/3.3.1/bin/irb:25:in load' from /home/ney/.asdf/installs/ruby/3.3.1/bin/irb:25:in
@antonio-ney please use https://github.com/q9f/eth.rb
Hi there, thanks for keeping up the work on a working ruby implementation.
The following code:
Throws the following issue:
I'm using the greeter.sol you linked in the Readme. Ethereum.rb 2.1.3 from rubygems, Ruby 2.4.0p0 on Archlinux 4.10.10.