Exemplo n.º 1
0
 public void Init()
 {
     snapshot   = new TestDataCache();
     testengine = new TestEngine(snapshot: snapshot);
     testengine.AddEntryScript("./TestClasses/Contract_Delegate.cs");
 }
Exemplo n.º 2
0
 public void Init()
 {
     testengine = new TestEngine();
     testengine.AddEntryScript("./TestClasses/Contract_InvokeCsNef.cs");
 }
Exemplo n.º 3
0
 public void Init()
 {
     _engine = new TestEngine(snapshot: new TestDataCache());
     _engine.AddEntryScript("./TestClasses/Contract_String.cs");
 }
Exemplo n.º 4
0
 public void Init()
 {
     testengine = new TestEngine();
     testengine.AddEntryScript("./TestClasses/Contract_Returns.cs");
 }
Exemplo n.º 5
0
 public void Init()
 {
     _engine = new TestEngine();
     _engine.AddEntryScript("./TestClasses/Contract_Foreach.cs");
 }
Exemplo n.º 6
0
 public void Init()
 {
     _engine = new TestEngine();
     _engine.AddEntryScript("./TestClasses/Contract_Concat.cs", false, false);
 }
        public void LongParse_Test()
        {
            using var testengine = new TestEngine(snapshot: new TestDataCache());
            testengine.AddEntryScript("./TestClasses/Contract_IntegerParse.cs");
            string methodname = "testLongparse";

            var result = testengine.ExecuteTestCaseStandard(methodname, " -9223372036854775808");
            var value  = result.Pop().GetInteger();

            Assert.AreEqual(-9223372036854775808, value);

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard(methodname, "9223372036854775807");

            value = result.Pop().GetInteger();
            Assert.AreEqual(9223372036854775807, value);

            //test backspace trip
            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard(methodname, "20 ");

            value = result.Pop().GetInteger();
            Assert.AreEqual(20, value);

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard(methodname, " 20 ");

            value = result.Pop().GetInteger();
            Assert.AreEqual(20, value);


            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard(methodname, "-9223372036854775809");

            Assert.AreEqual(VMState.FAULT, testengine.State);
            Assert.IsNotNull(testengine.FaultException);

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard(methodname, "9223372036854775808");

            Assert.AreEqual(VMState.FAULT, testengine.State);
            Assert.IsNotNull(testengine.FaultException);

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard(methodname, "");

            Assert.AreEqual(VMState.FAULT, testengine.State);
            Assert.IsNotNull(testengine.FaultException);

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard(methodname, "abc");

            Assert.AreEqual(VMState.FAULT, testengine.State);
            Assert.IsNotNull(testengine.FaultException);

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard(methodname, "@");

            Assert.AreEqual(VMState.FAULT, testengine.State);
            Assert.IsNotNull(testengine.FaultException);
        }
Exemplo n.º 8
0
 public void Init()
 {
     _engine = new TestEngine();
     _engine.AddEntryScript("./TestClasses/Contract_Enumerator.cs");
 }
Exemplo n.º 9
0
        public void Test_MultipleContracts()
        {
            using (var testengine = new TestEngine())
            {
                Assert.AreEqual(2, Assert.ThrowsException <EntryPointException>(() => testengine.AddEntryScript("./TestClasses/Contract_MultipleContracts.cs")).Count);
            }

            using (var testengine = new TestEngine())
            {
                Assert.AreEqual(2, Assert.ThrowsException <EntryPointException>(() => testengine.AddEntryScript("./TestClasses/Contract_MultipleContracts2.cs")).Count);
            }
        }
 public void Init()
 {
     _engine = new TestEngine();
     Assert.IsTrue(_engine.AddEntryScript("./TestClasses/Contract_Attribute.cs").Success);
 }
Exemplo n.º 11
0
 public void Test_NoEntryPoint()
 {
     using (var testengine = new TestEngine())
     {
         Assert.AreEqual(0, Assert.ThrowsException <EntryPointException>(() => testengine.AddEntryScript("./TestClasses/NoContract.cs")).Count);
     }
 }
Exemplo n.º 12
0
        public void Test_Wrong()
        {
            var testengine = new TestEngine();

            Assert.ThrowsException <NotSupportedException>(() => testengine.AddEntryScript("./TestClasses/Contract_WrongEvent.cs"));
        }
 public void Init()
 {
     _engine = new TestEngine();
     _engine.AddEntryScript("./TestClasses/Contract_Extensions.cs");
 }
Exemplo n.º 14
0
 public void Init()
 {
     _engine = new TestEngine(SmartContract.TriggerType.Application, new DummyVerificable());
     _engine.AddEntryScript("./TestClasses/Contract_ExecutionEngine.cs");
 }
        public void UInt160_ValidateAddress()
        {
            var address = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB".ToScriptHash(ProtocolSettings.Default.AddressVersion);

            using var testengine = new TestEngine();
            testengine.AddEntryScript("./TestClasses/Contract_UIntTypes.cs");

            // True

            var result = testengine.ExecuteTestCaseStandard("validateAddress", address.ToArray());

            Assert.AreEqual(1, result.Count);
            var item = result.Pop();

            Assert.IsTrue(item.GetBoolean());

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard("validateAddress", new ByteString(address.ToArray()));
            Assert.AreEqual(1, result.Count);
            item = result.Pop();
            Assert.IsTrue(item.GetBoolean());

            // False

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard("validateAddress", new byte[1] {
                1
            }.Concat(address.ToArray()).ToArray());
            Assert.AreEqual(1, result.Count);
            item = result.Pop();
            Assert.IsFalse(item.GetBoolean());

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard("validateAddress", BigInteger.One);
            Assert.AreEqual(1, result.Count);
            item = result.Pop();
            Assert.IsFalse(item.GetBoolean());

            testengine.Reset();
            testengine.ExecuteTestCaseStandard("validateAddress", StackItem.Null);
            Assert.AreEqual(VMState.FAULT, testengine.State);

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard("validateAddress", new VM.Types.Array());
            Assert.AreEqual(1, result.Count);
            item = result.Pop();
            Assert.IsFalse(item.GetBoolean());

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard("validateAddress", new Struct());
            Assert.AreEqual(1, result.Count);
            item = result.Pop();
            Assert.IsFalse(item.GetBoolean());

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard("validateAddress", new Map());
            Assert.AreEqual(1, result.Count);
            item = result.Pop();
            Assert.IsFalse(item.GetBoolean());

            testengine.Reset();
            result = testengine.ExecuteTestCaseStandard("validateAddress", StackItem.True);
            Assert.AreEqual(1, result.Count);
            item = result.Pop();
            Assert.IsFalse(item.GetBoolean());
        }
 public void Init()
 {
     testengine = new TestEngine(snapshot: null);
     testengine.AddEntryScript("./TestClasses/Contract_Instance.cs");
 }
Exemplo n.º 17
0
 public void Init()
 {
     testEngine = new TestEngine();
     testEngine.AddEntryScript("./TestClasses/Contract_Property.cs");
 }
Exemplo n.º 18
0
 public void TestByteArrayMap()
 {
     Assert.ThrowsException <System.Exception>(() => _engine.AddEntryScript("./TestClasses/Contract_MapException.cs"));
 }
Exemplo n.º 19
0
 public void Init()
 {
     _engine = new TestEngine(TriggerType.Application, new DummyVerificable());
     _engine.AddEntryScript("./TestClasses/Contract_ExecutionEngine.cs");
     scriptHash = _engine.Nef.Script.Span.ToScriptHash().ToArray().ToHexString();
 }
Exemplo n.º 20
0
 public void double_Test()
 {
     using var testengine = new TestEngine();
     Assert.IsFalse(testengine.AddEntryScript("./TestClasses/Contract_Types_Double.cs").Success);
 }
 public void Test_MultipleContracts()
 {
     using var testengine = new TestEngine();
     Assert.ThrowsException <Exception>(() => testengine.AddEntryScript("./TestClasses/Contract_MultipleContracts.cs"));
 }