func TestInvalidLinks(t *testing.T) {
	invalid := []string{
		"",
		"4b",                          
		"4bf",                         
		"4bf8131ca2a32eadc097e14b48",  
		"4bf8131ca2a32eadc097e14b48ecc7c87288a7b6b79757c8290834bacfda16a",     
		"4bf8131ca2a32eadc097e14b48ecc7c87288a7b6b79757c8290834bacfda16aa6",   
		"4bf8131ca2a32eadc097e14b48ecc7c87288a7b6b79757c8290834bacfda16aa68",  
		"4bf8131ca2a32eadc0x7e14b48ecc7c87288a7b6b79757c8290834bacfda16aa",  
		"4bf8131ca2a32eadc0X7e14b48ecc7c87288a7b6b79757c8290834bacfda16aa",  
		"4bf8131ca2a32eadc0k7e14b48ecc7c87288a7b6b79757c8290834bacfda16aa",  
		"4bf8131ca2a32eadc0K7e14b48ecc7c87288a7b6b79757c8290834bacfda16aa",  
	}
	for i, textLink := range invalid {
		var link merkle.Digest
		n, err := fmt.Sscan(textLink, &link)
		if fault.NotLink != err {
			t.Errorf("%d: testing: %q", i, textLink)
			t.Errorf("%d: expected: %s  but got: %s", i, fault.NotLink, err)
			return
		}
		if 0 != n {
			t.Errorf("%d: testing: %q", i, textLink)
			t.Errorf("%d: hex to link scanned: %d  expected: 0", i, n)
			return
		}
	}
}
originally part of transaction testing
package merkle_test
import (
	"encoding/json"
	"fmt"
	"testing"
	"github.com/bitmark-inc/bitmarkd/fault"
	"github.com/bitmark-inc/bitmarkd/merkle"
	"github.com/bitmark-inc/bitmarkd/util"
)
func TestScanFmt(t *testing.T) {
	stringDigest := "00000000440b921e1b77c6c0487ae5616de67f788f44ae2a5af6e2194d16b6f8"
	var d merkle.Digest
	n, err := fmt.Sscan(stringDigest, &d)
	if nil != err {
		t.Fatalf("hex to digest error: %s", err)
	}
	if 1 != n {
		t.Fatalf("scanned %d items expected to scan 1", n)
	}
	expected := merkle.Digest{
		0xf8, 0xb6, 0x16, 0x4d,
		0x19, 0xe2, 0xf6, 0x5a,
		0x2a, 0xae, 0x44, 0x8f,
		0x78, 0x7f, 0xe6, 0x6d,
		0x61, 0xe5, 0x7a, 0x48,
		0xc0, 0xc6, 0x77, 0x1b,
		0x1e, 0x92, 0x0b, 0x44,
		0x00, 0x00, 0x00, 0x00,
	}
	if d != expected {
		t.Errorf("digest(LE) = %#v expected %x#v", d, expected)
	}
	s := d.String()
	if s != stringDigest {
		t.Errorf("string: digest = %s expected %s", s, stringDigest)
	}
	s = fmt.Sprintf("%#v", d)
	if s != "<SHA3-256-BE:"+stringDigest+">" {
		t.Errorf("hash-v: digest = %s expected %s", s, stringDigest)
	}
}
func TestDigest(t *testing.T) {
	s := []byte("hello world")
	d := merkle.NewDigest(s)
	stringDigest := "38394ef2fb3b1ca394fd72d9a1fb71caf322769ec8aa9909047343567ecc4b64"
	var expected merkle.Digest
	n, err := fmt.Sscan(stringDigest, &expected)
	if nil != err {
		t.Fatalf("hex to digest error: %s", err)
	}
	if 1 != n {
		t.Fatalf("scanned %d items expected to scan 1", n)
	}
	if d != expected {
		t.Errorf("digest = %#v expected %#v", d, expected)
	}
}