public void TestDeserialize() { TrimmedBlock tblock = GetTrimmedBlockWithNoTransaction(); tblock.Hashes = new UInt256[] { TestUtils.GetTransaction(UInt160.Zero).Hash }; var newBlock = new TrimmedBlock(); using (MemoryStream ms = new(1024)) using (BinaryWriter writer = new(ms)) { tblock.Serialize(writer); MemoryReader reader = new(ms.ToArray()); newBlock.Deserialize(ref reader); } tblock.Hashes.Length.Should().Be(newBlock.Hashes.Length); tblock.Header.ToJson(ProtocolSettings.Default).ToString().Should().Be(newBlock.Header.ToJson(ProtocolSettings.Default).ToString()); }
public void TestDeserialize() { TrimmedBlock tblock = GetTrimmedBlockWithNoTransaction(); tblock.Hashes = new UInt256[] { TestUtils.GetTransaction(UInt160.Zero).Hash }; var newBlock = new TrimmedBlock(); using (MemoryStream ms = new MemoryStream(1024)) using (BinaryWriter writer = new BinaryWriter(ms)) using (BinaryReader reader = new BinaryReader(ms)) { tblock.Serialize(writer); ms.Seek(0, SeekOrigin.Begin); newBlock.Deserialize(reader); } tblock.Hashes.Length.Should().Be(newBlock.Hashes.Length); tblock.Header.ToJson().ToString().Should().Be(newBlock.Header.ToJson().ToString()); }