require 'spec_helper' RSpec.describe CoinAddressValidators do context "btc" do it "returns correctly" do expect(CoinAddressValidators["btc"].valid?("14YoCUBKcrK3r8Hn7VxYGQ5bbfHf8qRtch")).to be_truthy expect(CoinAddressValidators["btc"].valid?("14YoCUBKcrK3r8Hn7VxYGQ5bbfHf8qRtcg")).to be_falsey end end context "bch" do context "cashaddr format" do it "returns correctly" do expect(CoinAddressValidators["btc"].valid?("14YoCUBKcrK3r8Hn7VxYGQ5bbfHf8qRtch")).to be_truthy expect(CoinAddressValidators["btc"].valid?("14YoCUBKcrK3r8Hn7VxYGQ5bbfHf8qRtcg")).to be_falsey end end context "legacy format" do it "returns correctly" do expect(CoinAddressValidators["bch"].valid?("bitcoincash:qp85dztm50l8x0rdkr8laartkcygjpkkxg0qqf93kf")).to be_truthy expect(CoinAddressValidators["bch"].valid?("qp85dztm50l8x0rdkr8laartkcygjpkkxg0qqf93kf")).to be_truthy expect(CoinAddressValidators["bch"].valid?("bitcoincash:qp85dztm50l8x0rdkr8laartkcygjpkkxg0qqf93ka")).to be_falsey end end end context "eth" do it "returns correctly" do expect(CoinAddressValidators["eth"].valid?("0xff0a8531f38e5f143a0444d066fad0a0f0833853")).to be_truthy expect(CoinAddressValidators["eth"].valid?("0xff0a8531f38e5f143a0444d066fad0a0f08338534")).to be_falsey end end context "ltc" do it "returns correctly" do expect(CoinAddressValidators["ltc"].valid?("LajyQBeZaBA1NkZDeY8YT5RYYVRkXMvb2T")).to be_truthy expect(CoinAddressValidators["ltc"].valid?("M9k7JpqrWewzzQK8bPT2GFNzbijRHzDaU4")).to be_truthy expect(CoinAddressValidators["ltc"].valid?("M9k7JpqrWewzzQK8bPT2GFNzbijRHzDaU5")).to be_falsey end end context "xrp" do it "returns correctly" do expect(CoinAddressValidators["xrp"].valid?("r!!!")).to be_falsey expect(CoinAddressValidators["xrp"].valid?("rQGwKPE63Mmi9QdswwxKkVUxp6joqFbjzm")).to be_falsey expect(CoinAddressValidators["xrp"].valid?("rEuLyBCvcw4CFmzv8RepSiAoNgF8tTGJQC")).to be_truthy end end context "nil address" do %w(btc bch eth ltc xrp).each do |coin| it "returns false" do expect(CoinAddressValidators[coin].valid?(nil)).to be_falsey end end end end