public void TestWildcardContractPermission()
        {
            var buildScript = NeonTestTool.BuildScript("./TestClasses/Contract_ABIContractPermission.cs", true, false);
            var manifest    = JObject.Parse(buildScript.finalManifest);
            var permissions = manifest["permissions"].ToString(false);

            Assert.AreEqual(@"[{""contract"":""*"",""methods"":[""c""]},{""contract"":""0x01ff00ff00ff00ff00ff00ff00ff00ff00ff00a4"",""methods"":[""a"",""b""]}]", permissions);
        }
        public void GetAllILFunction()
        {
            var nt    = NeonTestTool.BuildScript("./TestClasses/Contract1.cs");
            var names = nt.GetAllILFunction();

            foreach (var n in names)
            {
                Console.WriteLine("got name:" + n);
            }
        }
        public void TestDumpAFunc()
        {
            var testtool  = NeonTestTool.BuildScript("./TestClasses/Contract1.cs");
            var ilmethod  = testtool.FindMethod("Contract1", "UnitTest_001");
            var neomethod = testtool.GetNEOVMMethod(ilmethod);

            DumpAVM(neomethod);
            var bytes = testtool.NeoMethodToBytes(neomethod);

            DumpBytes(bytes);
        }
Example #4
0
        public void UnitTest_TestSafe()
        {
            var buildScript = NeonTestTool.BuildScript("./TestClasses/Contract_ABISafe.cs", true, false);
            var abi         = buildScript.finalABI;

            var methodsABI = abi["methods"] as JArray;

            Assert.IsFalse(methodsABI[1]["safe"].AsBoolean());
            Assert.IsTrue(methodsABI[2]["safe"].AsBoolean());
            Assert.IsFalse(methodsABI[3]["safe"].AsBoolean());
        }
        public void TestDumpAFunc()
        {
            var testtool  = NeonTestTool.BuildScript("./TestClasses_VB/Contract_Return1.vb");
            var ilmethod  = testtool.FindMethod("SmartContract1", "Main");
            var neomethod = testtool.GetNEOVMMethod(ilmethod);

            DumpNEF(neomethod);

            var bytes = testtool.NeoMethodToBytes(neomethod);

            Assert.IsTrue(bytes.Length > 0);
        }
        public void GetAllILFunction()
        {
            var nt    = NeonTestTool.BuildScript("./TestClasses_VB/Contract_Return1.vb");
            var names = nt.GetAllILFunction();

            CollectionAssert.AreEqual(new string[] {
                "System.Void SmartContract1::.ctor()",
                "System.Object SmartContract1::Main()",
                "System.Byte[] SmartContract1::UnitTest_001()"
            },
                                      names);
        }
Example #7
0
        public void UnitTest_TestABIOffsetWithOptimizer()
        {
            var buildScript = NeonTestTool.BuildScript("./TestClasses/Contract_ABIOffset.cs", true, true);
            var abi         = buildScript.finialABI;

            var methodsABI = abi["methods"].AsList();

            Assert.AreEqual("0", methodsABI[0].GetDictItem("offset").ToString());
            Assert.AreEqual("5", methodsABI[1].GetDictItem("offset").ToString());
            Assert.AreEqual("30", methodsABI[2].GetDictItem("offset").ToString());
            // _initialize()
            Assert.AreEqual("36", methodsABI[3].GetDictItem("offset").ToString());
        }
        public void UnitTest_TestABIOffsetWithoutOptimizer()
        {
            var buildScript = NeonTestTool.BuildScript("./TestClasses/Contract_ABIOffset.cs", true, false);
            var abi         = buildScript.finalABI;

            var methodsABI = abi["methods"] as JArray;

            Assert.AreEqual("0", methodsABI[0]["offset"].AsString());
            Assert.AreEqual("6", methodsABI[1]["offset"].AsString());
            Assert.AreEqual("38", methodsABI[2]["offset"].AsString());
            // _initialize()
            Assert.AreEqual("49", methodsABI[3]["offset"].AsString());
        }