natspec test bugfix

pull/668/head
zsfelfoldi 10 years ago committed by zelig
parent b635cad9fe
commit 8e6a068d2d
  1. 19
      common/natspec/natspec_e2e_test.go

@ -6,7 +6,6 @@ import (
"math/big" "math/big"
"os" "os"
"testing" "testing"
"time"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -28,7 +27,6 @@ type testFrontend struct {
xeth *xe.XEth xeth *xe.XEth
api *rpc.EthereumApi api *rpc.EthereumApi
coinbase string coinbase string
txc int
lastConfirm string lastConfirm string
makeNatSpec bool makeNatSpec bool
} }
@ -175,6 +173,9 @@ func testInit(t *testing.T) (self *testFrontend) {
func (self *testFrontend) insertTx(addr, contract, fnsig string, args []string) { func (self *testFrontend) insertTx(addr, contract, fnsig string, args []string) {
//cb := common.HexToAddress(self.coinbase)
//coinbase := self.ethereum.ChainManager().State().GetStateObject(cb)
hash := common.Bytes2Hex(crypto.Sha3([]byte(fnsig))) hash := common.Bytes2Hex(crypto.Sha3([]byte(fnsig)))
data := "0x" + hash[0:8] data := "0x" + hash[0:8]
for _, arg := range args { for _, arg := range args {
@ -192,26 +193,19 @@ func (self *testFrontend) insertTx(addr, contract, fnsig string, args []string)
"data": "` + data + `" "data": "` + data + `"
}] }]
` `
self.txc++
req := &rpc.RpcRequest{ req := &rpc.RpcRequest{
Jsonrpc: "2.0", Jsonrpc: "2.0",
Method: "eth_transact", Method: "eth_transact",
Params: []byte(jsontx), Params: []byte(jsontx),
Id: self.txc, Id: 6,
} }
txcount := self.ethereum.TxPool().Size()
var reply interface{} var reply interface{}
err0 := self.api.GetRequestReply(req, &reply) err0 := self.api.GetRequestReply(req, &reply)
if err0 != nil { if err0 != nil {
self.t.Errorf("GetRequestReply error: %v", err0) self.t.Errorf("GetRequestReply error: %v", err0)
} }
for txcount == self.ethereum.TxPool().Size() {
time.Sleep(time.Millisecond)
}
//self.xeth.Transact(addr, contract, "100000000000", "100000", "100000", data) //self.xeth.Transact(addr, contract, "100000000000", "100000", "100000", data)
} }
@ -224,12 +218,15 @@ func (self *testFrontend) applyTxs() {
coinbase.SetGasPool(big.NewInt(1000000)) coinbase.SetGasPool(big.NewInt(1000000))
txs := self.ethereum.TxPool().GetTransactions() txs := self.ethereum.TxPool().GetTransactions()
for i := 0; i < len(txs); i++ {
for _, tx := range txs { for _, tx := range txs {
if tx.Nonce() == uint64(i) {
_, gas, err := core.ApplyMessage(core.NewEnv(stateDb, self.ethereum.ChainManager(), tx, block), tx, coinbase) _, gas, err := core.ApplyMessage(core.NewEnv(stateDb, self.ethereum.ChainManager(), tx, block), tx, coinbase)
//self.ethereum.TxPool().RemoveSet([]*types.Transaction{tx}) //self.ethereum.TxPool().RemoveSet([]*types.Transaction{tx})
time.Sleep(time.Millisecond * 100)
self.t.Logf("ApplyMessage: gas %v err %v", gas, err) self.t.Logf("ApplyMessage: gas %v err %v", gas, err)
} }
}
}
self.ethereum.TxPool().RemoveSet(txs) self.ethereum.TxPool().RemoveSet(txs)
self.xeth = self.xeth.WithState(stateDb) self.xeth = self.xeth.WithState(stateDb)

Loading…
Cancel
Save