Sha256: 464929e598b6ad0be8684cf2649b83a9c21e0e24695383a7cb7e3b703fdcb9be
Contents?: true
Size: 1.53 KB
Versions: 22
Compression:
Stored size: 1.53 KB
Contents
require 'spec_helper' describe Stellar::Util::StrKey do subject{ Stellar::Util::StrKey } describe "#check_decode" do it "properly decodes" do expect(decode :seed, "SAAAAAAAAAADST3H").to eq_bytes("\x00\x00\x00\x00\x00\x00\x39") expect(decode :account_id, "GD777777777764TU").to eq_bytes("\xFF\xFF\xFF\xFF\xFF\xFF\xFF") expect(decode :account_id, "GBQWWBFLRP3BXZD5").to eq_bytes("\x61\x6b\x04\xab\x8b\xf6\x1b") end it "raises an ArgumentError if the decoded version byte does not match the expected value" do expect{ decode :seed, "GD777777777764TU" }.to raise_error(ArgumentError) expect{ decode :account_id, "SAAAAAAAAAADST3M" }.to raise_error(ArgumentError) end it "raises an ArgumentError if the decoded value cannot be validated by the checksum" do expect{decode :seed, "SAAAAAAAAAADST3M"}.to raise_error(ArgumentError) end def decode(version, bytes) subject.check_decode(version, bytes) end end describe"#check_encode" do it "properly encodes" do expect(encode :seed, "\x00\x00\x00\x00\x00\x00\x39").to eq("SAAAAAAAAAADST3H") expect(encode :account_id, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF").to eq("GD777777777764TU") expect(encode :account_id, "\x61\x6b\x04\xab\x8b\xf6\x1b").to eq("GBQWWBFLRP3BXZD5") end it "raises an ArgumentError when an invalid version is provided" do expect{ encode :floob, "\x39" }.to raise_error(ArgumentError) end def encode(version, bytes) subject.check_encode(version, bytes) end end end
Version data entries
22 entries across 22 versions & 3 rubygems