예제 #1
0
        public void TestToJson()
        {
            JObject nep6contract = new JObject();

            nep6contract["script"] = "2103603f3880eb7aea0ad4500893925e4a42fea48a44ee6f898a10b3c7ce05d2a267ac";
            JObject parameters = new JObject();

            parameters["type"] = 0x00;
            parameters["name"] = "Sig";
            JArray array = new JArray
            {
                parameters
            };

            nep6contract["parameters"] = array;
            nep6contract["deployed"]   = false;
            account.Contract           = TLP6Contract.FromJson(nep6contract);
            JObject json = account.ToJson();

            json["address"].Should().Equals("AZk5bAanTtD6AvpeesmYgL8CLRYUt5JQsX");
            json["label"].Should().BeNull();
            json["isDefault"].ToString().Should().Be("false");
            json["lock"].ToString().Should().Be("false");
            json["key"].Should().BeNull();
            json["contract"]["script"].ToString().Should().Be("\"2103603f3880eb7aea0ad4500893925e4a42fea48a44ee6f898a10b3c7ce05d2a267ac\"");
            json["extra"].Should().BeNull();

            account.Contract = null;
            json             = account.ToJson();
            json["contract"].Should().BeNull();
        }
예제 #2
0
        public void TestFromJson()
        {
            string json = "{\"script\":\"2103ef891df4c0b7eefb937d21ea0fb88cde8e0d82a7ff11872b5e7047969dafb4eb68747476aa\"," +
                          "\"parameters\":[{\"name\":\"signature\",\"type\":\"Signature\"}],\"deployed\":false}";
            JObject @object = JObject.Parse(json);

            var tlp6Contract = TLP6Contract.FromJson(@object);

            tlp6Contract.Script.Should().BeEquivalentTo("2103ef891df4c0b7eefb937d21ea0fb88cde8e0d82a7ff11872b5e7047969dafb4eb68747476aa".HexToBytes());
            tlp6Contract.ParameterList.Length.Should().Be(1);
            tlp6Contract.ParameterList[0].Should().Be(ContractParameterType.Signature);
            tlp6Contract.ParameterNames.Length.Should().Be(1);
            tlp6Contract.ParameterNames[0].Should().Be("signature");
            tlp6Contract.Deployed.Should().BeFalse();
        }
예제 #3
0
        public void TestFromNullJson()
        {
            var tlp6Contract = TLP6Contract.FromJson(null);

            tlp6Contract.Should().BeNull();
        }