Skip to content

Commit

Permalink
Merge pull request #22 from piotr-iohk/smash_health
Browse files Browse the repository at this point in the history
Smash health
  • Loading branch information
piotr-iohk authored Dec 1, 2020
2 parents 02b940c + 3d503f0 commit ee78ee4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/cardano_wallet/misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ def post_address(payload)
'Accept' => 'application/json'} )
end

# Current SMASH health
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getCurrentSmashHealth
#
# @example
# smash_health({url: "https://smash.cardano-mainnet.iohk.io/"})
def smash_health(q = {})
q.empty? ? query = '' : query = CardanoWallet::Utils.to_query(q)
self.class.get("/smash/health#{query}")
end

end

# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Proxy
Expand Down
2 changes: 1 addition & 1 deletion lib/cardano_wallet/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module CardanoWallet
VERSION = "0.2.8"
VERSION = "0.2.9"
end
28 changes: 26 additions & 2 deletions spec/misc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@
UTILS = CardanoWallet.new.misc.utils
end

describe "SMASH health" do
it "SMASH health - unreachable" do
r = UTILS.smash_health({url: "http://onet.pl"})
expect(r.to_s).to include "unreachable"
expect(r.code).to eq 200
end

it "SMASH health - bad url" do
r = UTILS.smash_health({url: "dsds"})
expect(r.to_s).to include "bad_request"
expect(r.code).to eq 400
end
end

it "Inspect invalid address" do
addr = "addr"
res = UTILS.addresses addr
Expand Down Expand Up @@ -247,20 +261,30 @@
describe CardanoWallet::Misc::Settings do
before(:all) do
SETTINGS = CardanoWallet.new.misc.settings
UTILS = CardanoWallet.new.misc.utils
end

after(:all) do
SETTINGS.update({:pool_metadata_source => "none"})
end

["direct", "https://smash.pl", "none"].each do |strategy|
it "I can read and update settings to #{strategy}" do
matrix = {"direct" => "no_smash_configured",
"https://smash.pl" => "unreachable",
"none" => "no_smash_configured"}

matrix.each do |strategy, smash_health_response|
it "I can read and update settings to #{strategy} and verify SMASH health = #{smash_health_response}" do
s = SETTINGS.update({:pool_metadata_source => strategy})
expect(s.code).to eq 204

g = SETTINGS.get
expect(g['pool_metadata_source']).to eq strategy
expect(g.code).to eq 200

#check smash health
r = UTILS.smash_health
expect(r.to_s).to include smash_health_response
expect(r.code).to eq 200
end
end
end
Expand Down

0 comments on commit ee78ee4

Please sign in to comment.