diff --git a/waitnode/waitNode.go b/waitnode/waitNode.go index 653c8ca6f..18b80370d 100644 --- a/waitnode/waitNode.go +++ b/waitnode/waitNode.go @@ -3,6 +3,7 @@ package waitnode import ( "net" "os" + "github.com/simple-rules/harmony-benchmark/log" ) @@ -16,7 +17,7 @@ type WaitNode struct { Address address Worker string ID int - Log log.new() + Log log.Logger } func (node *WaitNode) doPoW(pow string) { @@ -47,12 +48,11 @@ func (node *WaitNode) listenOnPort(port string) { } // New Create a new Node -func New(address *address) *WaitNode { +func New(address *address, id int) *WaitNode { node := WaitNode{} - - // Consensus and associated channel to communicate blocks node.Address = *address - node.ID = 1 + node.ID = id node.Worker = "pow" + node.Log = log.new() return &node } diff --git a/waitnode/waitNode_test.go b/waitnode/waitNode_test.go new file mode 100644 index 000000000..0bc7c66b6 --- /dev/null +++ b/waitnode/waitNode_test.go @@ -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") + } +}