예제 #1
0
        public void test_key_prefix_single_byte()
        {
            var keyJson = new JObject(new JProperty("prefix", 42));
            var prefix  = ContractStorageSchema.ParseKeyPrefix(keyJson);

            prefix.Span.SequenceEqual(new byte[] { 42 }).Should().BeTrue();
        }
예제 #2
0
        public void test_key_prefix_string()
        {
            var keyJson = new JObject(new JProperty("prefix", "test"));
            var prefix  = ContractStorageSchema.ParseKeyPrefix(keyJson);

            prefix.Span.SequenceEqual(new byte[] { 0x74, 0x65, 0x73, 0x74 }).Should().BeTrue();
        }
예제 #3
0
        public void test_nft_schema()
        {
            var json   = Utility.GetResourceJson("nft-schema.json");
            var schema = ContractStorageSchema.Parse((JObject)json);

            schema.StructDefs.Should().HaveCount(1);
            schema.StorageDefs.Should().HaveCount(6);
        }
예제 #4
0
        public void test_parse_array_primitive()
        {
            var text = "Array<Integer>";
            var map  = new Dictionary <string, StructContractType>();

            ContractStorageSchema.TryParseContractType(text, map, out var actual).Should().BeTrue();

            var expected = new ArrayContractType(PrimitiveContractType.Integer);

            actual.Should()
            .NotBeNull()
            .And.Be(expected);
        }
예제 #5
0
        public void test_key_prefix_invalid_byte_in_array()
        {
            var keyJson = new JObject(new JProperty("prefix", new JArray(42, 1000, 48)));

            Assert.Throws <OverflowException>(() => ContractStorageSchema.ParseKeyPrefix(keyJson));
        }
예제 #6
0
        public void test_key_prefix_invalid_single_byte()
        {
            var keyJson = new JObject(new JProperty("prefix", 1000));

            Assert.Throws <OverflowException>(() => ContractStorageSchema.ParseKeyPrefix(keyJson));
        }