forked from btcsuite/btcwire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotocol_test.go
57 lines (50 loc) · 1.3 KB
/
protocol_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2013-2014 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package btcwire_test
import (
"testing"
"github.com/PointCoin/btcwire"
)
// TestServiceFlagStringer tests the stringized output for service flag types.
func TestServiceFlagStringer(t *testing.T) {
tests := []struct {
in btcwire.ServiceFlag
want string
}{
{0, "0x0"},
{btcwire.SFNodeNetwork, "SFNodeNetwork"},
{0xffffffff, "SFNodeNetwork|0xfffffffe"},
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
result := test.in.String()
if result != test.want {
t.Errorf("String #%d\n got: %s want: %s", i, result,
test.want)
continue
}
}
}
// TestBitcoinNetStringer tests the stringized output for bitcoin net types.
func TestBitcoinNetStringer(t *testing.T) {
tests := []struct {
in btcwire.BitcoinNet
want string
}{
{btcwire.MainNet, "MainNet"},
{btcwire.TestNet, "TestNet"},
{btcwire.TestNet3, "TestNet3"},
{btcwire.SimNet, "SimNet"},
{0xffffffff, "Unknown BitcoinNet (4294967295)"},
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
result := test.in.String()
if result != test.want {
t.Errorf("String #%d\n got: %s want: %s", i, result,
test.want)
continue
}
}
}