Example #1
0
        public async Task GetRawTransactionAsync_TransactionNotInPooledTransaction_ReturnsTransactionFromBlockStoreAsync()
        {
            uint256 txId = new uint256(12142124);

            this.pooledTransaction.Setup(p => p.GetTransaction(txId))
            .ReturnsAsync((Transaction)null);
            Transaction transaction = this.CreateTransaction();
            var         blockStore  = new Mock <IBlockStore>();

            blockStore.Setup(b => b.GetTrxAsync(txId))
            .ReturnsAsync(transaction);
            this.fullNode.Setup(f => f.NodeFeature <IBlockStore>(false))
            .Returns(blockStore.Object);
            this.controller = new NodeController(this.fullNode.Object, this.LoggerFactory.Object,
                                                 this.dateTimeProvider.Object, this.chainState.Object, this.nodeSettings,
                                                 this.connectionManager.Object, this.chain, this.network, this.pooledTransaction.Object,
                                                 this.pooledGetUnspentTransaction.Object, this.getUnspentTransaction.Object, this.networkDifficulty.Object);
            string txid    = txId.ToString();
            bool   verbose = false;

            var json = (JsonResult)await this.controller.GetRawTransactionAsync(txid, verbose).ConfigureAwait(false);

            TransactionBriefModel resultModel = (TransactionBriefModel)json.Value;

            Assert.NotNull(json);
            var model = Assert.IsType <TransactionBriefModel>(resultModel);

            Assert.Equal(transaction.ToHex(), model.Hex);
        }
        public TransactionModelsTest()
        {
            var network = Network.Main;

            this.txBlock10CoinbaseModelBrief       = new TransactionBriefModel(network.CreateTransaction(TxBlock10Hex));
            this.txBlock460373CoinbaseModelVerbose = new TransactionVerboseModel(network.CreateTransaction(TxBlock460373CoinbaseHex), network);
            this.txTwoInTwoOutModelVerbose         = new TransactionVerboseModel(network.CreateTransaction(TxTwoInTwoOutHex), network);
        }
        public void TransactionModelBriefRenderTest()
        {
            TransactionBriefModel model = this.txBlock10CoinbaseModelBrief;
            string json = ModelToJson(model);

            string expectedJson = "\"" + TxBlock10Hex + "\"";

            Assert.Equal(expectedJson, json);
        }
Example #4
0
        public TransactionModelsTest()
        {
            Block.BlockSignature  = false;
            Transaction.TimeStamp = false;

            this.txBlock10CoinbaseModelBrief       = new TransactionBriefModel(Transaction.Parse(TxBlock10Hex));
            this.txBlock460373CoinbaseModelVerbose = new TransactionVerboseModel(Transaction.Parse(TxBlock460373CoinbaseHex), Network.PurpleMain);
            this.txTwoInTwoOutModelVerbose         = new TransactionVerboseModel(Transaction.Parse(TxTwoInTwoOutHex), Network.PurpleMain);
        }
 public void Dispose()
 {
     this.txBlock10CoinbaseModelBrief       = null;
     this.txBlock460373CoinbaseModelVerbose = null;
     this.txTwoInTwoOutModelVerbose         = null;
 }
 public TransactionModelsTest()
 {
     this.txBlock10CoinbaseModelBrief       = new TransactionBriefModel(Transaction.Parse(txBlock10Hex));
     this.txBlock460373CoinbaseModelVerbose = new TransactionVerboseModel(Transaction.Parse(txBlock460373CoinbaseHex), Network.Main);
     this.txTwoInTwoOutModelVerbose         = new TransactionVerboseModel(Transaction.Parse(txTwoInTwoOutHex), Network.Main);
 }