@@ -19,6 +19,7 @@ package file_test
1919import (
2020 "context"
2121 "errors"
22+ "math/big"
2223 "os"
2324 "testing"
2425
@@ -162,71 +163,93 @@ func TestCSVFileIndexerNonCanonical(t *testing.T) {
162163 })
163164}
164165
165- // func TestCSVFileWatchAddressMethods(t *testing.T) {
166- // setupCSVIndexer(t)
167- // defer tearDownCSV(t)
168-
169- // t.Run("Load watched addresses (empty table)", func(t *testing.T) {
170- // testLoadEmptyWatchedAddresses(t)
171- // })
172-
173- // t.Run("Insert watched addresses", func(t *testing.T) {
174- // testInsertWatchedAddresses(t, func(t *testing.T) {
175- // test_helpers.TearDownDB(t, db)
176- // dumpWatchedAddressesCSVFileData(t)
177- // })
178- // })
179-
180- // t.Run("Insert watched addresses (some already watched)", func(t *testing.T) {
181- // testInsertAlreadyWatchedAddresses(t, func(t *testing.T) {
182- // test_helpers.TearDownDB(t, db)
183- // dumpWatchedAddressesCSVFileData(t)
184- // })
185- // })
186-
187- // t.Run("Remove watched addresses", func(t *testing.T) {
188- // testRemoveWatchedAddresses(t, func(t *testing.T) {
189- // test_helpers.TearDownDB(t, db)
190- // dumpWatchedAddressesCSVFileData(t)
191- // })
192- // })
193-
194- // t.Run("Remove watched addresses (some non-watched)", func(t *testing.T) {
195- // testRemoveNonWatchedAddresses(t, func(t *testing.T) {
196- // test_helpers.TearDownDB(t, db)
197- // dumpWatchedAddressesCSVFileData(t)
198- // })
199- // })
200-
201- // t.Run("Set watched addresses", func(t *testing.T) {
202- // testSetWatchedAddresses(t, func(t *testing.T) {
203- // test_helpers.TearDownDB(t, db)
204- // dumpWatchedAddressesCSVFileData(t)
205- // })
206- // })
207-
208- // t.Run("Set watched addresses (some already watched)", func(t *testing.T) {
209- // testSetAlreadyWatchedAddresses(t, func(t *testing.T) {
210- // test_helpers.TearDownDB(t, db)
211- // dumpWatchedAddressesCSVFileData(t)
212- // })
213- // })
214-
215- // t.Run("Load watched addresses", func(t *testing.T) {
216- // testLoadWatchedAddresses(t)
217- // })
218-
219- // t.Run("Clear watched addresses", func(t *testing.T) {
220- // testClearWatchedAddresses(t, func(t *testing.T) {
221- // test_helpers.TearDownDB(t, db)
222- // dumpWatchedAddressesCSVFileData(t)
223- // })
224- // })
225-
226- // t.Run("Clear watched addresses (empty table)", func(t *testing.T) {
227- // testClearEmptyWatchedAddresses(t, func(t *testing.T) {
228- // test_helpers.TearDownDB(t, db)
229- // dumpWatchedAddressesCSVFileData(t)
230- // })
231- // })
232- // }
166+ func TestCSVFileWatchAddressMethods (t * testing.T ) {
167+ setupCSVIndexer (t )
168+ defer tearDownCSV (t )
169+
170+ t .Run ("Load watched addresses (empty table)" , func (t * testing.T ) {
171+ test .TestLoadEmptyWatchedAddresses (t , ind )
172+ })
173+
174+ t .Run ("Insert watched addresses" , func (t * testing.T ) {
175+ args := mocks .GetInsertWatchedAddressesArgs ()
176+ err = ind .InsertWatchedAddresses (args , big .NewInt (int64 (mocks .WatchedAt1 )))
177+ require .NoError (t , err )
178+
179+ resetAndDumpWatchedAddressesCSVFileData (t )
180+
181+ test .TestInsertWatchedAddresses (t , db )
182+ })
183+
184+ t .Run ("Insert watched addresses (some already watched)" , func (t * testing.T ) {
185+ args := mocks .GetInsertAlreadyWatchedAddressesArgs ()
186+ err = ind .InsertWatchedAddresses (args , big .NewInt (int64 (mocks .WatchedAt2 )))
187+ require .NoError (t , err )
188+
189+ resetAndDumpWatchedAddressesCSVFileData (t )
190+
191+ test .TestInsertAlreadyWatchedAddresses (t , db )
192+ })
193+
194+ t .Run ("Remove watched addresses" , func (t * testing.T ) {
195+ args := mocks .GetRemoveWatchedAddressesArgs ()
196+ err = ind .RemoveWatchedAddresses (args )
197+ require .NoError (t , err )
198+
199+ resetAndDumpWatchedAddressesCSVFileData (t )
200+
201+ test .TestRemoveWatchedAddresses (t , db )
202+ })
203+
204+ t .Run ("Remove watched addresses (some non-watched)" , func (t * testing.T ) {
205+ args := mocks .GetRemoveNonWatchedAddressesArgs ()
206+ err = ind .RemoveWatchedAddresses (args )
207+ require .NoError (t , err )
208+
209+ resetAndDumpWatchedAddressesCSVFileData (t )
210+
211+ test .TestRemoveNonWatchedAddresses (t , db )
212+ })
213+
214+ t .Run ("Set watched addresses" , func (t * testing.T ) {
215+ args := mocks .GetSetWatchedAddressesArgs ()
216+ err = ind .SetWatchedAddresses (args , big .NewInt (int64 (mocks .WatchedAt2 )))
217+ require .NoError (t , err )
218+
219+ resetAndDumpWatchedAddressesCSVFileData (t )
220+
221+ test .TestSetWatchedAddresses (t , db )
222+ })
223+
224+ t .Run ("Set watched addresses (some already watched)" , func (t * testing.T ) {
225+ args := mocks .GetSetAlreadyWatchedAddressesArgs ()
226+ err = ind .SetWatchedAddresses (args , big .NewInt (int64 (mocks .WatchedAt3 )))
227+ require .NoError (t , err )
228+
229+ resetAndDumpWatchedAddressesCSVFileData (t )
230+
231+ test .TestSetAlreadyWatchedAddresses (t , db )
232+ })
233+
234+ t .Run ("Load watched addresses" , func (t * testing.T ) {
235+ test .TestLoadWatchedAddresses (t , ind )
236+ })
237+
238+ t .Run ("Clear watched addresses" , func (t * testing.T ) {
239+ err = ind .ClearWatchedAddresses ()
240+ require .NoError (t , err )
241+
242+ resetAndDumpWatchedAddressesCSVFileData (t )
243+
244+ test .TestClearWatchedAddresses (t , db )
245+ })
246+
247+ t .Run ("Clear watched addresses (empty table)" , func (t * testing.T ) {
248+ err = ind .ClearWatchedAddresses ()
249+ require .NoError (t , err )
250+
251+ resetAndDumpWatchedAddressesCSVFileData (t )
252+
253+ test .TestClearEmptyWatchedAddresses (t , db )
254+ })
255+ }
0 commit comments