Exemplo n.º 1
0
        public void Run_NotVerifiable_Test(byte[] ba)
        {
            MockOpData data = new MockOpData(FuncCallName.Pop)
            {
                _itemCount = 1,
                popData    = new byte[][] { ba },
            };

            OpTestCaseHelper.RunFailTest <VerifyOp>(data, "Top stack item value was 'false'.");
        }
Exemplo n.º 2
0
        public void Hash160OpTest()
        {
            MockOpData data = new MockOpData(FuncCallName.Pop, FuncCallName.Push)
            {
                _itemCount = 1,
                popData    = new byte[][] { message },
                pushData   = new byte[][] { expHash160 }
            };

            OpTestCaseHelper.RunTest <Hash160Op>(data, OP.HASH160);
        }
        public void Run_ErrorTest(FuncCallName[] expFuncCalls, int count, bool strict, byte[][][] expPopData, string expErr)
        {
            MockOpData data = new MockOpData(expFuncCalls)
            {
                _itemCount     = count,
                popCountData   = expPopData,
                IsStrictDerSig = strict
            };

            OpTestCaseHelper.RunFailTest <CheckSigOp>(data, expErr);
        }
Exemplo n.º 4
0
        public void Run_Equal_Test(byte[] ba1, byte[] ba2)
        {
            MockOpData data = new MockOpData(FuncCallName.Pop, FuncCallName.Pop, FuncCallName.PushBool)
            {
                _itemCount = 2,
                popData    = new byte[][] { ba1, ba2 },
                pushBool   = true
            };

            OpTestCaseHelper.RunTest <EqualOp>(data, OP.EQUAL);
        }
Exemplo n.º 5
0
        public void Sha256OpTest()
        {
            MockOpData data = new MockOpData(FuncCallName.Pop, FuncCallName.Push)
            {
                _itemCount = 1,
                popData    = new byte[][] { message },
                pushData   = new byte[][] { expSha256 }
            };

            OpTestCaseHelper.RunTest <Sha256Op>(data, OP.SHA256);
        }
Exemplo n.º 6
0
        public void RipeMd160OpTest()
        {
            MockOpData data = new MockOpData(FuncCallName.Pop, FuncCallName.Push)
            {
                _itemCount = 1,
                popData    = new byte[][] { message },
                pushData   = new byte[][] { expRipeMd }
            };

            OpTestCaseHelper.RunTest <RipeMd160Op>(data, OP.RIPEMD160);
        }
Exemplo n.º 7
0
        public void Run_Verifiable_Test()
        {
            MockOpData data = new MockOpData(FuncCallName.Pop)
            {
                _itemCount = 1,
                // Any value apart from 0 and -0 are considered true
                popData = new byte[][] { OpTestCaseHelper.b1 },
            };

            OpTestCaseHelper.RunTest <VerifyOp>(data, OP.VERIFY);
        }
Exemplo n.º 8
0
        public void Run_ItemCountOverflowTest2()
        {
            MockOpData data = new MockOpData(FuncCallName.Peek, FuncCallName.Push)
            {
                _itemCount    = 501,
                _altItemCount = 500,
                peekData      = new byte[][] { OpTestCaseHelper.b1 },
                pushData      = new byte[][] { OpTestCaseHelper.num3 },
            };

            OpTestCaseHelper.RunFailTest <SizeOp>(data, Err.OpStackItemOverflow);
        }
Exemplo n.º 9
0
        public void RunTest()
        {
            MockOpData data = new MockOpData(FuncCallName.Peek, FuncCallName.Push)
            {
                _itemCount    = 1,
                _altItemCount = 0,
                peekData      = new byte[][] { OpTestCaseHelper.b1 },
                pushData      = new byte[][] { OpTestCaseHelper.num3 },
            };

            OpTestCaseHelper.RunTest <SizeOp>(data, OP.SIZE);
        }
Exemplo n.º 10
0
        public void Run_ErrorTest(FuncCallName[] expFuncCalls, int count, bool strict, byte[][][] expPopData, string expErr)
        {
            // Note that MockOpData makes sure IOpData.Verify() is _not_ called in any of these cases
            MockOpData data = new MockOpData(expFuncCalls)
            {
                _itemCount     = count,
                popCountData   = expPopData,
                IsStrictDerSig = strict
            };

            OpTestCaseHelper.RunFailTest <CheckSigVerifyOp>(data, expErr);
        }
        public void Run_FailTest(int count, long expSeq, byte[] peekData, string expErr)
        {
            MockOpData data = new MockOpData(FuncCallName.Peek)
            {
                _itemCount                  = count,
                bip112                      = true,
                expectedSequence            = expSeq,
                SequenceVerificationSuccess = false,
                peekData                    = new byte[][] { peekData }
            };

            OpTestCaseHelper.RunFailTest <CheckSequenceVerifyOp>(data, expErr);
        }
        public void RunTest()
        {
            MockOpData data = new MockOpData(FuncCallName.Peek)
            {
                _itemCount                  = 1,
                bip112                      = true,
                expectedSequence            = 17,
                SequenceVerificationSuccess = true,
                peekData                    = new byte[][] { OpTestCaseHelper.num17 }
            };

            OpTestCaseHelper.RunTest <CheckSequenceVerifyOp>(data, OP.CheckSequenceVerify);
        }
Exemplo n.º 13
0
        public void RunTest()
        {
            MockOpData data = new MockOpData(FuncCallName.Peek)
            {
                _itemCount                  = 1,
                bip65                       = true,
                expectedLocktime            = 16,
                locktimeVerificationSuccess = true,
                peekData                    = new byte[][] { OpTestCaseHelper.num16 }
            };

            OpTestCaseHelper.RunTest <CheckLocktimeVerifyOp>(data, OP.CheckLocktimeVerify);
        }
Exemplo n.º 14
0
        public void CheckItemCountTest(MockOpData data, bool success)
        {
            bool b = CheckItemCount(data, out string error);

            if (success)
            {
                Assert.True(b, error);
            }
            else
            {
                Assert.False(b);
                Assert.Equal(Err.OpStackItemOverflow, error);
            }
        }
Exemplo n.º 15
0
        public void Run_CorrectSigTest()
        {
            MockOpData data = new MockOpData(FuncCallName.PopCount)
            {
                _itemCount             = 2,
                expectedSig            = Helper.ShortSig1,
                expectedPubkey         = KeyHelper.Pub1,
                expectedSigBa          = Helper.ShortSig1Bytes,
                sigVerificationSuccess = true,
                popCountData           = new byte[][][] { new byte[][] { Helper.ShortSig1Bytes, KeyHelper.Pub1CompBytes } },
            };

            OpTestCaseHelper.RunTest <CheckSigVerifyOp>(data, OP.CheckSigVerify);
        }
Exemplo n.º 16
0
        public void Run_WrongSigTest()
        {
            MockOpData data = new MockOpData(FuncCallName.PopCount)
            {
                _itemCount             = 2,
                expectedSig            = Helper.ShortSig1,
                expectedPubkey         = KeyHelper.Pub1,
                expectedSigBa          = Helper.ShortSig1Bytes,
                sigVerificationSuccess = false,
                popCountData           = new byte[][][] { new byte[][] { Helper.ShortSig1Bytes, KeyHelper.Pub1CompBytes } },
            };

            OpTestCaseHelper.RunFailTest <CheckSigVerifyOp>(data, "Signature verification failed.");
        }
        public void RunTest(Signature expSig, PublicKey expPub, byte[] expSigBa, bool success, bool der, byte[][] pop, bool expBool)
        {
            MockOpData data = new MockOpData(FuncCallName.PopCount, FuncCallName.PushBool)
            {
                _itemCount             = 2,
                expectedSig            = expSig,
                expectedPubkey         = expPub,
                expectedSigBa          = expSigBa,
                sigVerificationSuccess = success,
                IsStrictDerSig         = der,
                popCountData           = new byte[][][] { pop },
                pushBool = expBool
            };

            OpTestCaseHelper.RunTest <CheckSigOp>(data, OP.CheckSig);
        }