dcrd/wire/protocol_test.go
Dave Collins 0aa33e0fbd
wire: Consolidate tests into the wire pkg.
Contains the following upstream commits:

- 6e644855f5
  - This commit has been reverted since newer versions are already set
- d406d9e52b
2016-11-14 15:29:40 -06:00

55 lines
1.3 KiB
Go

// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package wire
import "testing"
// TestServiceFlagStringer tests the stringized output for service flag types.
func TestServiceFlagStringer(t *testing.T) {
tests := []struct {
in ServiceFlag
want string
}{
{0, "0x0"},
{SFNodeNetwork, "SFNodeNetwork"},
{SFNodeBloom, "SFNodeBloom"},
{0xffffffff, "SFNodeNetwork|SFNodeBloom|0xfffffffc"},
}
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
}
}
}
// TestCurrencyNetStringer tests the stringized output for decred net types.
func TestCurrencyNetStringer(t *testing.T) {
tests := []struct {
in CurrencyNet
want string
}{
{MainNet, "MainNet"},
{TestNet, "TestNet"},
{SimNet, "SimNet"},
{0xffffffff, "Unknown CurrencyNet (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
}
}
}