MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestNode_InitNodeCryptoInfo

Function TestNode_InitNodeCryptoInfo

proto/nodeinfo_test.go:61–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func 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
88func TestNodeKey_Less(t *testing.T) {
89 Convey("NodeID Difficulty", t, func() {

Callers

nothing calls this directly

Calls 8

DifficultyMethod · 0.95
THashHFunction · 0.92
NewNodeFunction · 0.85
NodeIDTypeAlias · 0.85
InitNodeCryptoInfoMethod · 0.80
SerializeMethod · 0.45
BytesMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected