Kevacoin stratum server for solo-mining
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
681 B

10 years ago
package util
import (
"encoding/hex"
"math/big"
"testing"
)
func TestGetTargetHex(t *testing.T) {
8 years ago
targetHex := GetTargetHex(500)
10 years ago
expectedHex := "6e128300"
if targetHex != expectedHex {
t.Error("Invalid targetHex")
}
8 years ago
targetHex = GetTargetHex(15000)
10 years ago
expectedHex = "7b5e0400"
if targetHex != expectedHex {
t.Error("Invalid targetHex")
}
}
func TestGetHashDifficulty(t *testing.T) {
hash := "8e3c1865f22801dc3df0a688da80701e2390e7838e65c142604cc00eafe34000"
hashBytes, _ := hex.DecodeString(hash)
diff := new(big.Int)
diff.SetBytes(reverse(hashBytes))
shareDiff := GetHashDifficulty(hashBytes)
if shareDiff.String() != "1009" {
t.Error("Invalid diff")
}
}