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

Function TestCPUMiner_HashBlock_quit

pow/cpuminer/miner_test.go:97–131  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestCPUMiner_HashBlock_quit(t *testing.T) {
98 minerQuit := make(chan struct{})
99 miner := NewCPUMiner(minerQuit)
100 nonceCh := make(chan NonceInfo)
101 stop := make(chan struct{})
102 diffWanted := 256
103 data := []byte{
104 0x79, 0xa6,
105 }
106 block := MiningBlock{
107 Data: data,
108 NonceChan: nonceCh,
109 Stop: stop,
110 }
111 var (
112 err error
113 )
114 go func() {
115 err = miner.ComputeBlockNonce(block, Uint256{}, diffWanted)
116 }()
117 // stop miner
118 time.Sleep(1 * time.Second)
119 //block.Stop <- struct{}{}
120 miner.quit <- struct{}{}
121
122 nonceFromCh := <-block.NonceChan
123
124 hasha := HashBlock(data, nonceFromCh.Nonce)
125 //hasha := hash.THashH(append(data, nonceFromCh.NonceInfo.Bytes()...))
126 if nonceFromCh.Difficulty < 1 || hasha.Difficulty() != nonceFromCh.Difficulty {
127 t.Errorf("ComputeBlockNonce got %v, difficulty %d, nonce %v, hash %s",
128 err, nonceFromCh.Difficulty, nonceFromCh.Nonce, hasha.String())
129 }
130 t.Logf("Difficulty: %d, Hash: %s", nonceFromCh.Difficulty, hasha.String())
131}

Callers

nothing calls this directly

Calls 6

ComputeBlockNonceMethod · 0.95
NewCPUMinerFunction · 0.85
HashBlockFunction · 0.85
ErrorfMethod · 0.80
DifficultyMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected