Skip to content

Commit

Permalink
spec: switch from infura to drpc (#308)
Browse files Browse the repository at this point in the history
* spec: switch from infura to drpc

* ci: switch to drpc token

* update docs

* eth/client: enable query parameters

* spec: add test for http client with query

* gem: fix missing bigdecimal gem
  • Loading branch information
q9f authored Dec 30, 2024
1 parent 39ad471 commit 7e38b0f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: |
bundle exec rspec
env:
INFURA_TOKEN: ${{ secrets.INFURA_TOKEN }}
DRPC_TOKEN: ${{ secrets.DRPC_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The test suite expects working local HTTP and IPC endpoints with a prefunded dev
geth --dev --http --ipcpath /tmp/geth.ipc &
```

It also expects an `$INFURA_TOKEN` in environment to test some ENS queries on mainnet.
It also expects an `$DRPC_TOKEN` in environment to test some ENS queries on mainnet.

To run tests, simply use `rspec`. Note, that the Ethereum test fixtures are also required.

Expand Down
3 changes: 3 additions & 0 deletions eth.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Gem::Specification.new do |spec|
spec.platform = Gem::Platform::RUBY
spec.required_ruby_version = ">= 3.0", "< 4.0"

# bigdecimal for big decimals ;)
spec.add_dependency "bigdecimal", "~> 3.1"

# forwardable for contracts meta programming
spec.add_dependency "forwardable", "~> 1.3"

Expand Down
8 changes: 6 additions & 2 deletions lib/eth/client/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ def initialize(host)
if !(uri.user.nil? && uri.password.nil?)
@user = uri.user
@password = uri.password
@uri = URI("#{uri.scheme}://#{uri.user}:#{uri.password}@#{@host}:#{@port}#{uri.path}")
if uri.query
@uri = URI("#{uri.scheme}://#{uri.user}:#{uri.password}@#{@host}:#{@port}#{uri.path}?#{uri.query}")
else
@uri = URI("#{uri.scheme}://#{uri.user}:#{uri.password}@#{@host}:#{@port}#{uri.path}")
end
else
@uri = URI("#{uri.scheme}://#{@host}:#{@port}#{uri.path}")
@uri = uri
end
end

Expand Down
38 changes: 25 additions & 13 deletions spec/eth/client_spec.rb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions spec/eth/ens/resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

describe Ens::Resolver do

# it expects an $INFURA_TOKEN in environment
let(:infura_api) { "https://mainnet.infura.io/v3/#{ENV["INFURA_TOKEN"]}" }
subject(:infura_mainnet) { Client.create infura_api }
let(:resolver) { Ens::Resolver.new(infura_mainnet) }
# it expects an $DRPC_TOKEN in environment
let(:drpc_api) { "https://lb.drpc.org/ogrpc?network=ethereum&dkey=#{ENV["DRPC_TOKEN"]}" }
subject(:drpc_mainnet) { Client.create drpc_api }
let(:resolver) { Ens::Resolver.new(drpc_mainnet) }

describe "normalize" do
it "can normalize ascii" do
Expand Down

0 comments on commit 7e38b0f

Please sign in to comment.