|
|
@ -21,8 +21,6 @@ import ( |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/core/rawdb" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/rlp" |
|
|
|
"github.com/ethereum/go-ethereum/rlp" |
|
|
|
"github.com/harmony-one/harmony/block" |
|
|
|
"github.com/harmony-one/harmony/block" |
|
|
@ -34,7 +32,7 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
// Tests block header storage and retrieval operations.
|
|
|
|
// Tests block header storage and retrieval operations.
|
|
|
|
func TestHeaderStorage(t *testing.T) { |
|
|
|
func TestHeaderStorage(t *testing.T) { |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := NewMemoryDatabase() |
|
|
|
|
|
|
|
|
|
|
|
// Create a test header to move around the database and make sure it's really new
|
|
|
|
// Create a test header to move around the database and make sure it's really new
|
|
|
|
header := blockfactory.NewTestHeader().With().Number(big.NewInt(42)).Extra([]byte("test header")).Header() |
|
|
|
header := blockfactory.NewTestHeader().With().Number(big.NewInt(42)).Extra([]byte("test header")).Header() |
|
|
@ -67,7 +65,7 @@ func TestHeaderStorage(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Tests block body storage and retrieval operations.
|
|
|
|
// Tests block body storage and retrieval operations.
|
|
|
|
func TestBodyStorage(t *testing.T) { |
|
|
|
func TestBodyStorage(t *testing.T) { |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := NewMemoryDatabase() |
|
|
|
|
|
|
|
|
|
|
|
// Create a test body to move around the database and make sure it's really new
|
|
|
|
// Create a test body to move around the database and make sure it's really new
|
|
|
|
body := types.NewTestBody().With().Uncles([]*block.Header{blockfactory.NewTestHeader().With().Extra([]byte("test header")).Header()}).Body() |
|
|
|
body := types.NewTestBody().With().Uncles([]*block.Header{blockfactory.NewTestHeader().With().Extra([]byte("test header")).Header()}).Body() |
|
|
@ -105,7 +103,7 @@ func TestBodyStorage(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Tests block storage and retrieval operations.
|
|
|
|
// Tests block storage and retrieval operations.
|
|
|
|
func TestBlockStorage(t *testing.T) { |
|
|
|
func TestBlockStorage(t *testing.T) { |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := NewMemoryDatabase() |
|
|
|
|
|
|
|
|
|
|
|
// Create a test block to move around the database and make sure it's really new
|
|
|
|
// Create a test block to move around the database and make sure it's really new
|
|
|
|
block := types.NewBlockWithHeader(blockfactory.NewTestHeader().With(). |
|
|
|
block := types.NewBlockWithHeader(blockfactory.NewTestHeader().With(). |
|
|
@ -167,7 +165,7 @@ func TestBlockStorage(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Tests that partial block contents don't get reassembled into full blocks.
|
|
|
|
// Tests that partial block contents don't get reassembled into full blocks.
|
|
|
|
func TestPartialBlockStorage(t *testing.T) { |
|
|
|
func TestPartialBlockStorage(t *testing.T) { |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := NewMemoryDatabase() |
|
|
|
block := types.NewBlockWithHeader(blockfactory.NewTestHeader().With(). |
|
|
|
block := types.NewBlockWithHeader(blockfactory.NewTestHeader().With(). |
|
|
|
Extra([]byte("test block")). |
|
|
|
Extra([]byte("test block")). |
|
|
|
TxHash(types.EmptyRootHash). |
|
|
|
TxHash(types.EmptyRootHash). |
|
|
@ -200,7 +198,7 @@ func TestPartialBlockStorage(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Tests block total difficulty storage and retrieval operations.
|
|
|
|
// Tests block total difficulty storage and retrieval operations.
|
|
|
|
func TestTdStorage(t *testing.T) { |
|
|
|
func TestTdStorage(t *testing.T) { |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := NewMemoryDatabase() |
|
|
|
|
|
|
|
|
|
|
|
// Create a test TD to move around the database and make sure it's really new
|
|
|
|
// Create a test TD to move around the database and make sure it's really new
|
|
|
|
hash, td := common.Hash{}, big.NewInt(314) |
|
|
|
hash, td := common.Hash{}, big.NewInt(314) |
|
|
@ -223,7 +221,7 @@ func TestTdStorage(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Tests that canonical numbers can be mapped to hashes and retrieved.
|
|
|
|
// Tests that canonical numbers can be mapped to hashes and retrieved.
|
|
|
|
func TestCanonicalMappingStorage(t *testing.T) { |
|
|
|
func TestCanonicalMappingStorage(t *testing.T) { |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := NewMemoryDatabase() |
|
|
|
|
|
|
|
|
|
|
|
// Create a test canonical number and assinged hash to move around
|
|
|
|
// Create a test canonical number and assinged hash to move around
|
|
|
|
hash, number := common.Hash{0: 0xff}, uint64(314) |
|
|
|
hash, number := common.Hash{0: 0xff}, uint64(314) |
|
|
@ -246,7 +244,7 @@ func TestCanonicalMappingStorage(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Tests that head headers and head blocks can be assigned, individually.
|
|
|
|
// Tests that head headers and head blocks can be assigned, individually.
|
|
|
|
func TestHeadStorage(t *testing.T) { |
|
|
|
func TestHeadStorage(t *testing.T) { |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := NewMemoryDatabase() |
|
|
|
|
|
|
|
|
|
|
|
blockHead := types.NewBlockWithHeader(blockfactory.NewTestHeader().With().Extra([]byte("test block header")).Header()) |
|
|
|
blockHead := types.NewBlockWithHeader(blockfactory.NewTestHeader().With().Extra([]byte("test block header")).Header()) |
|
|
|
blockFull := types.NewBlockWithHeader(blockfactory.NewTestHeader().With().Extra([]byte("test block full")).Header()) |
|
|
|
blockFull := types.NewBlockWithHeader(blockfactory.NewTestHeader().With().Extra([]byte("test block full")).Header()) |
|
|
@ -281,7 +279,7 @@ func TestHeadStorage(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Tests that receipts associated with a single block can be stored and retrieved.
|
|
|
|
// Tests that receipts associated with a single block can be stored and retrieved.
|
|
|
|
func TestBlockReceiptStorage(t *testing.T) { |
|
|
|
func TestBlockReceiptStorage(t *testing.T) { |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := NewMemoryDatabase() |
|
|
|
|
|
|
|
|
|
|
|
receipt1 := &types.Receipt{ |
|
|
|
receipt1 := &types.Receipt{ |
|
|
|
Status: types.ReceiptStatusFailed, |
|
|
|
Status: types.ReceiptStatusFailed, |
|
|
|