Skip to content

Commit

Permalink
e2e: cancel syncer context
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Aug 23, 2024
1 parent 037e9dd commit 6a07b6a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions internal/test/e2e/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ type Host struct {
dir string
privKey types.PrivateKey

s *syncer.Syncer
cm *chain.Manager
chainDB *coreutils.BoltChainDB
s *syncer.Syncer
syncerCancel context.CancelFunc
cm *chain.Manager
chainDB *coreutils.BoltChainDB

store *sqlite.Store
wallet *wallet.SingleAddressWallet
Expand Down Expand Up @@ -157,6 +158,7 @@ func (h *Host) Close() error {
h.contracts.Close()
h.storage.Close()
h.store.Close()
h.syncerCancel()
h.s.Close()
h.chainDB.Close()
return nil
Expand Down Expand Up @@ -242,7 +244,8 @@ func NewHost(privKey types.PrivateKey, dir string, network *consensus.Network, g
NetAddress: l.Addr().String(),
}, syncer.WithPeerDiscoveryInterval(100*time.Millisecond), syncer.WithSyncInterval(100*time.Millisecond))
syncErrChan := make(chan error, 1)
go func() { syncErrChan <- s.Run(context.Background()) }()
syncerCtx, syncerCancel := context.WithCancel(context.Background())

Check failure on line 247 in internal/test/e2e/host.go

View workflow job for this annotation

GitHub Actions / analyze

lostcancel: the syncerCancel function is not used on all paths (possible context leak) (govet)
go func() { syncErrChan <- s.Run(syncerCtx) }()

log := zap.NewNop()
db, err := sqlite.OpenDatabase(filepath.Join(dir, "hostd.db"), log.Named("sqlite"))
Expand Down Expand Up @@ -304,9 +307,10 @@ func NewHost(privKey types.PrivateKey, dir string, network *consensus.Network, g
dir: dir,
privKey: privKey,

s: s,
cm: cm,
chainDB: chainDB,
s: s,
syncerCancel: syncerCancel,
cm: cm,
chainDB: chainDB,

store: db,
wallet: wallet,
Expand Down

0 comments on commit 6a07b6a

Please sign in to comment.