Exemplo n.º 1
0
        public void AddAppcallScript(string filename, string specScriptID)
        {
            byte[] hex = NeonTestTool.HexString2Bytes(specScriptID);
            if (hex.Length != 20)
            {
                throw new Exception("fail Script ID");
            }

            if (scriptsAll.ContainsKey(filename) == false)
            {
                scriptsAll[filename] = NeonTestTool.BuildScript(filename);
            }

            scripts[specScriptID.ToLower()] = scriptsAll[filename];
        }
Exemplo n.º 2
0
        private void DumpItem(StackItem item, int space = 0)
        {
            var spacestr = "";

            for (var i = 0; i < space; i++)
            {
                spacestr += "    ";
            }
            Console.WriteLine(spacestr + "got Param:" + item.GetType().ToString());

            if (item is Neo.VM.Types.Array || item is Neo.VM.Types.Struct)
            {
                var array = item as Neo.VM.Types.Array;
                for (var i = 0; i < array.Count; i++)
                {
                    var subitem = array[i];
                    DumpItem(subitem, space + 1);
                }
            }
            else if (item is Neo.VM.Types.Map)
            {
                var map = item as Neo.VM.Types.Map;
                foreach (var subitem in map)
                {
                    Console.WriteLine("---Key---");
                    DumpItemShort(subitem.Key, space + 1);
                    Console.WriteLine("---Value---");
                    DumpItem(subitem.Value, space + 1);
                }
            }
            else
            {
                Console.WriteLine(spacestr + "--as num:" + item.GetBigInteger());

                Console.WriteLine(spacestr + "--as bin:" + NeonTestTool.Bytes2HexString(item.GetByteArray()));
                if (item is Neo.VM.Types.ByteArray)
                {
                    var str = item.GetString();
                    if (CheckAsciiChar(str))
                    {
                        Console.WriteLine(spacestr + "--as str:" + item.GetString());
                    }
                }
            }
        }
Exemplo n.º 3
0
        private bool Contract_Call()
        {
            StackItem item0       = this.CurrentContext.EvaluationStack.Pop();
            var       contractid  = item0.GetByteArray();
            var       contractkey = NeonTestTool.Bytes2HexString(contractid.Reverse().ToArray()).ToLower();
            var       contract    = scripts[contractkey];

            if (contract is null)
            {
                return(false);
            }
            StackItem        item1       = this.CurrentContext.EvaluationStack.Pop();
            StackItem        item2       = this.CurrentContext.EvaluationStack.Pop();
            ExecutionContext context_new = this.LoadScript(contract.finalAVM, 1);

            context_new.EvaluationStack.Push(item2);
            context_new.EvaluationStack.Push(item1);
            return(true);
        }
Exemplo n.º 4
0
        private void DumpItemShort(StackItem item, int space = 0)
        {
            var spacestr = "";

            for (var i = 0; i < space; i++)
            {
                spacestr += "    ";
            }
            var line = NeonTestTool.Bytes2HexString(item.GetByteArray());

            if (item is Neo.VM.Types.ByteArray)
            {
                var str = item.GetString();
                if (CheckAsciiChar(str))
                {
                    line += "|" + str;
                }
            }
            Console.WriteLine(spacestr + line);
        }