Ejemplo n.º 1
0
        public async void TwoUnevenPiecesInvalidFromVerified()
        {
            var expectedDigest = "0000000000000000000000000000000000000000".FromHex();
            var verified       = VerifiedBytes.From("hello".ToASCII(), expectedDigest, 3);

            await Assert.ThrowsAsync <BytesVerificationException>(async() => {
                await verified.Result;
            });
        }
Ejemplo n.º 2
0
        public async void TwoUnevenPiecesValidFromVerified()
        {
            var expectedDigest = "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d".FromHex();
            var verified       = VerifiedBytes.From("hello".ToASCII(), expectedDigest, 3);

            Assert.Equal(expectedDigest, verified.Digest);

            var resultValue = await verified.Result;

            Assert.Equal("hello".ToASCII(), resultValue);

            // Data can only be provided once.
            Assert.Throws <VerifiedBytesStateException>(() => {
                verified.ProvideData("hello".ToASCII());
            });
            Assert.Throws <VerifiedBytesStateException>(() => {
                verified.ProvidePiece(0, "hel".ToASCII());
            });
        }