|
|
@ -18,7 +18,7 @@ var ( |
|
|
|
testTime2 = time.Date(2017, 1, 2, 1, 1, 1, 1, time.UTC) |
|
|
|
) |
|
|
|
|
|
|
|
var hdrHeight11 = &types.Header{ |
|
|
|
var hdrHeight11 = types.Header{ |
|
|
|
Height: 11, |
|
|
|
Time: testTime1, |
|
|
|
ValidatorsHash: []byte("Tendermint"), |
|
|
@ -34,21 +34,18 @@ func TestValidateBlock(t *testing.T) { |
|
|
|
block: nil, wantErr: "non-nil Block", |
|
|
|
}, |
|
|
|
{ |
|
|
|
block: &types.Block{}, wantErr: "nil Header", |
|
|
|
}, |
|
|
|
{ |
|
|
|
block: &types.Block{Header: new(types.Header)}, |
|
|
|
block: &types.Block{}, |
|
|
|
}, |
|
|
|
|
|
|
|
// Start Header.Height mismatch test
|
|
|
|
{ |
|
|
|
block: &types.Block{Header: &types.Header{Height: 10}}, |
|
|
|
block: &types.Block{Header: types.Header{Height: 10}}, |
|
|
|
commit: lite.Commit{Header: &types.Header{Height: 11}}, |
|
|
|
wantErr: "don't match - 10 vs 11", |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
block: &types.Block{Header: &types.Header{Height: 11}}, |
|
|
|
block: &types.Block{Header: types.Header{Height: 11}}, |
|
|
|
commit: lite.Commit{Header: &types.Header{Height: 11}}, |
|
|
|
}, |
|
|
|
// End Header.Height mismatch test
|
|
|
@ -62,15 +59,15 @@ func TestValidateBlock(t *testing.T) { |
|
|
|
|
|
|
|
{ |
|
|
|
block: &types.Block{Header: hdrHeight11}, |
|
|
|
commit: lite.Commit{Header: hdrHeight11}, |
|
|
|
commit: lite.Commit{Header: &hdrHeight11}, |
|
|
|
}, |
|
|
|
// End Header.Hash mismatch test
|
|
|
|
|
|
|
|
// Start Header.Data hash mismatch test
|
|
|
|
{ |
|
|
|
block: &types.Block{ |
|
|
|
Header: &types.Header{Height: 11}, |
|
|
|
Data: &types.Data{Txs: []types.Tx{[]byte("0xDE"), []byte("AD")}}, |
|
|
|
Header: types.Header{Height: 11}, |
|
|
|
Data: types.Data{Txs: []types.Tx{[]byte("0xDE"), []byte("AD")}}, |
|
|
|
}, |
|
|
|
commit: lite.Commit{ |
|
|
|
Header: &types.Header{Height: 11}, |
|
|
@ -80,8 +77,8 @@ func TestValidateBlock(t *testing.T) { |
|
|
|
}, |
|
|
|
{ |
|
|
|
block: &types.Block{ |
|
|
|
Header: &types.Header{Height: 11, DataHash: deadBeefHash}, |
|
|
|
Data: &types.Data{Txs: deadBeefTxs}, |
|
|
|
Header: types.Header{Height: 11, DataHash: deadBeefHash}, |
|
|
|
Data: types.Data{Txs: deadBeefTxs}, |
|
|
|
}, |
|
|
|
commit: lite.Commit{ |
|
|
|
Header: &types.Header{Height: 11}, |
|
|
@ -116,21 +113,18 @@ func TestValidateBlockMeta(t *testing.T) { |
|
|
|
meta: nil, wantErr: "non-nil BlockMeta", |
|
|
|
}, |
|
|
|
{ |
|
|
|
meta: &types.BlockMeta{}, wantErr: "non-nil Header", |
|
|
|
}, |
|
|
|
{ |
|
|
|
meta: &types.BlockMeta{Header: new(types.Header)}, |
|
|
|
meta: &types.BlockMeta{}, |
|
|
|
}, |
|
|
|
|
|
|
|
// Start Header.Height mismatch test
|
|
|
|
{ |
|
|
|
meta: &types.BlockMeta{Header: &types.Header{Height: 10}}, |
|
|
|
meta: &types.BlockMeta{Header: types.Header{Height: 10}}, |
|
|
|
commit: lite.Commit{Header: &types.Header{Height: 11}}, |
|
|
|
wantErr: "don't match - 10 vs 11", |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
meta: &types.BlockMeta{Header: &types.Header{Height: 11}}, |
|
|
|
meta: &types.BlockMeta{Header: types.Header{Height: 11}}, |
|
|
|
commit: lite.Commit{Header: &types.Header{Height: 11}}, |
|
|
|
}, |
|
|
|
// End Header.Height mismatch test
|
|
|
@ -144,12 +138,12 @@ func TestValidateBlockMeta(t *testing.T) { |
|
|
|
|
|
|
|
{ |
|
|
|
meta: &types.BlockMeta{Header: hdrHeight11}, |
|
|
|
commit: lite.Commit{Header: hdrHeight11}, |
|
|
|
commit: lite.Commit{Header: &hdrHeight11}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
meta: &types.BlockMeta{ |
|
|
|
Header: &types.Header{ |
|
|
|
Header: types.Header{ |
|
|
|
Height: 11, |
|
|
|
ValidatorsHash: []byte("lite-test"), |
|
|
|
// TODO: should be able to use empty time after Amino upgrade
|
|
|
@ -164,7 +158,7 @@ func TestValidateBlockMeta(t *testing.T) { |
|
|
|
|
|
|
|
{ |
|
|
|
meta: &types.BlockMeta{ |
|
|
|
Header: &types.Header{ |
|
|
|
Header: types.Header{ |
|
|
|
Height: 11, DataHash: deadBeefHash, |
|
|
|
ValidatorsHash: []byte("Tendermint"), |
|
|
|
Time: testTime1, |
|
|
@ -183,7 +177,7 @@ func TestValidateBlockMeta(t *testing.T) { |
|
|
|
|
|
|
|
{ |
|
|
|
meta: &types.BlockMeta{ |
|
|
|
Header: &types.Header{ |
|
|
|
Header: types.Header{ |
|
|
|
Height: 11, DataHash: deadBeefHash, |
|
|
|
ValidatorsHash: []byte("Tendermint"), |
|
|
|
Time: testTime2, |
|
|
|