func TestNewBlockHeaderPanics(t *testing.T) { ct := uint64(100) head := coin.BlockHeader{Time: ct} assert.Panics(t, func() { coin.NewBlockHeader(head, coin.NewUnspentPool(), ct, 50, coin.BlockBody{}) }) assert.Panics(t, func() { coin.NewBlockHeader(head, coin.NewUnspentPool(), ct-1, 50, coin.BlockBody{}) }) assert.Panics(t, func() { coin.NewBlockHeader(head, coin.NewUnspentPool(), ct-ct, 50, coin.BlockBody{}) }) assert.NotPanics(t, func() { coin.NewBlockHeader(head, coin.NewUnspentPool(), ct+1, 50, coin.BlockBody{}) }) }
func TestNewBlockHeader(t *testing.T) { // TODO -- update this test for newBlockHeader changes b := makeNewBlock() prev := b.Head unsp := coin.NewUnspentPool() unsp.XorHash = randSHA256() fee := uint64(10) bh := coin.NewBlockHeader(prev, unsp, prev.Time+22, fee, b.Body) assert.Equal(t, bh.PrevHash, prev.Hash()) assert.NotEqual(t, bh.PrevHash, prev.PrevHash) assert.Equal(t, bh.Time, uint64(prev.Time+22)) assert.Equal(t, bh.BkSeq, uint64(prev.BkSeq+1)) assert.Equal(t, bh.Fee, fee) assert.Equal(t, bh.Version, prev.Version) assert.Equal(t, bh.BodyHash, b.Body.Hash()) assert.Equal(t, bh.UxHash, unsp.GetUxHash()) }