waitnode and test

pull/56/head
Alok Kothari 6 years ago
parent fb7db3d102
commit 79471ee428
  1. 10
      waitnode/waitNode.go
  2. 26
      waitnode/waitNode_test.go

@ -3,6 +3,7 @@ package waitnode
import ( import (
"net" "net"
"os" "os"
"github.com/simple-rules/harmony-benchmark/log" "github.com/simple-rules/harmony-benchmark/log"
) )
@ -16,7 +17,7 @@ type WaitNode struct {
Address address Address address
Worker string Worker string
ID int ID int
Log log.new() Log log.Logger
} }
func (node *WaitNode) doPoW(pow string) { func (node *WaitNode) doPoW(pow string) {
@ -47,12 +48,11 @@ func (node *WaitNode) listenOnPort(port string) {
} }
// New Create a new Node // New Create a new Node
func New(address *address) *WaitNode { func New(address *address, id int) *WaitNode {
node := WaitNode{} node := WaitNode{}
// Consensus and associated channel to communicate blocks
node.Address = *address node.Address = *address
node.ID = 1 node.ID = id
node.Worker = "pow" node.Worker = "pow"
node.Log = log.new()
return &node return &node
} }

@ -0,0 +1,26 @@
package waitnode
import (
"testing"
"github.com/simple-rules/harmony-benchmark/log"
)
func TestNewNode(test *testing.T) {
Address := address{IP: "1", Port: "2"}
Worker := "pow"
ID := 1
Log := log.new()
node := New(address, ID)
if node.Address == nil {
test.Error("Address is not initialized for the node")
}
if node.ID == nil {
test.Error("ID is not initialized for the node")
}
if node.Wroker == nil {
test.Error("Worker is not initialized for the node")
}
}
Loading…
Cancel
Save