@@ -25,12 +25,17 @@ import (
2525type MockBidderRegistryContract struct {
2626 DepositForWindowsFunc func (opts * bind.TransactOpts , windows []* big.Int ) (* types.Transaction , error )
2727 WithdrawFromWindowsFunc func (opts * bind.TransactOpts , windows []* big.Int ) (* types.Transaction , error )
28+ DepositForWindowFunc func (opts * bind.TransactOpts , window * big.Int ) (* types.Transaction , error )
2829}
2930
3031func (m * MockBidderRegistryContract ) DepositForWindows (opts * bind.TransactOpts , windows []* big.Int ) (* types.Transaction , error ) {
3132 return m .DepositForWindowsFunc (opts , windows )
3233}
3334
35+ func (m * MockBidderRegistryContract ) DepositForWindow (opts * bind.TransactOpts , window * big.Int ) (* types.Transaction , error ) {
36+ return m .DepositForWindowFunc (opts , window )
37+ }
38+
3439func (m * MockBidderRegistryContract ) WithdrawFromWindows (opts * bind.TransactOpts , windows []* big.Int ) (* types.Transaction , error ) {
3540 return m .WithdrawFromWindowsFunc (opts , windows )
3641}
@@ -58,6 +63,7 @@ func TestAutoDepositTracker_Start(t *testing.T) {
5863 }
5964
6065 amount := big .NewInt (100 )
66+ oracleWindowOffset := big .NewInt (1 )
6167 logger := util .NewTestLogger (os .Stdout )
6268 evtMgr := events .NewListener (logger , & btABI , & brABI )
6369 brContract := & MockBidderRegistryContract {
@@ -67,6 +73,9 @@ func TestAutoDepositTracker_Start(t *testing.T) {
6773 WithdrawFromWindowsFunc : func (opts * bind.TransactOpts , windows []* big.Int ) (* types.Transaction , error ) {
6874 return types .NewTransaction (1 , common.Address {}, nil , 0 , nil , nil ), nil
6975 },
76+ DepositForWindowFunc : func (opts * bind.TransactOpts , window * big.Int ) (* types.Transaction , error ) {
77+ return types .NewTransaction (1 , common.Address {}, nil , 0 , nil , nil ), nil
78+ },
7079 }
7180 btContract := & MockBlockTrackerContract {
7281 GetCurrentWindowFunc : func () (* big.Int , error ) {
@@ -80,7 +89,7 @@ func TestAutoDepositTracker_Start(t *testing.T) {
8089 st := store .New (inmemstorage .New ())
8190
8291 // Create AutoDepositTracker instance
83- adt := autodepositor .New (evtMgr , brContract , btContract , optsGetter , st , logger )
92+ adt := autodepositor .New (evtMgr , brContract , btContract , optsGetter , st , oracleWindowOffset , logger )
8493
8594 // Start AutoDepositTracker
8695 ctx := context .Background ()
@@ -114,17 +123,13 @@ func TestAutoDepositTracker_Start(t *testing.T) {
114123
115124 assertStatus (t , true , []uint64 {2 , 3 })
116125
117- publishNewWindow (evtMgr , & btABI , big .NewInt (1 ))
118-
119- assertStatus (t , true , []uint64 {2 , 3 , 4 })
120-
121126 publishNewWindow (evtMgr , & btABI , big .NewInt (2 ))
122127
123- assertStatus (t , true , []uint64 {2 , 3 , 4 , 5 })
128+ assertStatus (t , true , []uint64 {2 , 3 , 4 })
124129
125130 publishNewWindow (evtMgr , & btABI , big .NewInt (3 ))
126131
127- assertStatus (t , true , []uint64 {3 , 4 , 5 , 6 })
132+ assertStatus (t , true , []uint64 {3 , 4 , 5 })
128133
129134 // Stop AutoDepositTracker
130135 windowNumbers , err := adt .Stop ()
@@ -133,7 +138,7 @@ func TestAutoDepositTracker_Start(t *testing.T) {
133138 }
134139
135140 // Assert window numbers
136- expectedWindowNumbers := []* big.Int {big .NewInt (3 ), big .NewInt (4 ), big .NewInt (5 ), big . NewInt ( 6 ) }
141+ expectedWindowNumbers := []* big.Int {big .NewInt (3 ), big .NewInt (4 ), big .NewInt (5 )}
137142 if len (windowNumbers ) != len (expectedWindowNumbers ) {
138143 t .Fatalf ("expected %d window numbers, got %d" , len (expectedWindowNumbers ), len (windowNumbers ))
139144 }
@@ -143,7 +148,7 @@ func TestAutoDepositTracker_Start(t *testing.T) {
143148 }
144149 }
145150
146- assertStatus (t , false , []uint64 {3 , 4 , 5 , 6 })
151+ assertStatus (t , false , []uint64 {3 , 4 , 5 })
147152}
148153
149154func TestAutoDepositTracker_Start_CancelContext (t * testing.T ) {
@@ -166,6 +171,9 @@ func TestAutoDepositTracker_Start_CancelContext(t *testing.T) {
166171 DepositForWindowsFunc : func (opts * bind.TransactOpts , windows []* big.Int ) (* types.Transaction , error ) {
167172 return types .NewTransaction (1 , common.Address {}, nil , 0 , nil , nil ), nil
168173 },
174+ DepositForWindowFunc : func (opts * bind.TransactOpts , window * big.Int ) (* types.Transaction , error ) {
175+ return types .NewTransaction (1 , common.Address {}, nil , 0 , nil , nil ), nil
176+ },
169177 }
170178 btContract := & MockBlockTrackerContract {
171179 GetCurrentWindowFunc : func () (* big.Int , error ) {
@@ -176,10 +184,11 @@ func TestAutoDepositTracker_Start_CancelContext(t *testing.T) {
176184 return & bind.TransactOpts {}, nil
177185 }
178186
187+ oracleWindowOffset := big .NewInt (1 )
179188 st := store .New (inmemstorage .New ())
180189
181190 // Create AutoDepositTracker instance
182- adt := autodepositor .New (evtMgr , brContract , btContract , optsGetter , st , logger )
191+ adt := autodepositor .New (evtMgr , brContract , btContract , optsGetter , st , oracleWindowOffset , logger )
183192
184193 // Start AutoDepositTracker with a cancelable context
185194 ctx , cancel := context .WithCancel (context .Background ())
@@ -214,10 +223,11 @@ func TestAutoDepositTracker_Stop_NotRunning(t *testing.T) {
214223 return & bind.TransactOpts {}, nil
215224 }
216225
226+ oracleWindowOffset := big .NewInt (1 )
217227 st := store .New (inmemstorage .New ())
218228
219229 // Create AutoDepositTracker instance
220- adt := autodepositor .New (evtMgr , brContract , btContract , optsGetter , st , logger )
230+ adt := autodepositor .New (evtMgr , brContract , btContract , optsGetter , st , oracleWindowOffset , logger )
221231
222232 // Stop AutoDepositTracker when not running
223233 _ , err = adt .Stop ()
@@ -257,10 +267,11 @@ func TestAutoDepositTracker_IsWorking(t *testing.T) {
257267 return & bind.TransactOpts {}, nil
258268 }
259269
270+ oracleWindowOffset := big .NewInt (1 )
260271 st := store .New (inmemstorage .New ())
261272
262273 // Create AutoDepositTracker instance
263- adt := autodepositor .New (evtMgr , brContract , btContract , optsGetter , st , logger )
274+ adt := autodepositor .New (evtMgr , brContract , btContract , optsGetter , st , oracleWindowOffset , logger )
264275
265276 // Assert initial IsWorking status
266277 if adt .IsWorking () {
0 commit comments