Browse Source

rpc: fix memcount error in tests

pull/46/head
Ethan Buchman 10 years ago
parent
commit
6b5383918f
2 changed files with 9 additions and 8 deletions
  1. +2
    -2
      rpc/test/helpers.go
  2. +7
    -6
      rpc/test/tests.go

+ 2
- 2
rpc/test/helpers.go View File

@ -29,7 +29,7 @@ var (
userPriv = "FDE3BD94CB327D19464027BA668194C5EFA46AE83E8419D7542CFF41F00C81972239C21C81EA7173A6C489145490C015E05D4B97448933B708A7EC5B7B4921E3"
userPub = "2239C21C81EA7173A6C489145490C015E05D4B97448933B708A7EC5B7B4921E3"
clients = map[string]rpc.Client{
clients = map[string]rpc.Client{
"JSONRPC": rpc.NewClient(requestAddr, "JSONRPC"),
"HTTP": rpc.NewClient(requestAddr, "HTTP"),
}
@ -43,7 +43,6 @@ func decodeHex(hexStr string) []byte {
return bytes
}
// create a new node and sleep forever
func newNode(ready chan struct{}) {
// Create & start node
@ -196,6 +195,7 @@ func broadcastTx(t *testing.T, typ string, fromAddr, toAddr, data []byte, key [6
if err != nil {
t.Fatal(err)
}
mempoolCount += 1
return tx, resp.Receipt
}


+ 7
- 6
rpc/test/tests.go View File

@ -85,11 +85,10 @@ func testBroadcastTx(t *testing.T, typ string) {
}
pool := node.MempoolReactor().Mempool
txs := pool.GetProposalTxs()
if len(txs) != mempoolCount+1 {
t.Fatalf("The mem pool has %d txs. Expected %d", len(txs), mempoolCount+1)
if len(txs) != mempoolCount {
t.Fatalf("The mem pool has %d txs. Expected %d", len(txs), mempoolCount)
}
tx2 := txs[mempoolCount].(*types.SendTx)
mempoolCount += 1
tx2 := txs[mempoolCount-1].(*types.SendTx)
n, err := new(int64), new(error)
buf1, buf2 := new(bytes.Buffer), new(bytes.Buffer)
tx.WriteSignBytes(buf1, n, err)
@ -122,8 +121,10 @@ func testGetStorage(t *testing.T, typ string) {
if len(contractAddr) == 0 {
t.Fatal("Creates contract but resulting address is empty")
}
// allow it to get mined
time.Sleep(time.Second * 20)
mempoolCount -= 1
mempoolCount = 0
v := getStorage(t, typ, contractAddr, []byte{0x1})
got := RightPadWord256(v)
@ -190,7 +191,7 @@ func testCall(t *testing.T, typ string) {
// allow it to get mined
time.Sleep(time.Second * 20)
mempoolCount -= 1
mempoolCount = 0
// run a call through the contract
data := []byte{}


Loading…
Cancel
Save