(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestNode_InitNodeCryptoInfo(t *testing.T) { |
| 62 | Convey("InitNodeCryptoInfo", t, func() { |
| 63 | node := NewNode() |
| 64 | node.InitNodeCryptoInfo(1000 * time.Millisecond) |
| 65 | hashTmp := hash.THashH(append(node.PublicKey.Serialize(), |
| 66 | node.Nonce.Bytes()...)) |
| 67 | t.Logf("ComputeBlockNonce, Difficulty: %d, nonce %v, hash %s", |
| 68 | node.ID.Difficulty(), node.Nonce, hashTmp.String()) |
| 69 | |
| 70 | So(node.ID.Difficulty(), ShouldBeGreaterThan, 1) |
| 71 | So(hashTmp.String(), ShouldEqual, node.ID) |
| 72 | }) |
| 73 | Convey("NodeID Difficulty", t, func() { |
| 74 | var node NodeID |
| 75 | So(node.Difficulty(), ShouldEqual, -1) |
| 76 | node = NodeID("") |
| 77 | So(node.Difficulty(), ShouldEqual, -1) |
| 78 | node = NodeID("1") |
| 79 | So(node.Difficulty(), ShouldEqual, -1) |
| 80 | node = NodeID("00000000011a34cb8142780f692a4097d883aa2ac8a534a070a134f11bcca573") |
| 81 | So(node.Difficulty(), ShouldEqual, 39) |
| 82 | node = NodeID("#0000000011a34cb8142780f692a4097d883aa2ac8a534a070a134f11bcca573") |
| 83 | So(node.Difficulty(), ShouldEqual, -1) |
| 84 | So((*NodeID)(nil).Difficulty(), ShouldEqual, -1) |
| 85 | }) |
| 86 | } |
| 87 | |
| 88 | func TestNodeKey_Less(t *testing.T) { |
| 89 | Convey("NodeID Difficulty", t, func() { |
nothing calls this directly
no test coverage detected