public void Current()
        {
            IByteBuffer buf = _ser.ZeroSerialize(_txMsg);

            _zeroPacket            = new ZeroPacket(buf);
            _zeroPacket.PacketType = buf.ReadByte();
            _zeroPacket.PacketType = Eth62MessageCode.Transactions;
            _handler.HandleMessage(_zeroPacket);
        }
예제 #2
0
        public void SetUp()
        {
            Console.WriteLine("AAA");
            Session session = new Session(8545, Substitute.For <IChannel>(), Substitute.For <IDisconnectsAnalyzer>(), LimboLogs.Instance);

            session.RemoteNodeId = TestItem.PublicKeyA;
            session.RemoteHost   = "127.0.0.1";
            session.RemotePort   = 30303;
            _ser = new MessageSerializationService();
            _ser.Register(new TransactionsMessageSerializer());
            _ser.Register(new StatusMessageSerializer());
            NodeStatsManager stats = new NodeStatsManager(TimerFactory.Default, LimboLogs.Instance);
            var ecdsa         = new EthereumEcdsa(ChainId.Mainnet, LimboLogs.Instance);
            var tree          = Build.A.BlockTree().TestObject;
            var stateProvider = new StateProvider(new TrieStore(new MemDb(), LimboLogs.Instance), new MemDb(), LimboLogs.Instance);
            var specProvider  = MainnetSpecProvider.Instance;

            TxPool.TxPool txPool = new TxPool.TxPool(
                ecdsa,
                new ChainHeadInfoProvider(new FixedBlockChainHeadSpecProvider(MainnetSpecProvider.Instance), tree, stateProvider),
                new TxPoolConfig(),
                new TxValidator(ChainId.Mainnet),
                LimboLogs.Instance,
                new TransactionComparerProvider(specProvider, tree).GetDefaultComparer());
            ISyncServer syncSrv = Substitute.For <ISyncServer>();
            BlockHeader head    = Build.A.BlockHeader.WithNumber(1).TestObject;

            syncSrv.Head.Returns(head);
            _handler = new Eth62ProtocolHandler(session, _ser, stats, syncSrv, txPool, ShouldGossip.Instance, LimboLogs.Instance);
            _handler.DisableTxFiltering();

            StatusMessage statusMessage = new StatusMessage();

            statusMessage.ProtocolVersion = 63;
            statusMessage.BestHash        = Keccak.Compute("1");
            statusMessage.GenesisHash     = Keccak.Compute("0");
            statusMessage.TotalDifficulty = 131200;
            statusMessage.ChainId         = 1;
            IByteBuffer bufStatus = _ser.ZeroSerialize(statusMessage);

            _zeroPacket            = new ZeroPacket(bufStatus);
            _zeroPacket.PacketType = bufStatus.ReadByte();

            _handler.HandleMessage(_zeroPacket);

            Transaction tx = Build.A.Transaction.SignedAndResolved(ecdsa, TestItem.PrivateKeyA).TestObject;

            _txMsg = new TransactionsMessage(new[] { tx });
        }