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 (
"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
}

@ -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