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

            nep6contract["script"] = "IQNgPziA63rqCtRQCJOSXkpC/qSKRO5viYoQs8fOBdKiZ6w=";
            JObject parameters = new JObject();

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

            nep6contract["parameters"] = array;
            nep6contract["deployed"]   = false;
            _account.Contract          = NEP6Contract.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("\"IQNgPziA63rqCtRQCJOSXkpC\\/qSKRO5viYoQs8fOBdKiZ6w=\"");
            json["extra"].Should().BeNull();

            _account.Contract = null;
            json = _account.ToJson();
            json["contract"].Should().BeNull();
        }
Exemple #2
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          = NEP6Contract.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();
        }
Exemple #3
0
        public void TestToJson()
        {
            JObject nep6contract = new();

            nep6contract["script"] = "IQNgPziA63rqCtRQCJOSXkpC/qSKRO5viYoQs8fOBdKiZ6w=";
            JObject parameters = new();

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

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

            json["address"].AsString().Should().Be("NdtB8RXRmJ7Nhw1FPTm7E6HoDZGnDw37nf");
            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(@"""IQNgPziA63rqCtRQCJOSXkpC/qSKRO5viYoQs8fOBdKiZ6w=""");
            json["extra"].Should().BeNull();

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

            NEP6Contract nep6Contract = NEP6Contract.FromJson(@object);

            nep6Contract.Script.Should().BeEquivalentTo("2103ef891df4c0b7eefb937d21ea0fb88cde8e0d82a7ff11872b5e7047969dafb4eb68747476aa".HexToBytes());
            nep6Contract.ParameterList.Length.Should().Be(1);
            nep6Contract.ParameterList[0].Should().Be(ContractParameterType.Signature);
            nep6Contract.ParameterNames.Length.Should().Be(1);
            nep6Contract.ParameterNames[0].Should().Be("signature");
            nep6Contract.Deployed.Should().BeFalse();
        }
Exemple #5
0
        public void TestFromNullJson()
        {
            NEP6Contract nep6Contract = NEP6Contract.FromJson(null);

            nep6Contract.Should().BeNull();
        }