Represents a lookup key to locate a transaction within a block.
Ejemplo n.º 1
0
        public void TestExceptionInLoadTxInput()
        {
            var expectedException = new Exception();

            var coreStorage = new Mock<ICoreStorage>();

            var chainedHeader = RandomData.RandomChainedHeader();
            var tx = RandomData.RandomTransaction(new RandomDataOptions { TxInputCount = 1 });
            var txLookupKey = new TxLookupKey(UInt256.Zero, 0);
            var loadingTx = new LoadingTx(1, tx, chainedHeader, ImmutableArray.Create(txLookupKey));

            var loadingTxes = new BufferBlock<LoadingTx>();
            loadingTxes.Post(loadingTx);
            loadingTxes.Complete();

            // throw expected exception when the input transaction is looked up
            Transaction outputTx = null;
            coreStorage.Setup(x => x.TryGetTransaction(txLookupKey.BlockHash, txLookupKey.TxIndex, out outputTx)).Throws(expectedException);

            var loadedTxes = TxLoader.LoadTxes(coreStorage.Object, loadingTxes);

            Exception actualEx;
            AssertMethods.AssertAggregateThrows<Exception>(() =>
                loadedTxes.ToEnumerable().ToList(), out actualEx);
            Assert.AreSame(expectedException, actualEx);
        }
Ejemplo n.º 2
0
 public static byte[] EncodeTxLookupKey(TxLookupKey txLookupKey)
 {
     using (var stream = new MemoryStream())
     using (var writer = new BinaryWriter(stream))
     {
         EncodeTxLookupKey(writer, txLookupKey);
         return stream.ToArray();
     }
 }
Ejemplo n.º 3
0
 public static void EncodeTxLookupKey(BinaryWriter writer, TxLookupKey txLookupKey)
 {
     writer.WriteUInt256(txLookupKey.BlockHash);
     writer.WriteInt32(txLookupKey.TxIndex);
 }