public void GetTransaction_Id_SuccessResponse()
        {
            // Arrange
            var blockchainProvider =
                new ProofOfWorkBlockProvider(new MerkleTreeProvider(), _configurationServiceMock.Object);

            var transactionSetList = TransactionDataSet.TransactionData.Select(ts => (HashSet <Transaction>)ts.First())
                                     .ToList();

            transactionSetList[1].First().Id = "111111";

            BlockBase block = null;

            transactionSetList.ForEach(ts =>
                                       block = blockchainProvider.CreateBlock(ts, new DateTime(1, 1, 1), block).Result);

            _blockchainServiceMock.Setup(p => p.GetBlockchainTreeLinked())
            .Returns(new SuccessResponse <BlockBase>("The blockchain!", block));

            const string id = "111111";

            // Act
            var result = _transactionService.GetTransaction(id) as SuccessResponse <Transaction>;

            // Assert
            _blockchainServiceMock.Verify(p => p.GetBlockchainTreeLinked());

            Assert.NotNull(result);
            Assert.NotNull(result.Result);
            Assert.Equal(id, result.Result.Id);
            Assert.NotNull(result.Message);
            Assert.Equal("The transaction has been found", result.Message);
        }
        public ProofOfWorkValidatorTests()
        {
            var configurationServiceMock = new Mock <IConfigurationService>();

            configurationServiceMock.Setup(p => p.GetConfiguration())
            .Returns(new Common.Models.BlockchainNodeConfiguration
            {
                Target    = "0000",
                Version   = "PoW-v1",
                BlockSize = 10
            });

            _proofOfWorkValidator     = new ProofOfWorkValidator(new MerkleTreeValidator());
            _proofOfWorkBlockProvider = new ProofOfWorkBlockProvider(new MerkleTreeProvider(), configurationServiceMock.Object);
        }
Exemplo n.º 3
0
        public ProofOfWorkBlockProviderTests()
        {
            _blockchainNodeConfiguration = new BlockchainNodeConfiguration
            {
                Target    = "0000",
                Version   = "PoW-v1",
                BlockSize = 10,
                NodeId    = "1"
            };

            var configurationServiceMock = new Mock <IConfigurationService>();

            configurationServiceMock.Setup(p => p.GetConfiguration())
            .Returns(_blockchainNodeConfiguration);

            _blockProvider = new ProofOfWorkBlockProvider(new MerkleTreeProvider(), configurationServiceMock.Object);
        }