@@ -18,6 +18,7 @@ import (
1818 "github.com/NethermindEth/juno/mocks"
1919 adaptfeeder "github.com/NethermindEth/juno/starknetdata/feeder"
2020 "github.com/NethermindEth/juno/utils/log"
21+ "github.com/stretchr/testify/assert"
2122 "github.com/stretchr/testify/require"
2223 "go.uber.org/mock/gomock"
2324)
@@ -155,18 +156,18 @@ func TestRestoreMempool(t *testing.T) {
155156 require .Equal (t , int (i ), pool .Len ())
156157 }
157158 // check the db has stored the transactions
158- time .Sleep (100 * time .Millisecond )
159- lenDB , err = pool .LenDB ()
160- require .NoError (t , err )
161- require .Equal (t , 3 , lenDB )
159+ require .EventuallyWithT (t , func (c * assert.CollectT ) {
160+ lenDB , err := pool .LenDB ()
161+ assert .NoError (c , err )
162+ assert .Equal (c , 3 , lenDB )
163+ }, 2 * time .Second , 10 * time .Millisecond )
162164 // Close the mempool
163165 pool .Close ()
164166 require .NoError (t , testDB .Close ())
165167 testDB , _ , err = setupDatabase ("testrestoremempool" , false )
166168 require .NoError (t , err )
167169
168170 poolRestored := mempool .New (testDB , chain , 1024 , logger )
169- time .Sleep (100 * time .Millisecond )
170171 require .NoError (t , poolRestored .LoadFromDB ())
171172 lenDB , err = poolRestored .LenDB ()
172173 require .NoError (t , err )
0 commit comments