Permalink
Browse files

Correct ordering of coinbase scripts in tests

Also adds internal tests for transactions
  • Loading branch information...
1 parent c1922be commit 7d341cdc25ee98f52eefc105b763219631cd73bd @neoeinstein committed May 27, 2011
@@ -0,0 +1,24 @@
+using MbUnit.Framework;
+using NHamcrest.Core;
+using xpdm.Bitcoin.Core;
+
+namespace xpdm.Bitcoin.Tests.Core
+{
+ [TestFixture]
+ public class BitcoinObjectTest
+ {
+ #region Utility Asserts
+
+ public static void AssertThatHashMatches(BitcoinObject bitObj, Hash256 expectedHash)
+ {
+ Assert.That(bitObj.Hash256, Is.EqualTo(expectedHash));
+ }
+
+ public static void AssertThatHashMatches(BitcoinObject bitObj, Hash160 expectedHash)
+ {
+ Assert.That(bitObj.Hash160, Is.EqualTo(expectedHash));
+ }
+
+ #endregion
+ }
+}
@@ -0,0 +1,52 @@
+using System.Collections.Generic;
+using Gallio.Framework.Data;
+using MbUnit.Framework;
+using NHamcrest.Core;
+using xpdm.Bitcoin.Core;
+using xpdm.Bitcoin.Tests.Factories.Core;
+
+namespace xpdm.Bitcoin.Tests.Core
+{
+ [TestFixture]
+ public class TransactionTest
+ {
+ [Test]
+ [Factory("TransactionData")]
+ public void VerifyTransactionHash(
+ [Bind(0)] Transaction tx,
+ [Bind(1)] Hash256 txHash)
+ {
+ BitcoinObjectTest.AssertThatHashMatches(tx, txHash);
+ }
+
+ [Test]
+ [Factory("TransactionData")]
+ public void VerifyIsCoinbase(
+ [Bind(0)] Transaction tx,
+ [Bind(2)] bool expectedCoinbase)
+ {
+ Assert.That(tx.TransactionInputs.All(txIn => txIn.IsCoinbase), Is.EqualTo(expectedCoinbase));
+ }
+
+ public static IEnumerable<IDataItem> TransactionData
+ {
+ get
+ {
+ yield return new DataRow(Transactions.Block000000.Tx0, Transactions.Block000000.Tx0_Hash, true);
+ yield return new DataRow(Transactions.Block072783.Tx0, Transactions.Block072783.Tx0_Hash, true);
+ yield return new DataRow(Transactions.Block072783.Tx1, Transactions.Block072783.Tx1_Hash, false);
+ yield return new DataRow(Transactions.Block072785.Tx0, Transactions.Block072785.Tx0_Hash, true);
+ yield return new DataRow(Transactions.Block072785.Tx1, Transactions.Block072785.Tx1_Hash, false);
+ yield return new DataRow(Transactions.Block072785.Tx2, Transactions.Block072785.Tx2_Hash, false);
+ yield return new DataRow(Transactions.Block072785.Tx3, Transactions.Block072785.Tx3_Hash, false);
+ yield return new DataRow(Transactions.Block072785.Tx4, Transactions.Block072785.Tx4_Hash, false);
+ yield return new DataRow(Transactions.Block072785.Tx5, Transactions.Block072785.Tx5_Hash, false);
+ yield return new DataRow(Transactions.Block103640.Tx0, Transactions.Block103640.Tx0_Hash, true);
+ yield return new DataRow(Transactions.Block103640.Tx1, Transactions.Block103640.Tx1_Hash, false);
+ yield return new DataRow(Transactions.Block103958.Tx0, Transactions.Block103958.Tx0_Hash, true);
+ yield return new DataRow(Transactions.Block103958.Tx1, Transactions.Block103958.Tx1_Hash, false);
+ yield return new DataRow(Transactions.Block103958.Tx2, Transactions.Block103958.Tx2_Hash, false);
+ }
+ }
+ }
+}
@@ -19,7 +19,7 @@ public static class Block000000
new TransactionInput
{
Source = TransactionOutpoint.Coinbase,
- Script = new Script(BufferOperations.FromByteString("04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73", Endianness.BigEndian), 0),
+ Script = new Script(BufferOperations.FromByteString("4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73", Endianness.BigEndian), 0),
},
},
TransactionOutputs =
@@ -19,7 +19,7 @@ public static class Block072783
new TransactionInput
{
Source = TransactionOutpoint.Coinbase,
- Script = Script.Parse("1c00ba18 04f3"),
+ Script = Script.Parse("18ba001c f304"),
},
},
TransactionOutputs =
@@ -19,7 +19,7 @@ public static class Block072785
new TransactionInput
{
Source = TransactionOutpoint.Coinbase,
- Script = Script.Parse("1c00ba18 03ce"),
+ Script = Script.Parse("18ba001c ce03"),
},
},
TransactionOutputs =
@@ -191,7 +191,7 @@ public static class Block072785
Source = new TransactionOutpoint
{
SourceTransactionHash = Hash256.Parse("b77e0fc6d275c951342a33473015937e62b25a68538d78a260f1225b2835a283"),
- OutputSequenceNumber = 0,
+ OutputSequenceNumber = 1,
},
Script = Script.Parse("3045022100ade09f7f9c884906899d359dc66407723390382bc5582f70e78e4df8faea7edf02206528f1e2de03733d397beaf8dab9fc81df09400f09a5c3e05502186412af182e01 0499c0b4ce36a491bba7afa0b25408ca3814480feffa3266c9de323fa8f9d3eacd47f534ef2d61e482392825d9932d2d9f976933742cd9f52bc922c21e1d6d5a08"),
},
@@ -19,7 +19,7 @@ public static class Block103640
new TransactionInput
{
Source = TransactionOutpoint.Coinbase,
- Script = Script.Parse("1b038dee 0100013160"),
+ Script = Script.Parse("ee8d031b 6031010001"),
},
},
TransactionOutputs =
@@ -19,7 +19,7 @@ public static class Block103958
new TransactionInput
{
Source = TransactionOutpoint.Coinbase,
- Script = Script.Parse("1b038dee 39"),
+ Script = Script.Parse("ee8d031b 39"),
},
},
TransactionOutputs =
@@ -71,8 +71,10 @@
<Compile Include="BufferOperationsTest.cs" />
<Compile Include="Converters\StringToByteArrayConverter.cs" />
<Compile Include="Converters\Core\StringToScriptConverter.cs" />
+ <Compile Include="Core\BitcoinObjectTest.cs" />
<Compile Include="Core\Hash256Test.cs" />
<Compile Include="Core\TransactionSignatureOperationsTest.cs" />
+ <Compile Include="Core\TransactionTest.cs" />
<Compile Include="Factories\Core\Blocks.cs" />
<Compile Include="Factories\Core\Transactions.Block000000.cs" />
<Compile Include="Factories\Core\Transactions.Block103640.cs" />

0 comments on commit 7d341cd

Please sign in to comment.