diff --git a/core/block_processor_test.go b/core/block_processor_test.go index ad29404e120c5e4e77f8d22e723a1d08521405a2..64add7e8becd12fb90aebd0f97e9d1c295545bf5 100644 --- a/core/block_processor_test.go +++ b/core/block_processor_test.go @@ -4,6 +4,7 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/pow/ezp" @@ -19,7 +20,7 @@ func proc() (*BlockProcessor, *ChainManager) { func TestNumber(t *testing.T) { bp, chain := proc() - block1 := chain.NewBlock(nil) + block1 := chain.NewBlock(common.Address{}) block1.Header().Number = big.NewInt(3) err := bp.ValidateHeader(block1.Header(), chain.Genesis().Header()) @@ -27,7 +28,7 @@ func TestNumber(t *testing.T) { t.Errorf("expected block number error") } - block1 = chain.NewBlock(nil) + block1 = chain.NewBlock(common.Address{}) err = bp.ValidateHeader(block1.Header(), chain.Genesis().Header()) if err == BlockNumberErr { t.Errorf("didn't expect block number error") diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go index 898d37f9c088d690d2bfa86d32214554e493c772..e49e594a3d6f5afb8c21fb120b47354eabb9d362 100644 --- a/core/chain_manager_test.go +++ b/core/chain_manager_test.go @@ -1,7 +1,6 @@ package core import ( - "bytes" "fmt" "math/big" "os" @@ -35,7 +34,7 @@ func testFork(t *testing.T, bman *BlockProcessor, i, N int, f func(td1, td2 *big // asert the bmans have the same block at i bi1 := bman.bc.GetBlockByNumber(uint64(i)).Hash() bi2 := bman2.bc.GetBlockByNumber(uint64(i)).Hash() - if bytes.Compare(bi1, bi2) != 0 { + if bi1 != bi2 { t.Fatal("chains do not have the same hash at height", i) } @@ -270,11 +269,11 @@ func TestChainInsertions(t *testing.T) { <-done } - if bytes.Equal(chain2[len(chain2)-1].Hash(), chainMan.CurrentBlock().Hash()) { + if chain2[len(chain2)-1].Hash() != chainMan.CurrentBlock().Hash() { t.Error("chain2 is canonical and shouldn't be") } - if !bytes.Equal(chain1[len(chain1)-1].Hash(), chainMan.CurrentBlock().Hash()) { + if chain1[len(chain1)-1].Hash() != chainMan.CurrentBlock().Hash() { t.Error("chain1 isn't canonical and should be") } } @@ -320,7 +319,7 @@ func TestChainMultipleInsertions(t *testing.T) { <-done } - if !bytes.Equal(chains[longest][len(chains[longest])-1].Hash(), chainMan.CurrentBlock().Hash()) { + if chains[longest][len(chains[longest])-1].Hash() != chainMan.CurrentBlock().Hash() { t.Error("Invalid canonical chain") } } diff --git a/core/genesis.go b/core/genesis.go index 70845b502a6adca47d504f34454b39d7e885a831..3e00533ae6f4bf39b066edaf6b67652ba783fcca 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -8,7 +8,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/state" ) @@ -19,9 +18,6 @@ import ( var ZeroHash256 = make([]byte, 32) var ZeroHash160 = make([]byte, 20) var ZeroHash512 = make([]byte, 64) -var EmptyShaList = crypto.Sha3(common.Encode([]interface{}{})) -var EmptyListRoot = crypto.Sha3(common.Encode("")) - var GenesisDiff = big.NewInt(131072) var GenesisGasLimit = big.NewInt(3141592) diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 7c50e5e53204764bb3c7512d202460d0b1351330..f2fe5c7485e01151ba60dda6c91b26e8424dd454 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -63,7 +63,7 @@ func NewTxPool(eventMux *event.TypeMux) *TxPool { func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { // Validate sender if _, err := tx.From(); err != nil { - return err + return ErrInvalidSender } // Validate curve param v, _, _ := tx.Curve() diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index 418cb041547ad633ebbf0a965973069cc76b4d1b..bf9012573c14cc321e21d3e0b72918329b77f995 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -4,10 +4,10 @@ import ( "crypto/ecdsa" "testing" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/state" ) @@ -21,11 +21,11 @@ func SQ() stateQuery { } func (self stateQuery) GetAccount(addr []byte) *state.StateObject { - return state.NewStateObject(addr, self.db) + return state.NewStateObject(common.BytesToAddress(addr), self.db) } func transaction() *types.Transaction { - return types.NewTransactionMessage(make([]byte, 20), common.Big0, common.Big0, common.Big0, nil) + return types.NewTransactionMessage(common.Address{}, common.Big0, common.Big0, common.Big0, nil) } func setup() (*TxPool, *ecdsa.PrivateKey) { @@ -88,10 +88,8 @@ func TestRemoveInvalid(t *testing.T) { func TestInvalidSender(t *testing.T) { pool, _ := setup() - tx := new(types.Transaction) - tx.V = 28 - err := pool.ValidateTransaction(tx) + err := pool.ValidateTransaction(new(types.Transaction)) if err != ErrInvalidSender { - t.Error("expected %v, got %v", ErrInvalidSender, err) + t.Errorf("expected %v, got %v", ErrInvalidSender, err) } }