public void TestClone() { TrimmedBlock tblock = GetTrimmedBlockWithNoTransaction(); tblock.Hashes = new UInt256[] { TestUtils.GetTransaction().Hash }; ICloneable <TrimmedBlock> cloneable = tblock; var clonedBlock = cloneable.Clone(); clonedBlock.ToJson().ToString().Should().Be(tblock.ToJson().ToString()); }
public void TestFromReplica() { TrimmedBlock tblock = GetTrimmedBlockWithNoTransaction(); tblock.Hashes = new UInt256[] { TestUtils.GetTransaction().Hash }; ICloneable <TrimmedBlock> cloneable = new TrimmedBlock(); cloneable.FromReplica(tblock); ((TrimmedBlock)cloneable).ToJson().ToString().Should().Be(tblock.ToJson().ToString()); }
public void TestDeserialize() { TrimmedBlock tblock = GetTrimmedBlockWithNoTransaction(); tblock.Hashes = new UInt256[] { TestUtils.GetTransaction().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.MerkleRoot.Should().Be(newBlock.MerkleRoot); tblock.PrevHash.Should().Be(newBlock.PrevHash); tblock.Timestamp.Should().Be(newBlock.Timestamp); tblock.Hashes.Length.Should().Be(newBlock.Hashes.Length); tblock.Witness.ScriptHash.Should().Be(newBlock.Witness.ScriptHash); tblock.ToJson().ToString().Should().Be(newBlock.ToJson().ToString()); }