@ -216,6 +216,63 @@ func TestMempoolUpdate(t *testing.T) {
}
}
}
}
func TestMempool_KeepInvalidTxsInCache ( t * testing . T ) {
app := counter . NewApplication ( true )
cc := proxy . NewLocalClientCreator ( app )
wcfg := cfg . DefaultConfig ( )
wcfg . Mempool . KeepInvalidTxsInCache = true
mempool , cleanup := newMempoolWithAppAndConfig ( cc , wcfg )
defer cleanup ( )
// 1. An invalid transaction must remain in the cache after Update
{
a := make ( [ ] byte , 8 )
binary . BigEndian . PutUint64 ( a , 0 )
b := make ( [ ] byte , 8 )
binary . BigEndian . PutUint64 ( b , 1 )
err := mempool . CheckTx ( b , nil , TxInfo { } )
require . NoError ( t , err )
// simulate new block
_ = app . DeliverTx ( abci . RequestDeliverTx { Tx : a } )
_ = app . DeliverTx ( abci . RequestDeliverTx { Tx : b } )
err = mempool . Update ( 1 , [ ] types . Tx { a , b } ,
[ ] * abci . ResponseDeliverTx { { Code : abci . CodeTypeOK } , { Code : 2 } } , nil , nil )
require . NoError ( t , err )
// a must be added to the cache
err = mempool . CheckTx ( a , nil , TxInfo { } )
if assert . Error ( t , err ) {
assert . Equal ( t , ErrTxInCache , err )
}
// b must remain in the cache
err = mempool . CheckTx ( b , nil , TxInfo { } )
if assert . Error ( t , err ) {
assert . Equal ( t , ErrTxInCache , err )
}
}
// 2. An invalid transaction must remain in the cache
{
a := make ( [ ] byte , 8 )
binary . BigEndian . PutUint64 ( a , 0 )
// remove a from the cache to test (2)
mempool . cache . Remove ( a )
err := mempool . CheckTx ( a , nil , TxInfo { } )
require . NoError ( t , err )
err = mempool . CheckTx ( a , nil , TxInfo { } )
if assert . Error ( t , err ) {
assert . Equal ( t , ErrTxInCache , err )
}
}
}
func TestTxsAvailable ( t * testing . T ) {
func TestTxsAvailable ( t * testing . T ) {
app := kvstore . NewApplication ( )
app := kvstore . NewApplication ( )
cc := proxy . NewLocalClientCreator ( app )
cc := proxy . NewLocalClientCreator ( app )