From 562bde6902726ef306ed426268f61b97230b19c4 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sat, 27 Jul 2013 15:38:03 -0500 Subject: [PATCH] Use byte literals in tests to make go vet happy. The go vet command complains about untagged struct initializers when defining a ShaHash directly. This seems to be a limitation where go vet does not exclude the warning for types which are a constant size byte array like it does for normal constant size byte array definition. This commit simply modifies the tests to use a constant definition cast to a ShaHash to overcome the limitation of go vet. --- msgblock_test.go | 8 ++++---- msgtx_test.go | 2 +- shahash_test.go | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/msgblock_test.go b/msgblock_test.go index 5196e17a..68925720 100644 --- a/msgblock_test.go +++ b/msgblock_test.go @@ -294,18 +294,18 @@ func TestBlockWireErrors(t *testing.T) { var blockOne btcwire.MsgBlock = btcwire.MsgBlock{ Header: btcwire.BlockHeader{ Version: 1, - PrevBlock: btcwire.ShaHash{ + PrevBlock: btcwire.ShaHash([btcwire.HashSize]byte{ // Make go vet happy. 0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f, 0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - MerkleRoot: btcwire.ShaHash{ + }), + MerkleRoot: btcwire.ShaHash([btcwire.HashSize]byte{ // Make go vet happy. 0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44, 0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67, 0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1, 0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, - }, + }), Timestamp: time.Unix(0x4966bc61, 0), // 2009-01-08 20:54:25 -0600 CST Bits: 0x1d00ffff, // 486604799 diff --git a/msgtx_test.go b/msgtx_test.go index 5ccc61b6..6f631aac 100644 --- a/msgtx_test.go +++ b/msgtx_test.go @@ -134,7 +134,7 @@ func TestTxSha(t *testing.T) { msgTx := btcwire.NewMsgTx() txIn := btcwire.TxIn{ PreviousOutpoint: btcwire.OutPoint{ - Hash: btcwire.ShaHash{0x00}, + Hash: btcwire.ShaHash{}, Index: 0xffffffff, }, SignatureScript: []byte{0x04, 0x31, 0xdc, 0x00, 0x1b, 0x01, 0x62}, diff --git a/shahash_test.go b/shahash_test.go index e99f4542..a1f5774c 100644 --- a/shahash_test.go +++ b/shahash_test.go @@ -80,12 +80,12 @@ func TestShaHash(t *testing.T) { func TestShaHashString(t *testing.T) { // Block 100000 hash. wantStr := "000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506" - hash := &btcwire.ShaHash{ + hash := btcwire.ShaHash([btcwire.HashSize]byte{ // Make go vet happy. 0x06, 0xe5, 0x33, 0xfd, 0x1a, 0xda, 0x86, 0x39, 0x1f, 0x3f, 0x6c, 0x34, 0x32, 0x04, 0xb0, 0xd2, 0x78, 0xd4, 0xaa, 0xec, 0x1c, 0x0b, 0x20, 0xaa, 0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - } + }) hashStr := hash.String() if hashStr != wantStr { @@ -118,24 +118,24 @@ func TestNewShaHashFromStr(t *testing.T) { // Single digit hash. { "1", - btcwire.ShaHash{ + btcwire.ShaHash([btcwire.HashSize]byte{ // Make go vet happy. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, + }), nil, }, // Block 203707 with stripped leading zeros. { "3264bc2ac36a60840790ba1d475d01367e7c723da941069e9dc", - btcwire.ShaHash{ + btcwire.ShaHash([btcwire.HashSize]byte{ // Make go vet happy. 0xdc, 0xe9, 0x69, 0x10, 0x94, 0xda, 0x23, 0xc7, 0xe7, 0x67, 0x13, 0xd0, 0x75, 0xd4, 0xa1, 0x0b, 0x79, 0x40, 0x08, 0xa6, 0x36, 0xac, 0xc2, 0x4b, 0x26, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, + }), nil, },