示例#1
0
        public void TryDecodeTest(byte[] expBa, Bech32.Mode mode, byte expWitVer, string expHrp, string bechStr)
        {
            bool b = Bech32.TryDecode(bechStr, mode, out byte[] actualBa, out byte actualWitVer, out string actualHrp);

            Assert.True(b);
            Assert.Equal(expBa, actualBa);
            Assert.Equal(expWitVer, actualWitVer);
            Assert.Equal(expHrp, actualHrp);
        }
示例#2
0
        public void Decode_ExceptionTests(string bech, Bech32.Mode mode, byte expWitVer, string expHrp, string expErr)
        {
            byte      actWitVer = 255;
            string    actHrp    = ".";
            Exception ex        = Assert.Throws <FormatException>(() => Bech32.Decode(bech, mode, out actWitVer, out actHrp));

            Assert.Equal(expWitVer, actWitVer);
            Assert.Equal(expHrp, actHrp);
            Assert.Contains(expErr, ex.Message);

            bool b = Bech32.TryDecode(bech, mode, out byte[] result, out actWitVer, out actHrp);

            Assert.False(b);
            Assert.Null(result);
            Assert.Equal(0, actWitVer);
        }