Skip to content

Commit

Permalink
update changelog PR number and added unit test for Stop() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Jun 21, 2024
1 parent 72061f3 commit 0ee1e60
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* [2340](https://github.com/zeta-chain/node/pull/2340) - add ValidateInbound method for cctx orchestrator
* [2344](https://github.com/zeta-chain/node/pull/2344) - group common data of EVM/Bitcoin signer and observer using base structs
* [2357](https://github.com/zeta-chain/node/pull/2357) - integrate base Signer structure into EVM/Bitcoin Signer
* [2359](https://github.com/zeta-chain/node/pull/2357) - integrate base Observer structure into EVM/Bitcoin Observer
* [2359](https://github.com/zeta-chain/node/pull/2359) - integrate base Observer structure into EVM/Bitcoin Observer

### Tests

Expand Down
8 changes: 5 additions & 3 deletions zetaclient/chains/base/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ func (ob *Observer) Stop() {
close(ob.stop)

// close database
err := ob.CloseDB()
if err != nil {
ob.Logger().Chain.Error().Err(err).Msgf("CloseDB failed for chain %d", ob.Chain().ChainId)
if ob.db != nil {
err := ob.CloseDB()
if err != nil {
ob.Logger().Chain.Error().Err(err).Msgf("CloseDB failed for chain %d", ob.Chain().ChainId)

Check warning on line 141 in zetaclient/chains/base/observer.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/base/observer.go#L141

Added line #L141 was not covered by tests
}
}
ob.Logger().Chain.Info().Msgf("observer stopped for chain %d", ob.Chain().ChainId)
}
Expand Down
11 changes: 11 additions & 0 deletions zetaclient/chains/base/observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ func TestNewObserver(t *testing.T) {
}
}

func TestStop(t *testing.T) {
t.Run("should be able to stop observer", func(t *testing.T) {
// create observer and initialize db
ob := createObserver(t)
ob.OpenDB(sample.CreateTempDir(t), "")

// stop observer
ob.Stop()
})
}

func TestObserverGetterAndSetter(t *testing.T) {
t.Run("should be able to update chain", func(t *testing.T) {
ob := createObserver(t)
Expand Down

0 comments on commit 0ee1e60

Please sign in to comment.