# frozen_string_literal: true

RSpec.describe(AdequateCryptoAddress) do
  describe '.valid?' do
    context 'Bitcoin' do
      it 'validates hash160 addresses' do
        expect(described_class).to be_valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoin')
        expect(described_class).to be_valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BTC')
        expect(described_class).to be_valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin')
        expect(described_class).to be_valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc')
        expect(described_class).to be_valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', :hash160)

        # testnet
        expect(described_class).to be_valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'hash160test')
        expect(described_class).to be_valid('mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB', :btc)
      end

      it 'validates p2sh addresses' do
        expect(described_class).to be_valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'BTC')
        expect(described_class).to be_valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin', 'p2sh')

        # testnet
        expect(described_class).to be_valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'btc')
        expect(described_class).to be_valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoin', 'p2shtest')
      end

      it 'validates segwit addresses' do
        expect(described_class).to be_valid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'BTC')
        expect(described_class).to be_valid('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq', 'bitcoin')
        expect(described_class).to be_valid('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq', 'bitcoin', :segwit_v0_keyhash)
        expect(described_class).to be_valid('bc1qc7slrfxkknqcq2jevvvkdgvrt8080852dfjewde450xdlk4ugp7szw5tk9', 'BTC')
        expect(described_class).to be_valid('bc1qc7slrfxkknqcq2jevvvkdgvrt8080852dfjewde450xdlk4ugp7szw5tk9', 'bitcoin', 'segwit_v0_scripthash')
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('asdf', :bitcoin)
        expect(described_class).not_to be_valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin', :segwit_v0_keyhash)
        expect(described_class).not_to be_valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin', 'asdf')
        expect(described_class).not_to be_valid('tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty', :bitcoin)
        expect(described_class).not_to be_valid('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5', 'bitcoin')
        expect(described_class).not_to be_valid('BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2', 'bitcoin')
        expect(described_class).not_to be_valid('bc1rw5uspcuh', 'bitcoin')
        expect(described_class).not_to be_valid('bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90', 'bitcoin')
        expect(described_class).not_to be_valid('BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P', 'bitcoin')
        expect(described_class).not_to be_valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7', 'BTC')
        expect(described_class).not_to be_valid('bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du', 'bitcoin')
        expect(described_class).not_to be_valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv', 'Bitcoin')
        expect(described_class).not_to be_valid('bc1gmk9yu', 'bitcoin')
      end
    end

    context 'Bitcoincash' do
      it 'validates legacy addresses' do
        expect(described_class).to be_valid('3CWFddi6m4ndiGyKqzYvsFYagqDLPVMTzC', :bch, :p2sh)
        expect(described_class).to be_valid('155fzsEBHy9Ri2bMQ8uuuR3tv1YzcDywd4', 'bitcoincash', :p2pkh)
        expect(described_class).to be_valid('2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1Vc', 'BCH', :p2shtest)
        expect(described_class).to be_valid('mmRH4e9WW4ekZUP5HvBScfUyaSUjfQRyvD', :BCH, :p2pkhtest)
      end

      it 'validates cash addresses' do
        expect(described_class).to be_valid('bitcoincash:qqkv9wr69ry2p9l53lxp635va4h86wv435995w8p2h', :bch, :p2pkh)
        expect(described_class).to be_valid('bitcoincash:pqdg9uq52wzhf228hweext9j2jdjgdpj9qt7xxfngd', :bitcoincash, :p2sh)
        expect(described_class).to be_valid('bchtest:qpqtmmfpw79thzq5z7s0spcd87uhn6d34uqqem83hf', :Bitcoincash, :p2pkhtest)
        expect(described_class).to be_valid('bchtest:pp8f7ww2g6y07ypp9r4yendrgyznysc9kqxh6acwu3', :BCH, :p2shtest)
        expect(described_class).to be_valid('bitcoincash:qrtj3rd8524cndt2eew3s6wljqggmne00sgh4kfypk', :bitcoincash)
      end

      it 'validates cash addresses without prefix addresses' do
        expect(described_class).to be_valid('qrtj3rd8524cndt2eew3s6wljqggmne00sgh4kfypk', :bitcoincash)
        expect(described_class).to be_valid('pqdg9uq52wzhf228hweext9j2jdjgdpj9qt7xxfngd', :bitcoincash, :p2sh)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('bitcoincash:qqkv9wr69ry2p9l53lxP635va4h86wv435995w8p2H', :bch)
        expect(described_class).not_to be_valid('wrong', :bch)
        expect(described_class).not_to be_valid('bitcoincash:wrong', :bch)
        expect(described_class).not_to be_valid('bitcoincash:123', :bch)

        expect(described_class).not_to be_valid('bitcoincash:qqkv9wr69ry2p9l53lxp635va4h86wv435995w8p2h', :bch, :p2pkhtest)
        expect(described_class).not_to be_valid('bitcoincash:pqdg9uq52wzhf228hweext9j2jdjgdpj9qt7xxfngd', :bitcoincash, :p2pkhtest)
        expect(described_class).not_to be_valid('bchtest:qpqtmmfpw79thzq5z7s0spcd87uhn6d34uqqem83hf', :Bitcoincash, :p2sh)
        expect(described_class).not_to be_valid('bchtest:pp8f7ww2g6y07ypp9r4yendrgyznysc9kqxh6acwu3', :BCH, :p2sh)
      end
    end

    context 'Ethereum' do
      it 'validates addresses' do
        expect(described_class).to be_valid('0xE37c0D48d68da5c5b14E5c1a9f1CFE802776D9FF', 'ethereum')
        expect(described_class).to be_valid('0xa00354276d2fC74ee91e37D085d35748613f4748', :ethereum)
        expect(described_class).to be_valid('0xAff4d6793F584a473348EbA058deb8caad77a288', :ETH)
        expect(described_class).to be_valid('0xc6d9d2cd449a754c494264e1809c50e34d64562b', 'ETH')
        expect(described_class).to be_valid('0x52908400098527886E0F7030069857D2E4169EE7', 'ETH')
        expect(described_class).to be_valid('0x8617E340B3D01FA5F11F306F4090FD50E238070D', 'ETH')
        expect(described_class).to be_valid('0xde709f2102306220921060314715629080e2fb77', 'ETH')
      end

      it 'validates without prefixes addresses' do
        expect(described_class).to be_valid('27b1fdb04752bbc536007a920d24acb045561c26', 'ETH')
        expect(described_class).to be_valid('5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', 'ETH')
        expect(described_class).to be_valid('fB6916095ca1df60bB79Ce92cE3Ea74c37c5d359', 'ETH')
        expect(described_class).to be_valid('dbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB', 'ETH')
        expect(described_class).to be_valid('D1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETH')
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('wrong', :ETH)
        expect(described_class).not_to be_valid('0xD1110A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETH')
        expect(described_class).not_to be_valid('a10354276d2fC74ee91e37D085d35748613f4748', :ethereum)
      end
    end

    context 'Ripple' do
      it 'validates addresses' do
        expect(described_class).to be_valid('rPMLwSwyyULN2acf5JKB1nj8F8Eu8pVMV8', :ripple)
        expect(described_class).to be_valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', :ripple)
        expect(described_class).to be_valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'RIPPLE')
        expect(described_class).to be_valid('r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV', 'XRP')
        expect(described_class).to be_valid('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', :XRP)
        expect(described_class).to be_valid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN', 'XRP')
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('wrong', :xrp)
        expect(described_class).not_to be_valid('r3kmLJN5D28dHuH8vZNUZpMC43pEHpaoc1', :xrp)
        expect(described_class).not_to be_valid('r1kmLJN5D28dHuH8vZNUZpMC43pEHpaocV', 'ripple')
      end
    end

    context 'Dash' do
      it 'validates addresses' do
        expect(described_class).to be_valid('Xx4dYKgz3Zcv6kheaqog3fynaKWjbahb6b', :dash)
        expect(described_class).to be_valid('XcY4WJ6Z2Q8w7vcYER1JypC8s2oa3SQ1b1', 'DASH')
        expect(described_class).to be_valid('XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4', 'DASH', :prod)
        expect(described_class).to be_valid('yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA', :DASH, 'test')
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('wrong', :dash)
        expect(described_class).not_to be_valid('yPv7h2i8v3dJ1fSH4L3x91JSJszjdbsJJA', :dash)
        expect(described_class).not_to be_valid('XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4', 'dash', :test)
        expect(described_class).not_to be_valid('yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA', :DASH, :prod)
      end
    end

    context 'Zcash' do
      it 'validates addresses' do
        expect(described_class).to be_valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', :zec)
        expect(described_class).to be_valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'zcash', :prod)
        expect(described_class).to be_valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'ZEC', :test)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('wrong', :zec)
        expect(described_class).not_to be_valid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', :zcash)
        expect(described_class).not_to be_valid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', :ZEC)
        expect(described_class).not_to be_valid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', :zcash, :test)
      end
    end

    context 'Litecoin' do
      it 'validates addresses' do
        expect(described_class).to be_valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', :ltc)
        expect(described_class).to be_valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'ltc', :prod)
        expect(described_class).to be_valid('LTpYZG19YmfvY2bBDYtCKpunVRw7nVgRHW', 'LTC')
        expect(described_class).to be_valid('Lb6wDP2kHGyWC7vrZuZAgV7V4ECyDdH7a6', 'Litecoin')
        expect(described_class).to be_valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'Litecoin', :test)

        expect(described_class).to be_valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'LTC')
        expect(described_class).to be_valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'LTC', :test)
        expect(described_class).to be_valid('QW2SvwjaJU8LD6GSmtm1PHnBG2xPuxwZFy', 'LTC', :test)
        expect(described_class).to be_valid('QjpzxpbLp5pCGsCczMbfh1uhC3P89QZavY', 'LTC', :test)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('wrong', :zec)
        expect(described_class).not_to be_valid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', :zcash)
        expect(described_class).not_to be_valid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', :ZEC)
        expect(described_class).not_to be_valid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', :zcash, :test)
      end
    end

    context '42' do
      it 'validates addresses' do
        expect(described_class).to be_valid('4bmfTBKaAQUbnedyWZtog4Sso4UMbRLLwg', '42', :mainnet)
        expect(described_class).to be_valid('4NMweooeSVz2QXZGmFEJjmbbpv3pjFAx5X', '42', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('mkHS9ne12qx9pS9VojpwU5xtRd4T7X7ZUt', '42', :mainnet)
        expect(described_class).not_to be_valid('4NMweooeSVz2QXZGmFEJjmbbpv3pjFAx42', '42', :mainnet)
        expect(described_class).not_to be_valid('4bmfTBKaAQUbnedyWZtog4Sso4UMbRLL42', '42', :mainnet)
      end
    end

    context 'altm' do
      it 'validates addresses' do
        expect(described_class).to be_valid('AQL9WZhmDe5eGBuzzVnmPacfXJSwtCdNJc', 'altm', :mainnet)
        expect(described_class).to be_valid('AHZvikbxxmcxYsUqtymgxFoLais2dffHGK', 'altm', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('AQL9WZhmDe5eGBuzzVnmPacfXJSwtCdN11', 'altm', :mainnet)
        expect(described_class).not_to be_valid('AHZvikbxxmcxYsUqtymgxFoLais2dffH11', 'altm', :mainnet)
      end
    end

    context 'ani' do
      it 'validates addresses' do
        expect(described_class).to be_valid('AW7rZFu6semXGqyUBsaxuXs6LymQh2kwRA', 'ani', :mainnet)
        expect(described_class).to be_valid('ARyR1fUQjutaoCb64LhaiPZjzvKyGrYYL1', 'ani', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('AW7rZFu6semXGqyUBsaxuXs6LymQh2kw11', 'ani', :mainnet)
        expect(described_class).not_to be_valid('ARyR1fUQjutaoCb64LhaiPZjzvKyGrYY11', 'ani', :mainnet)
      end
    end

    context 'aus' do
      it 'validates addresses' do
        expect(described_class).to be_valid('AbSMZaNyhiaXx4c57ADQ46Pz7CwJ3GpSVD', 'aus', :mainnet)
        expect(described_class).to be_valid('SXBHFu1SyKF99U8aJ1SXxw5DrzrjRsRmme', 'aus', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('AbSMZaNyhiaXx4c57ADQ46Pz7CwJ3GpS11', 'aus', :mainnet)
        expect(described_class).not_to be_valid('SXBHFu1SyKF99U8aJ1SXxw5DrzrjRsRm11', 'aus', :mainnet)
      end
    end

    context 'dftz' do
      it 'validates addresses' do
        expect(described_class).to be_valid('DNgXEa1bwfZ6AV1VFd9ACQPW98Es3Gsni1', 'dftz', :mainnet)
        expect(described_class).to be_valid('D6fSu4x65wkcuq7EdoqtQ8unZmGejJda1U', 'dftz', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('DNgXEa1bwfZ6AV1VFd9ACQPW98Es3Gsn11', 'dftz', :mainnet)
        expect(described_class).not_to be_valid('D6fSu4x65wkcuq7EdoqtQ8unZmGejJda11', 'dftz', :mainnet)
      end
    end

    context 'genix' do
      it 'validates addresses' do
        expect(described_class).to be_valid('GRfUUn1BjsHnn1QQ6wVjgQFJNoX94jQy9L', 'genix', :mainnet)
        expect(described_class).to be_valid('GfukUaJCxcBSzPxhySKbsD68nuYEC4YbrZ', 'genix', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('GRfUUn1BjsHnn1QQ6wVjgQFJNoX94jQy11', 'genix', :mainnet)
        expect(described_class).not_to be_valid('GfukUaJCxcBSzPxhySKbsD68nuYEC4Yb11', 'genix', :mainnet)
      end
    end

    context 'hcc' do
      it 'validates addresses' do
        expect(described_class).to be_valid('HSoqpwLqMSiAeXa964RDKe9wNKYc1FJYAp', 'hcc', :mainnet)
        expect(described_class).to be_valid('H73kXbboxxbE8mgZ84mrP6ZvbRK4khwoKU', 'hcc', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('HSoqpwLqMSiAeXa964RDKe9wNKYc1FJY11', 'hcc', :mainnet)
        expect(described_class).not_to be_valid('H73kXbboxxbE8mgZ84mrP6ZvbRK4khwo11', 'hcc', :mainnet)
      end
    end

    context 'hth' do
      it 'validates addresses' do
        expect(described_class).to be_valid('hbGWMKExSeKCXspt3J84JfJBLAb6UKTnfK', 'hth', :mainnet)
        expect(described_class).to be_valid('hWKCLpvHEDwzYeFdWLrGBXdFRW8ogEfso7', 'hth', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('hbGWMKExSeKCXspt3J84JfJBLAb6UKTn11', 'hth', :mainnet)
        expect(described_class).not_to be_valid('hWKCLpvHEDwzYeFdWLrGBXdFRW8ogEfs11', 'hth', :mainnet)
      end
    end

    context 'konj' do
      it 'validates addresses' do
        expect(described_class).to be_valid('K7gNsQQKF1ynvpgM3kMc5oB52C3oJdCJDU', 'konj', :mainnet)
        expect(described_class).to be_valid('KAG8W6Lx4E11funA9KvkX7f1wfE6ni21En', 'konj', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('K7gNsQQKF1ynvpgM3kMc5oB52C3oJdUUOU', 'konj', :mainnet)
        expect(described_class).not_to be_valid('KAG8W6Lx4E11funA9KvkX7f1wfE6niUUOU', 'konj', :mainnet)
      end
    end

    context 'ldoge' do
      it 'validates addresses' do
        expect(described_class).to be_valid('dX7EJqPyVSWivBDuTZzUBaAkFrG7kGY6A9', 'ldoge', :mainnet)
        expect(described_class).to be_valid('dYfzfhVgupKE4eoEJAoZv6xGVwdDf5NzE9', 'ldoge', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('dX7EJqPyVSWivBDuTZzUBaAkFrG7kGY611', 'ldoge', :mainnet)
        expect(described_class).not_to be_valid('dYfzfhVgupKE4eoEJAoZv6xGVwdDf5Nz11', 'ldoge', :mainnet)
      end
    end

    context 'mhsp' do
      it 'validates addresses' do
        expect(described_class).to be_valid('MjAuM7XmPfZ2QPYFwkNpw9jhnsTa7PEiZX', 'mhsp', :mainnet)
        expect(described_class).to be_valid('MbS4XtUcH235YMQyJqPXRo4ZP2SW7KYSz2', 'mhsp', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('MjAuM7XmPfZ2QPYFwkNpw9jhnsTa7PEi11', 'mhsp', :mainnet)
        expect(described_class).not_to be_valid('MbS4XtUcH235YMQyJqPXRo4ZP2SW7KYS11', 'mhsp', :mainnet)
      end
    end

    context 'nah' do
      it 'validates addresses' do
        expect(described_class).to be_valid('SZ4MANtVniqdZKH4BffVoBFNUr4a3jjw21', 'nah', :mainnet)
        expect(described_class).to be_valid('SZsgnsVEdLS7XW4bKkQGntmCYS1DfqQFJ7', 'nah', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('SZ4MANtVniqdZKH4BffVoBFNUr4a3jjw11', 'nah', :mainnet)
        expect(described_class).not_to be_valid('SZsgnsVEdLS7XW4bKkQGntmCYS1DfqQF11', 'nah', :mainnet)
      end
    end

    context 'ntbc' do
      it 'validates addresses' do
        expect(described_class).to be_valid('NQvRxAAhVUzhYzqe956yamohJQuk6pWfBi', 'ntbc', :mainnet)
        expect(described_class).to be_valid('NY34QXqUq2mL63N98SSvv7RkcK82qoFaib', 'ntbc', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('NQvRxAAhVUzhYzqe956yamohJQuk6pWf11', 'ntbc', :mainnet)
        expect(described_class).not_to be_valid('NY34QXqUq2mL63N98SSvv7RkcK82qoFa11', 'ntbc', :mainnet)
      end
    end

    context 'ntrn' do
      it 'validates addresses' do
        expect(described_class).to be_valid('9pMLvPszakXTTbx4wPpazYCQafGP86do2y', 'ntrn', :mainnet)
        expect(described_class).to be_valid('9f8EXeytYayJrwsU2gjaGXNrug2neb5a84', 'ntrn', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('9pMLvPszakXTTbx4wPpazYCQafGP86do11', 'ntrn', :mainnet)
        expect(described_class).not_to be_valid('9f8EXeytYayJrwsU2gjaGXNrug2neb5a11', 'ntrn', :mainnet)
      end
    end

    context 'pak' do
      it 'validates addresses' do
        expect(described_class).to be_valid('PQC6NTc7Pi4reEPWnJEDAmMhqumjmrSAwV', 'pak', :mainnet)
        expect(described_class).to be_valid('PTrtSLxMTdPznK3Mjaw2kEPxJ5jmPsZVoz', 'pak', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('PQC6NTc7Pi4reEPWnJEDAmMhqumjmrSA11', 'pak', :mainnet)
        expect(described_class).not_to be_valid('PTrtSLxMTdPznK3Mjaw2kEPxJ5jmPsZV11', 'pak', :mainnet)
      end
    end

    context 'petal' do
      it 'validates addresses' do
        expect(described_class).to be_valid('CQNjLzupHbrHQRffUPsgBZz9hZqsRt2bez', 'petal', :mainnet)
        expect(described_class).to be_valid('CJ2uas3XxXRpUVs6EUfK6JRLUaWBTzCPSt', 'petal', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('CQNjLzupHbrHQRffUPsgBZz9hZqsRt2b11', 'petal', :mainnet)
        expect(described_class).not_to be_valid('CJ2uas3XxXRpUVs6EUfK6JRLUaWBTzCP11', 'petal', :mainnet)
      end
    end

    context 'pgn' do
      it 'validates addresses' do
        expect(described_class).to be_valid('PPfbwWx2NSTgrzRxKpS1whdmW6Kzz96eMa', 'pgn', :mainnet)
        expect(described_class).to be_valid('PAexuuwSGjZEhRdjYxZVRKLsMaRqYvJFrs', 'pgn', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('PPfbwWx2NSTgrzRxKpS1whdmW6Kzz96e11', 'pgn', :mainnet)
        expect(described_class).not_to be_valid('PAexuuwSGjZEhRdjYxZVRKLsMaRqYvJF11', 'pgn', :mainnet)
      end
    end

    context 'pivxl' do
      it 'validates addresses' do
        expect(described_class).to be_valid('QY12ZewMYmcZky2RgZJtcBhvR4EnC2bWe9', 'pivxl', :mainnet)
        expect(described_class).to be_valid('QjwU47jBgPPNE3dKTHwoyJfZ5qA774gZeJ', 'pivxl', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('QY12ZewMYmcZky2RgZJtcBhvR4EnC2bW11', 'pivxl', :mainnet)
        expect(described_class).not_to be_valid('QjwU47jBgPPNE3dKTHwoyJfZ5qA774gZ11', 'pivxl', :mainnet)
      end
    end

    context 'rnrc' do
      it 'validates addresses' do
        expect(described_class).to be_valid('RMk8VCe1zZmFVUpnyNiPwQ2rsn3NKt2RzP', 'rnrc', :mainnet)
        expect(described_class).to be_valid('RVQkGZkWtWzgd7P4g2q1QCeWGe5MyWc2wg', 'rnrc', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('RMk8VCe1zZmFVUpnyNiPwQ2rsn3NKt2R11', 'rnrc', :mainnet)
        expect(described_class).not_to be_valid('RVQkGZkWtWzgd7P4g2q1QCeWGe5MyWc211', 'rnrc', :mainnet)
      end
    end

    context 'roger' do
      it 'validates addresses' do
        expect(described_class).to be_valid('Rmonk1tmbRS1nKfwSeN2WfGZcdRfTQAy5s', 'roger', :mainnet)
        expect(described_class).to be_valid('RogseRve5vPxMrBKVA72FvhPYUKFEQqc1w', 'roger', :mainnet)
        expect(described_class).to be_valid('Rmine1zxSdA5KUH4By61sUnhMuk8BR6QnS', 'roger', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('Rmonk1tmbRS1nKfwSeN2WfGZcdRfTQAy11', 'roger', :mainnet)
        expect(described_class).not_to be_valid('RogseRve5vPxMrBKVA72FvhPYUKFEQqc11', 'roger', :mainnet)
        expect(described_class).not_to be_valid('Rmine1zxSdA5KUH4By61sUnhMuk8BR6Q11', 'roger', :mainnet)
      end
    end

    context 'scribe' do
      it 'validates addresses' do
        expect(described_class).to be_valid('R9JyMRYNdvUAeusBv59qCErYCniqw8FsuV', 'scribe', :mainnet)
        expect(described_class).to be_valid('RF4XX6jXDaucyJd3sYHQRyntF5iUSbUhjq', 'scribe', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('R9JyMRYNdvUAeusBv59qCErYCniqw8Fs11', 'scribe', :mainnet)
        expect(described_class).not_to be_valid('RF4XX6jXDaucyJd3sYHQRyntF5iUSbUh11', 'scribe', :mainnet)
      end
    end

    context 'shroud' do
      it 'validates addresses' do
        expect(described_class).to be_valid('SeErAzKoniHdntGt4sbXDYhc9Syf28Cr4p', 'shroud', :mainnet)
        expect(described_class).to be_valid('Saj9YTTRa7EvowsDfG9CvyiHEVvApjeugy', 'shroud', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('SeErAzKoniHdntGt4sbXDYhc9Syf28Cr11', 'shroud', :mainnet)
        expect(described_class).not_to be_valid('Saj9YTTRa7EvowsDfG9CvyiHEVvApjeu11', 'shroud', :mainnet)
      end
    end

    context 'sprx' do
      it 'validates addresses' do
        expect(described_class).to be_valid('SYAaubMmEAma36UxsgrFs4NJKJ4eKL1KyM', 'sprx', :mainnet)
        expect(described_class).to be_valid('SgHKJtvmADc1fTsZvjFj7HmJUCH41fgypf', 'sprx', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('SYAaubMmEAma36UxsgrFs4NJKJ4eKL1K11', 'sprx', :mainnet)
        expect(described_class).not_to be_valid('SgHKJtvmADc1fTsZvjFj7HmJUCH41fgy11', 'sprx', :mainnet)
      end
    end

    context 'sugar' do
      it 'validates addresses' do
        expect(described_class).to be_valid('sugar1qaltnjyuezz597z0lr5dlmna8wug9vv04q95zta', 'sugar', :mainnet)
        expect(described_class).to be_valid('sugar1q4msk84ett3wszvcxyty7qykppges5endulru3h', 'sugar', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('sugar1qaltnjyuezz597z0lr5dlmna8wug9vv04q95z11', 'sugar', :mainnet)
        expect(described_class).not_to be_valid('sugar1q4msk84ett3wszvcxyty7qykppges5endulru11', 'sugar', :mainnet)
      end
    end

    context 'swamp' do
      it 'validates addresses' do
        expect(described_class).to be_valid('WY7eZHp3eJVpq8uZaHZXcxiTLwg8bANriD', 'swamp', :mainnet)
        expect(described_class).to be_valid('Wktg99Ko1DNdJJ2rqgS1qoJmPzqZNpdUBF', 'swamp', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('WY7eZHp3eJVpq8uZaHZXcxiTLwg8bANr11', 'swamp', :mainnet)
        expect(described_class).not_to be_valid('Wktg99Ko1DNdJJ2rqgS1qoJmPzqZNpdU11', 'swamp', :mainnet)
      end
    end

    context 'swift' do
      it 'validates addresses' do
        expect(described_class).to be_valid('8KVqps9JRaCNUnRZ6u8nvV6WjMW9udeJkA', 'swift', :mainnet)
        expect(described_class).to be_valid('8M5WeXtCn5T6oKo1jC89DURnutrBCsmuAK', 'swift', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('8KVqps9JRaCNUnRZ6u8nvV6WjMW9udeJ11', 'swift', :mainnet)
        expect(described_class).not_to be_valid('8M5WeXtCn5T6oKo1jC89DURnutrBCsmu11', 'swift', :mainnet)
      end
    end

    context 'swipp' do
      it 'validates addresses' do
        expect(described_class).to be_valid('SXm37UvM5amMyayCLNQTAAN9KQLUMFMTQa', 'swipp', :mainnet)
        expect(described_class).to be_valid('STypbQxEadhrB6WWht1bbpZBxEzSo6zsi8', 'swipp', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('SXm37UvM5amMyayCLNQTAAN9KQLUMFMT11', 'swipp', :mainnet)
        expect(described_class).not_to be_valid('STypbQxEadhrB6WWht1bbpZBxEzSo6zs11', 'swipp', :mainnet)
      end
    end

    context 'vivo' do
      it 'validates addresses' do
        expect(described_class).to be_valid('VSbKYa21MmorcJbrpHWf1jCnrrN6FXXE54', 'vivo', :mainnet)
        expect(described_class).to be_valid('VPmQoqErV6VtdkBBSBPcuCaJdYwBVyxrYb', 'vivo', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('VSbKYa21MmorcJbrpHWf1jCnrrN6FXXE11', 'vivo', :mainnet)
        expect(described_class).not_to be_valid('VPmQoqErV6VtdkBBSBPcuCaJdYwBVyxr11', 'vivo', :mainnet)
      end
    end

    context 'xep' do
      it 'validates addresses' do
        expect(described_class).to be_valid('ep1qj799qexdrl0ccfgslcluh4j74f0f3vedatcv0k', 'xep', :mainnet)
        expect(described_class).to be_valid('ep1quss4d4nd7cq9r6amnd0amnyj9xv2jh3y6vlwuj', 'xep', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('ep1qj799qexdrl0ccfgslcluh4j74f0f3vedatcv11', 'xep', :mainnet)
        expect(described_class).not_to be_valid('ep1quss4d4nd7cq9r6amnd0amnyj9xv2jh3y6vlw11', 'xep', :mainnet)
      end
    end

    context 'yce' do
      it 'validates addresses' do
        expect(described_class).to be_valid('M9b9HVdUQx9Spfm9z3t3H6GqNGp7tAF1q1', 'yce', :mainnet)
        expect(described_class).to be_valid('MQm9pPuATv1xV5sqVrziVubBiMi992iEpg', 'yce', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('M9b9HVdUQx9Spfm9z3t3H6GqNGp7tAF111', 'yce', :mainnet)
        expect(described_class).not_to be_valid('MQm9pPuATv1xV5sqVrziVubBiMi992iE11', 'yce', :mainnet)
      end
    end

    context 'ytn' do
      it 'validates addresses' do
        expect(described_class).to be_valid('YcE6vVvHMM4rjqNcXbgXkAzekQYLGmu741', 'ytn', :mainnet)
        expect(described_class).to be_valid('YXkupu7ebzgkG8vL6vkTtpUVt59oyRUyU7', 'ytn', :mainnet)
      end

      it 'validates wrong addresses' do
        expect(described_class).not_to be_valid('YcE6vVvHMM4rjqNcXbgXkAzekQYLGmu711', 'ytn', :mainnet)
        expect(described_class).not_to be_valid('YXkupu7ebzgkG8vL6vkTtpUVt59oyRUy11', 'ytn', :mainnet)
      end
    end
  end

  describe '.address_for_coin' do
    it 'returns insance' do
      expect(described_class.address_for_coin('D1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'eth')).to be_kind_of(AdequateCryptoAddress::Eth)
    end

    it 'raises UnknownCurrency with unknown currency' do
      expect { described_class.address_for_coin('addr', 'asdf') }.to raise_error(AdequateCryptoAddress::UnknownCurrency, /asdf/)
    end
  end

  describe '.supported_currency?' do
    it 'list total supported currencies' do
      puts "    #{described_class.supported_currencies.length}"
    end
    it 'all supported currencies exist' do
      cls_constants = described_class.constants.map(&:to_s)
      described_class.supported_currencies.each do |curr|
        expect(cls_constants).to include(curr.capitalize) unless curr == '42'
      end
    end
  end
end
