aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-18 20:38:47 +0800
committerFelix Lange <fjl@twurst.com>2015-03-18 20:38:47 +0800
commita59dd393e71cc52b1f96973aef884af619166f38 (patch)
treeb52cfbbb41a9fffaaefa2bc8913f578480cff160
parentb5b83db450974f70f4bc25f280cc6ec9193f8e19 (diff)
downloadgo-tangerine-a59dd393e71cc52b1f96973aef884af619166f38.tar
go-tangerine-a59dd393e71cc52b1f96973aef884af619166f38.tar.gz
go-tangerine-a59dd393e71cc52b1f96973aef884af619166f38.tar.bz2
go-tangerine-a59dd393e71cc52b1f96973aef884af619166f38.tar.lz
go-tangerine-a59dd393e71cc52b1f96973aef884af619166f38.tar.xz
go-tangerine-a59dd393e71cc52b1f96973aef884af619166f38.tar.zst
go-tangerine-a59dd393e71cc52b1f96973aef884af619166f38.zip
core: fix tests
-rw-r--r--core/block_processor_test.go5
-rw-r--r--core/chain_manager_test.go9
-rw-r--r--core/genesis.go4
-rw-r--r--core/transaction_pool.go2
-rw-r--r--core/transaction_pool_test.go12
5 files changed, 13 insertions, 19 deletions
diff --git a/core/block_processor_test.go b/core/block_processor_test.go
index ad29404e1..64add7e8b 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 898d37f9c..e49e594a3 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 70845b502..3e00533ae 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 7c50e5e53..f2fe5c748 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 418cb0415..bf9012573 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)
}
}