2015-05-01 08:28:01 +02:00
|
|
|
// Copyright (c) 2013-2015 The btcsuite developers
|
2013-05-08 21:31:00 +02:00
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-01-31 19:32:55 +01:00
|
|
|
package wire_test
|
2013-05-08 21:31:00 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2014-07-03 02:43:33 +02:00
|
|
|
|
2015-01-31 19:32:55 +01:00
|
|
|
"github.com/btcsuite/btcd/wire"
|
2013-05-08 21:31:00 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// TestServiceFlagStringer tests the stringized output for service flag types.
|
|
|
|
func TestServiceFlagStringer(t *testing.T) {
|
|
|
|
tests := []struct {
|
2015-01-31 19:32:55 +01:00
|
|
|
in wire.ServiceFlag
|
2013-05-08 21:31:00 +02:00
|
|
|
want string
|
|
|
|
}{
|
|
|
|
{0, "0x0"},
|
2015-01-31 19:32:55 +01:00
|
|
|
{wire.SFNodeNetwork, "SFNodeNetwork"},
|
2013-05-08 21:31:00 +02:00
|
|
|
{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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-03 15:36:11 +01:00
|
|
|
|
|
|
|
// TestBitcoinNetStringer tests the stringized output for bitcoin net types.
|
|
|
|
func TestBitcoinNetStringer(t *testing.T) {
|
|
|
|
tests := []struct {
|
2015-01-31 19:32:55 +01:00
|
|
|
in wire.BitcoinNet
|
2014-01-03 15:36:11 +01:00
|
|
|
want string
|
|
|
|
}{
|
2015-01-31 19:32:55 +01:00
|
|
|
{wire.MainNet, "MainNet"},
|
|
|
|
{wire.TestNet, "TestNet"},
|
|
|
|
{wire.TestNet3, "TestNet3"},
|
|
|
|
{wire.SimNet, "SimNet"},
|
2014-01-03 15:36:11 +01:00
|
|
|
{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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|