public void SaveContractRegistry(ContractRegistry registry) { var data = StateSerialization.SerializeState(registry.GetState()); var typeName = Encoding.ASCII.GetBytes(registry.GetType().Name); this.SaveData(this.integration.contractRegistryAddress, data, typeName); this.integration.logger.LogTrace("Saved registry data: " + data.Length + " bytes"); }
public void Serializes_And_Deserializes_State() { var state = new Dictionary <string, object>() { { "testString", "string value with \n newlines and \t tabs" }, { "testInt", 15 }, { "testDecimal", 15.0m }, { "testBoolean", true }, { "testDictionary", new Dictionary <string, object>() { { "nestedString", "another string value \0 with a null byte" }, { "nestedInt", 42 }, { "nestedTrue", true }, { "nestedFalse", false }, } }, { "testList", new List <object>() { "A string, and an int (- - )", 103, true, } }, }; var serialized = StateSerialization.SerializeState(state); var deserialized = StateSerialization.DeserializeState(serialized); var reserialized = StateSerialization.SerializeState(deserialized); Assert.Equal(serialized, reserialized); Assert.Equal(state, deserialized); }