MCPcopy Create free account
hub / github.com/33cn/chain33 / TestTxHashCache_Add

Function TestTxHashCache_Add

blockchain/cache_test.go:89–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func 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
110func TestTxHashCache_Del(t *testing.T) {
111

Callers

nothing calls this directly

Calls 5

GenaddressFunction · 0.92
initTxHashCacheFunction · 0.85
newTestTxsFunction · 0.85
addTestBlockFunction · 0.70
AddMethod · 0.65

Tested by

no test coverage detected