Skip to content
This repository was archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
Add testnet blockchain adapters again
Browse files Browse the repository at this point in the history
  • Loading branch information
h0jeZvgoxFepBQ2C committed Aug 20, 2017
1 parent 7ff9dbe commit c2ab1d4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gem 'satoshi-unit', '~> 0.1'
gem 'httparty', '~> 0.13.5'
gem 'faraday'
gem 'concurrent-ruby'
gem 'pry'

group :development do
gem "bundler", "~> 1.0"
Expand Down
12 changes: 10 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ GEM
btcruby (1.0.3)
ffi (~> 1.9, >= 1.9.3)
builder (3.2.2)
coderay (1.1.1)
concurrent-ruby (0.9.1)
crack (0.4.2)
safe_yaml (~> 1.0.0)
Expand Down Expand Up @@ -37,8 +38,9 @@ GEM
nokogiri (>= 1.5.10)
rake
rdoc
json (1.8.1)
json (1.8.6)
jwt (1.0.0)
method_source (0.8.2)
mini_portile (0.6.0)
multi_json (1.10.1)
multi_xml (0.5.5)
Expand All @@ -51,6 +53,10 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.5.2)
rake (10.3.2)
rdoc (4.1.2)
Expand All @@ -69,6 +75,7 @@ GEM
rspec-support (3.1.0)
safe_yaml (1.0.4)
satoshi-unit (0.1.7)
slop (3.6.0)
thread_safe (0.3.4)
vcr (2.9.3)
webmock (1.21.0)
Expand All @@ -86,10 +93,11 @@ DEPENDENCIES
github_api (= 0.11.3)
httparty (~> 0.13.5)
jeweler (~> 2.0.1)
pry
rspec
satoshi-unit (~> 0.1)
vcr
webmock

BUNDLED WITH
1.10.4
1.15.1
4 changes: 4 additions & 0 deletions lib/straight/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def blockchain_adapters
@blockchain_adapters
end

def test_blockchain_adapters
@blockchain_adapters.map{ |el| el.class.testnet_adapter rescue next }.compact
end

# Creates a new order for the address derived from the pubkey and the keychain_id argument provided.
# See explanation of this keychain_id argument is in the description for the AddressProvider::Base#new_address method.
def new_order(args)
Expand Down
5 changes: 3 additions & 2 deletions spec/lib/exchange_rate_adapters/btc_adapter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'pry'

RSpec.describe Straight::ExchangeRate::BtcAdapter do

Expand All @@ -18,11 +19,11 @@ class Straight::ExchangeRate::Adapter
end

it "converts amount from currency into BTC" do
expect(@exchange_adapter.convert_from_currency(2252.706, currency: 'USD')).to eq(500000000)
expect(@exchange_adapter.convert_from_currency(100, currency: 'USD')).to eq(500000000)
end

it "converts from btc into currency" do
expect(@exchange_adapter.convert_to_currency(500000000, currency: 'USD')).to eq(2252.706)
expect(@exchange_adapter.convert_to_currency(100, currency: 'USD')).to eq(2252.706)
end

it "shows btc amounts in various denominations" do
Expand Down
1 change: 1 addition & 0 deletions spec/lib/gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
it "is using testnet" do
@gateway.test_mode = true
allow(@mock_adapter).to receive(:testnet_adapters).and_return(true)
expect(@gateway.blockchain_adapters).to_not be nil
expect(@gateway.blockchain_adapters).to eq(@gateway.test_blockchain_adapters)
end

Expand Down

0 comments on commit c2ab1d4

Please sign in to comment.