(t *testing.T)
| 48 | } |
| 49 | |
| 50 | func TestTxPool(t *testing.T) { |
| 51 | txPool := &TXPool{} |
| 52 | txPool.Init() |
| 53 | |
| 54 | txEntry := &TXEntry{ |
| 55 | Tx: txn, |
| 56 | Attrs: []*TXAttr{}, |
| 57 | } |
| 58 | |
| 59 | ret := txPool.AddTxList(txEntry) |
| 60 | if ret == false { |
| 61 | t.Error("Failed to add tx to the pool") |
| 62 | return |
| 63 | } |
| 64 | |
| 65 | ret = txPool.AddTxList(txEntry) |
| 66 | if ret == true { |
| 67 | t.Error("Failed to add tx to the pool") |
| 68 | return |
| 69 | } |
| 70 | |
| 71 | txList, oldTxList := txPool.GetTxPool(true, 0) |
| 72 | for _, v := range txList { |
| 73 | assert.NotNil(t, v) |
| 74 | } |
| 75 | |
| 76 | for _, v := range oldTxList { |
| 77 | assert.NotNil(t, v) |
| 78 | } |
| 79 | |
| 80 | entry := txPool.GetTransaction(txn.Hash()) |
| 81 | if entry == nil { |
| 82 | t.Error("Failed to get the transaction") |
| 83 | return |
| 84 | } |
| 85 | |
| 86 | assert.Equal(t, txn.Hash(), entry.Hash()) |
| 87 | |
| 88 | status := txPool.GetTxStatus(txn.Hash()) |
| 89 | if status == nil { |
| 90 | t.Error("failed to get the status") |
| 91 | return |
| 92 | } |
| 93 | |
| 94 | assert.Equal(t, txn.Hash(), status.Hash) |
| 95 | |
| 96 | count := txPool.GetTransactionCount() |
| 97 | assert.Equal(t, count, 1) |
| 98 | |
| 99 | err := txPool.CleanTransactionList([]*types.Transaction{txn}) |
| 100 | if err != nil { |
| 101 | t.Error("Failed to clean transaction list") |
| 102 | return |
| 103 | } |
| 104 | } |
nothing calls this directly
no test coverage detected