identity chain is working fixed listen on port

pull/61/head
Alok Kothari 6 years ago
parent b46bdaff40
commit 4a97f541cd
  1. 4
      identitychain/identitychain.go
  2. 20
      identitychain/identitychain_test.go

@ -93,13 +93,12 @@ func (IDC *IdentityChain) UpdateIdentityChain() {
}
func (IDC *IdentityChain) listenOnPort() {
fmt.Print(IDC.Peer.Port)
listen, err := net.Listen("tcp4", ":"+IDC.Peer.Port)
if err != nil {
IDC.log.Crit("Socket listen port failed")
os.Exit(1)
} else {
IDC.log.Info("Identity chain is now listening..")
IDC.log.Info("Identity chain is now listening ..")
}
defer listen.Close()
for {
@ -116,5 +115,6 @@ func (IDC *IdentityChain) listenOnPort() {
func New(Peer p2p.Peer) *IdentityChain {
IDC := IdentityChain{}
IDC.Peer = Peer
IDC.log = log.New()
return &IDC
}

@ -1,16 +1,18 @@
package identitychain
import (
"fmt"
"os"
"testing"
"github.com/simple-rules/harmony-benchmark/p2p"
)
func TestConnAlive(test *testing.T) {
// peer := p2p.Peer{Ip: "127.0.0.1", Port: "8080"}
// IDC := New(peer)
// IDC.listenOnPort()
// // conn, err := net.Dial("tcp", IDC.Peer.Ip+":"+IDC.Peer.Port)
// // if err != nil {
// // test.Fatal(err)
// // }
// // defer conn.Close()
func TestIDCFormed(test *testing.T) {
peer := p2p.Peer{Ip: "127.0.0.1", Port: "8080"}
IDC := New(peer)
if IDC == nil {
fmt.Println("IDC not formed.")
os.Exit(1)
}
}

Loading…
Cancel
Save