From 8e6a068d2d5b6374e0a8588a34a96a26562bae83 Mon Sep 17 00:00:00 2001 From: zsfelfoldi Date: Tue, 7 Apr 2015 14:46:14 +0200 Subject: [PATCH] natspec test bugfix --- common/natspec/natspec_e2e_test.go | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/common/natspec/natspec_e2e_test.go b/common/natspec/natspec_e2e_test.go index 43a1fdf1c9..aff094d1d0 100644 --- a/common/natspec/natspec_e2e_test.go +++ b/common/natspec/natspec_e2e_test.go @@ -6,7 +6,6 @@ import ( "math/big" "os" "testing" - "time" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" @@ -28,7 +27,6 @@ type testFrontend struct { xeth *xe.XEth api *rpc.EthereumApi coinbase string - txc int lastConfirm string makeNatSpec bool } @@ -175,6 +173,9 @@ func testInit(t *testing.T) (self *testFrontend) { 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))) data := "0x" + hash[0:8] for _, arg := range args { @@ -192,26 +193,19 @@ func (self *testFrontend) insertTx(addr, contract, fnsig string, args []string) "data": "` + data + `" }] ` - self.txc++ req := &rpc.RpcRequest{ Jsonrpc: "2.0", Method: "eth_transact", Params: []byte(jsontx), - Id: self.txc, + Id: 6, } - txcount := self.ethereum.TxPool().Size() - var reply interface{} err0 := self.api.GetRequestReply(req, &reply) if err0 != nil { 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) } @@ -224,11 +218,14 @@ func (self *testFrontend) applyTxs() { coinbase.SetGasPool(big.NewInt(1000000)) txs := self.ethereum.TxPool().GetTransactions() - for _, tx := range txs { - _, gas, err := core.ApplyMessage(core.NewEnv(stateDb, self.ethereum.ChainManager(), tx, block), tx, coinbase) - //self.ethereum.TxPool().RemoveSet([]*types.Transaction{tx}) - time.Sleep(time.Millisecond * 100) - self.t.Logf("ApplyMessage: gas %v err %v", gas, err) + for i := 0; i < len(txs); i++ { + for _, tx := range txs { + if tx.Nonce() == uint64(i) { + _, gas, err := core.ApplyMessage(core.NewEnv(stateDb, self.ethereum.ChainManager(), tx, block), tx, coinbase) + //self.ethereum.TxPool().RemoveSet([]*types.Transaction{tx}) + self.t.Logf("ApplyMessage: gas %v err %v", gas, err) + } + } } self.ethereum.TxPool().RemoveSet(txs)