github.com/dashpay/godash@v0.0.0-20160726055534-e038a21e0e3d/wire/protocol_test.go (about)

     1  // Copyright (c) 2013-2015 The btcsuite developers
     2  // Copyright (c) 2016 The Dash developers
     3  // Use of this source code is governed by an ISC
     4  // license that can be found in the LICENSE file.
     5  
     6  package wire_test
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/dashpay/godash/wire"
    12  )
    13  
    14  // TestServiceFlagStringer tests the stringized output for service flag types.
    15  func TestServiceFlagStringer(t *testing.T) {
    16  	tests := []struct {
    17  		in   wire.ServiceFlag
    18  		want string
    19  	}{
    20  		{0, "0x0"},
    21  		{wire.SFNodeNetwork, "SFNodeNetwork"},
    22  		{wire.SFNodeGetUTXO, "SFNodeGetUTXO"},
    23  		{wire.SFNodeBloom, "SFNodeBloom"},
    24  		{0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|0xfffffff8"},
    25  	}
    26  
    27  	t.Logf("Running %d tests", len(tests))
    28  	for i, test := range tests {
    29  		result := test.in.String()
    30  		if result != test.want {
    31  			t.Errorf("String #%d\n got: %s want: %s", i, result,
    32  				test.want)
    33  			continue
    34  		}
    35  	}
    36  }
    37  
    38  // TestBitcoinNetStringer tests the stringized output for bitcoin net types.
    39  func TestBitcoinNetStringer(t *testing.T) {
    40  	tests := []struct {
    41  		in   wire.BitcoinNet
    42  		want string
    43  	}{
    44  		{wire.MainNet, "MainNet"},
    45  		{wire.TestNet, "TestNet"},
    46  		{wire.TestNet3, "TestNet3"},
    47  		{wire.SimNet, "SimNet"},
    48  		{0xffffffff, "Unknown BitcoinNet (4294967295)"},
    49  	}
    50  
    51  	t.Logf("Running %d tests", len(tests))
    52  	for i, test := range tests {
    53  		result := test.in.String()
    54  		if result != test.want {
    55  			t.Errorf("String #%d\n got: %s want: %s", i, result,
    56  				test.want)
    57  			continue
    58  		}
    59  	}
    60  }