2016-04-11 19:34:28 +02:00
|
|
|
// Copyright (c) 2016 The btcsuite developers
|
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package chaincfg
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2016-04-11 21:21:40 +02:00
|
|
|
// TestInvalidHashStr ensures the newShaHashFromStr function panics when used to
|
|
|
|
// with an invalid hash string.
|
|
|
|
func TestInvalidHashStr(t *testing.T) {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r == nil {
|
|
|
|
t.Errorf("Expected panic for invalid hash, got nil")
|
|
|
|
}
|
|
|
|
}()
|
2016-08-08 21:04:33 +02:00
|
|
|
newHashFromStr("banana")
|
2016-04-11 21:21:40 +02:00
|
|
|
}
|
|
|
|
|
2016-04-11 19:34:28 +02:00
|
|
|
// TestMustRegisterPanic ensures the mustRegister function panics when used to
|
|
|
|
// register an invalid network.
|
|
|
|
func TestMustRegisterPanic(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
// Setup a defer to catch the expected panic to ensure it actually
|
|
|
|
// paniced.
|
|
|
|
defer func() {
|
|
|
|
if err := recover(); err == nil {
|
|
|
|
t.Error("mustRegister did not panic as expected")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// Intentionally try to register duplicate params to force a panic.
|
|
|
|
mustRegister(&MainNetParams)
|
|
|
|
}
|