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(); }
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(); }
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); }
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); }
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)); }
public void test_key_prefix_invalid_single_byte() { var keyJson = new JObject(new JProperty("prefix", 1000)); Assert.Throws <OverflowException>(() => ContractStorageSchema.ParseKeyPrefix(keyJson)); }