forked from cerc-io/plugeth
core: fix tests
This commit is contained in:
parent
b5b83db450
commit
a59dd393e7
@ -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")
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user