コード例 #1
0
ファイル: Bootstrap.cs プロジェクト: PlumpMath/NBlockchain-1
 /// <summary>
 /// Run the communication machine
 /// </summary>
 public void Run()
 {
     m_BlockchainStore = new BlockchainStore();
     Network.INetworkAgentAPI _newNetwork = new CommunicationEngine(m_BlockchainStore);
     m_Agent = new AgentAPI.AgentServices(m_BlockchainStore, _newNetwork, Log);
     _newNetwork.initP2PServer();
 }
コード例 #2
0
        public void stringifyTestMethod()
        {
            IRepositoryAgentInterface _newBlockchainStore = new BlockchainStore(message => { });
            string _newBlockString = _newBlockchainStore.stringify();
            string _expected       = "[{\"data\":\"my genesis block!!\",\"hash\":\"816534932c2b7154836da6afc367695e6337db8a921823784c14378abed4f7d7\",\"index\":0,\"previousHash\":\"0\",\"timestamp\":1465154705}]";

            Assert.AreEqual <string>(_expected, _newBlockString);
        }
コード例 #3
0
        public void generateNextBlockTestMethod()
        {
            List <string>             _log = new List <string>();
            IRepositoryAgentInterface _newBlockchainStore = new BlockchainStore(message => _log.Add(message));
            const string _testString     = "generate Next Block";
            IBlock       _newBlock       = _newBlockchainStore.generateNextBlock(_testString);
            string       _newBlockString = _newBlock.stringify();
            string       _chain          = _newBlockchainStore.stringify();

            Assert.IsTrue(_chain.Contains(_testString));
        }
コード例 #4
0
 /// <summary>
 /// Run the communication machine
 /// </summary>
 public async Task Run(int p2pPortNumber, int _AgentHTTPServerPortNumber)
 {
     try
     {
         m_BlockchainStore     = new BlockchainStore(Log);
         m_CommunicationEngine = new CommunicationEngine(m_BlockchainStore, p2pPortNumber, Log);
         m_Agent = new AgentAPI.AgentServices(m_BlockchainStore, m_CommunicationEngine, _AgentHTTPServerPortNumber, Log);
         await m_CommunicationEngine.InitP2PServerAsync();
     }
     catch (Exception ex)
     {
         Log($"The aplikcation has been handled by the exception {ex}");
     }
 }
コード例 #5
0
        public void ConstructoTestMethod()
        {
            IRepositoryAgentInterface _newBlockchainStore = new BlockchainStore(message => { });

            Assert.IsNotNull(_newBlockchainStore);
        }