natspec test bugfix

This commit is contained in:
zsfelfoldi 2015-04-07 14:46:14 +02:00 committed by zelig
parent b635cad9fe
commit 8e6a068d2d

View File

@ -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,11 +218,14 @@ 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 _, tx := range txs { for i := 0; i < len(txs); i++ {
_, gas, err := core.ApplyMessage(core.NewEnv(stateDb, self.ethereum.ChainManager(), tx, block), tx, coinbase) for _, tx := range txs {
//self.ethereum.TxPool().RemoveSet([]*types.Transaction{tx}) if tx.Nonce() == uint64(i) {
time.Sleep(time.Millisecond * 100) _, gas, err := core.ApplyMessage(core.NewEnv(stateDb, self.ethereum.ChainManager(), tx, block), tx, coinbase)
self.t.Logf("ApplyMessage: gas %v err %v", gas, err) //self.ethereum.TxPool().RemoveSet([]*types.Transaction{tx})
self.t.Logf("ApplyMessage: gas %v err %v", gas, err)
}
}
} }
self.ethereum.TxPool().RemoveSet(txs) self.ethereum.TxPool().RemoveSet(txs)