github.com/sixexorg/magnetic-ring@v0.0.0-20191119090307-31705a21e419/p2pserver/p2pserver_test.go (about)

     1  /*
     2   * Copyright (C) 2018 The ontology Authors
     3   * This file is part of The ontology library.
     4   *
     5   * The ontology is free software: you can redistribute it and/or modify
     6   * it under the terms of the GNU Lesser General Public License as published by
     7   * the Free Software Foundation, either version 3 of the License, or
     8   * (at your option) any later version.
     9   *
    10   * The ontology is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU Lesser General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU Lesser General Public License
    16   * along with The ontology.  If not, see <http://www.gnu.org/licenses/>.
    17   */
    18  
    19  package p2pserver_test
    20  
    21  import (
    22  	"fmt"
    23  	"testing"
    24  
    25  	"github.com/ontio/ontology/common/log"
    26  	"github.com/sixexorg/magnetic-ring/p2pserver/common"
    27  	"github.com/sixexorg/magnetic-ring/p2pserver"
    28  )
    29  
    30  func TestNewP2PServer(t *testing.T) {
    31  	log.InitLog(log.InfoLog)
    32  	log.Init(log.Stdout)
    33  	fmt.Println("Start test new p2pserver...")
    34  
    35  	p2p := p2pserver.NewServer()
    36  
    37  	if p2p.GetVersion() != common.PROTOCOL_VERSION {
    38  		t.Error("TestNewP2PServer p2p version error", p2p.GetVersion())
    39  	}
    40  
    41  	if p2p.GetVersion() != common.PROTOCOL_VERSION {
    42  		t.Error("TestNewP2PServer p2p version error")
    43  	}
    44  	sync, cons := p2p.GetPort()
    45  	if sync != 20338 {
    46  		t.Error("TestNewP2PServer sync port error")
    47  	}
    48  
    49  	if cons != 20339 {
    50  		t.Error("TestNewP2PServer consensus port error")
    51  	}
    52  }