public void TestJavaSerialiazation()
{
var block = new Block(_params, _blockBytes);
var tx = block.Transactions[1];
// Serialize using Java.
byte[] javaBits;
using (var bos = new MemoryStream())
{
var oos = new BinaryFormatter();
oos.Serialize(bos, tx);
javaBits = bos.ToArray();
}
// Deserialize again.
Transaction tx2;
using (var bos = new MemoryStream(javaBits))
{
var ois = new BinaryFormatter();
tx2 = (Transaction) ois.Deserialize(bos);
}
// Note that this will actually check the transactions are equal by doing BitCoin serialization and checking
// the byte streams are the same! A true "deep equals" is not implemented for Transaction. The primary purpose
// of this test is to ensure no errors occur during the Java serialization/deserialization process.
Assert.AreEqual(tx, tx2);
}