OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / vendor / github.com / btcsuite / btcd / chaincfg / params_test.go
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
5 package chaincfg
6
7 import "testing"
8
9 // TestInvalidHashStr ensures the newShaHashFromStr function panics when used to
10 // with an invalid hash string.
11 func 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.
22 func 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 }