func TestNewBlockFromBytes(t *testing.T) {
	var block100000Buf bytes.Buffer
	err := Block100000.Serialize(&block100000Buf)
	if err != nil {
		t.Errorf("Serialize: %v", err)
	}
	block100000Bytes := block100000Buf.Bytes()
	b, err := soterutil.NewBlockFromBytes(block100000Bytes)
	if err != nil {
		t.Errorf("NewBlockFromBytes: %v", err)
		return
	}
	serializedBytes, err := b.Bytes()
	if err != nil {
		t.Errorf("Bytes: %v", err)
		return
	}
	if !bytes.Equal(serializedBytes, block100000Bytes) {
		t.Errorf("Bytes: wrong bytes - got %v, want %v",
			spew.Sdump(serializedBytes),
			spew.Sdump(block100000Bytes))
	}
	if msgBlock := b.MsgBlock(); !reflect.DeepEqual(msgBlock, &Block100000) {
		t.Errorf("MsgBlock: mismatched MsgBlock - got %v, want %v",
			spew.Sdump(msgBlock), spew.Sdump(&Block100000))
	}
}
TestNewBlockFromBytes tests creation of a Block from serialized bytes.
package soterutil_test
import (
	"bytes"
	"io"
	"reflect"
	"testing"
	"time"
	"github.com/soteria-dag/soterd/chaincfg/chainhash"
	"github.com/soteria-dag/soterd/wire"
	"github.com/soteria-dag/soterd/soterutil"
	"github.com/davecgh/go-spew/spew"
)
func TestBlock(t *testing.T) {
	b := soterutil.NewBlock(&Block100000)
	if msgBlock := b.MsgBlock(); !reflect.DeepEqual(msgBlock, &Block100000) {
		t.Errorf("MsgBlock: mismatched MsgBlock - got %v, want %v",
			spew.Sdump(msgBlock), spew.Sdump(&Block100000))
	}
	wantHeight := int32(100000)
	b.SetHeight(wantHeight)
	if gotHeight := b.Height(); gotHeight != wantHeight {
		t.Errorf("Height: mismatched height - got %v, want %v",
			gotHeight, wantHeight)
	}
	wantHashStr := "3ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
	wantHash, err := chainhash.NewHashFromStr(wantHashStr)
	if err != nil {
		t.Errorf("NewHashFromStr: %v", err)
	}
	for i := 0; i < 2; i++ {
		hash := b.Hash()
		if !hash.IsEqual(wantHash) {
			t.Errorf("Hash #%d mismatched hash - got %v, want %v",
				i, hash, wantHash)
		}
	}
	wantTxHashes := []string{
		"8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87",
		"fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4",
		"6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4",
		"e9a66845e05d5abc0ad04ec80f774a7e585c6e8db975962d069a522137b80c1d",
	}
	b = soterutil.NewBlock(&Block100000)
	for i, txHash := range wantTxHashes {
		wantHash, err := chainhash.NewHashFromStr(txHash)
		if err != nil {
			t.Errorf("NewHashFromStr: %v", err)
		}
		for j := 0; j < 2; j++ {
			tx, err := b.Tx(i)
			if err != nil {
				t.Errorf("Tx #%d: %v", i, err)
				continue
			}
			hash := tx.Hash()
			if !hash.IsEqual(wantHash) {
				t.Errorf("Hash #%d mismatched hash - got %v, "+
					"want %v", j, hash, wantHash)
				continue
			}
		}
	}
	b = soterutil.NewBlock(&Block100000)
	for i := 0; i < 2; i++ {
		transactions := b.Transactions()
		if len(transactions) != len(wantTxHashes) {
			t.Errorf("Transactions #%d mismatched number of "+
				"transactions - got %d, want %d", i,
				len(transactions), len(wantTxHashes))
			continue
		}
		for j, tx := range transactions {
			wantHash, err := chainhash.NewHashFromStr(wantTxHashes[j])
			if err != nil {
				t.Errorf("NewHashFromStr: %v", err)
			}
			hash := tx.Hash()
			if !hash.IsEqual(wantHash) {
				t.Errorf("Transactions #%d mismatched hashes "+
					"- got %v, want %v", j, hash, wantHash)
				continue
			}
		}
	}
	var block100000Buf bytes.Buffer
	err = Block100000.Serialize(&block100000Buf)
	if err != nil {
		t.Errorf("Serialize: %v", err)
	}
	block100000Bytes := block100000Buf.Bytes()
	for i := 0; i < 2; i++ {
		serializedBytes, err := b.Bytes()
		if err != nil {
			t.Errorf("Bytes: %v", err)
			continue
		}
		if !bytes.Equal(serializedBytes, block100000Bytes) {
			t.Errorf("Bytes #%d wrong bytes - got %v, want %v", i,
				spew.Sdump(serializedBytes),
				spew.Sdump(block100000Bytes))
			continue
		}
	}
	wantTxLocs := []wire.TxLoc{
		{TxStart: 161, TxLen: 135},
		{TxStart: 296, TxLen: 259},
		{TxStart: 555, TxLen: 257},
		{TxStart: 812, TxLen: 225},
	}
	txLocs, err := b.TxLoc()
	if err != nil {
		t.Errorf("TxLoc: %v", err)
		return
	}
	if !reflect.DeepEqual(txLocs, wantTxLocs) {
		t.Errorf("TxLoc: mismatched transaction location information "+
			"- got %v, want %v", spew.Sdump(txLocs),
			spew.Sdump(wantTxLocs))
	}
}