Verify CGo link to libcryptonote.a works with a known-vector hash test. Co-Authored-By: Charon <charon@lethean.io>
30 lines
685 B
Go
30 lines
685 B
Go
// SPDX-Licence-Identifier: EUPL-1.2
|
|
|
|
package crypto_test
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
"forge.lthn.ai/core/go-blockchain/crypto"
|
|
)
|
|
|
|
func TestFastHash_Good_KnownVector(t *testing.T) {
|
|
// Empty input → known Keccak-256 hash.
|
|
input := []byte{}
|
|
expected := "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
|
|
|
|
got := crypto.FastHash(input)
|
|
if hex.EncodeToString(got[:]) != expected {
|
|
t.Fatalf("FastHash(empty)\n got: %x\n want: %s", got, expected)
|
|
}
|
|
}
|
|
|
|
func TestFastHash_Good_HelloWorld(t *testing.T) {
|
|
input := []byte("Hello, World!")
|
|
got := crypto.FastHash(input)
|
|
var zero [32]byte
|
|
if got == zero {
|
|
t.Fatal("FastHash returned zero hash")
|
|
}
|
|
}
|