(t *testing.T)
| 87 | } |
| 88 | |
| 89 | func TestTxHashCache_Add(t *testing.T) { |
| 90 | |
| 91 | var txHeightRange int64 = 5 |
| 92 | tc, chain, cfg := initTxHashCache(txHeightRange) |
| 93 | _, priv := util.Genaddress() |
| 94 | |
| 95 | addTestBlock(chain, cfg, priv, 0, txHeightRange, 30) |
| 96 | currHeight := tc.currBlockHeight |
| 97 | require.Equal(t, 29, int(currHeight)) |
| 98 | for i := 15; i < 34; i++ { |
| 99 | _, ok := tc.txHashes[int64(i)] |
| 100 | require.True(t, ok) |
| 101 | } |
| 102 | require.Equal(t, 20, len(tc.txHashes)) |
| 103 | txs := newTestTxs(cfg, priv, currHeight+1, txHeightRange) |
| 104 | tc.Add(&types.Block{Txs: txs, Height: currHeight + 1}) |
| 105 | |
| 106 | require.Nil(t, tc.txHashes[15]) |
| 107 | require.NotNil(t, tc.txHashes[35]) |
| 108 | } |
| 109 | |
| 110 | func TestTxHashCache_Del(t *testing.T) { |
| 111 |
nothing calls this directly
no test coverage detected