rpc: fix tests to count mempool; copy responses to avoid data races

This commit is contained in:
Ethan Buchman
2015-03-28 21:38:29 -07:00
parent fb90d5bc92
commit d30fc2fa43
4 changed files with 19 additions and 11 deletions

View File

@ -134,10 +134,11 @@ func TestHTTPBroadcastTx(t *testing.T) {
}
pool := node.MempoolReactor().Mempool
txs := pool.GetProposalTxs()
if len(txs) != 1 {
t.Fatal("The mem pool has %d txs. Expected 1", len(txs))
if len(txs) != mempoolCount+1 {
t.Fatalf("The mem pool has %d txs. Expected %d", len(txs), mempoolCount+1)
}
tx2 := txs[0].(*types.SendTx)
tx2 := txs[mempoolCount].(*types.SendTx)
mempoolCount += 1
if bytes.Compare(merkle.HashFromBinary(tx), merkle.HashFromBinary(tx2)) != 0 {
t.Fatal("inconsistent hashes for mempool tx and sent tx")
}