From 134876b022bd4924bd71009a4c290b032b91bf7f Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Tue, 1 Dec 2020 15:27:13 +0100 Subject: [PATCH 1/2] Smash health ep with tests --- lib/cardano_wallet/misc.rb | 10 ++++++++++ spec/misc_spec.rb | 28 ++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/cardano_wallet/misc.rb b/lib/cardano_wallet/misc.rb index 0d35570..41b8054 100644 --- a/lib/cardano_wallet/misc.rb +++ b/lib/cardano_wallet/misc.rb @@ -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 diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index fa4c2b9..4718667 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -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 @@ -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 From 3d503f02bbaba4633795cc84ed16b175d0b7bd08 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Tue, 1 Dec 2020 15:28:13 +0100 Subject: [PATCH 2/2] version to 0.2.9 --- lib/cardano_wallet/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cardano_wallet/version.rb b/lib/cardano_wallet/version.rb index e0047de..75c454d 100644 --- a/lib/cardano_wallet/version.rb +++ b/lib/cardano_wallet/version.rb @@ -1,3 +1,3 @@ module CardanoWallet - VERSION = "0.2.8" + VERSION = "0.2.9" end