1// Copyright (c) 2016 The btcsuite developers
2// Use of this source code is governed by an ISC
3// license that can be found in the LICENSE file.
4
5package chaincfg
6
7import "testing"
8
9// TestInvalidHashStr ensures the newShaHashFromStr function panics when used to
10// with an invalid hash string.
11func TestInvalidHashStr(t *testing.T) {
12	defer func() {
13		if r := recover(); r == nil {
14			t.Errorf("Expected panic for invalid hash, got nil")
15		}
16	}()
17	newHashFromStr("banana")
18}
19
20// TestMustRegisterPanic ensures the mustRegister function panics when used to
21// register an invalid network.
22func TestMustRegisterPanic(t *testing.T) {
23	t.Parallel()
24
25	// Setup a defer to catch the expected panic to ensure it actually
26	// paniced.
27	defer func() {
28		if err := recover(); err == nil {
29			t.Error("mustRegister did not panic as expected")
30		}
31	}()
32
33	// Intentionally try to register duplicate params to force a panic.
34	mustRegister(&MainNetParams)
35}
36