Skip to content

Commit

Permalink
fix: inmemory db cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <[email protected]>
  • Loading branch information
gfanton committed Jan 6, 2025
1 parent 2d9e101 commit dfe212b
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions gno.land/pkg/integration/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ func RunNode(ctx context.Context, pcfg *ProcessNodeConfig, stdout, stderr io.Wri
logger := slog.New(handler)

// Initialize database
data, err := initDatabase(pcfg.DBDir)
db, err := initDatabase(pcfg.DBDir)
if err != nil {
return err
}

Check warning on line 77 in gno.land/pkg/integration/process.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/process.go#L76-L77

Added lines #L76 - L77 were not covered by tests
defer db.Close() // ensure db is close

nodecfg := TestingMinimalNodeConfig(pcfg.RootDir)

Expand All @@ -85,7 +86,7 @@ func RunNode(ctx context.Context, pcfg *ProcessNodeConfig, stdout, stderr io.Wri
pv := nodecfg.PrivValidator.GetPubKey()

// Setup node configuration
nodecfg.DB = data
nodecfg.DB = db
nodecfg.TMConfig.DBPath = pcfg.DBDir
nodecfg.TMConfig = pcfg.TMConfig
nodecfg.Genesis = pcfg.Genesis.ToGenesisDoc()
Expand Down Expand Up @@ -272,16 +273,23 @@ func RunInMemoryProcess(ctx context.Context, cfg ProcessConfig) (NodeProcess, er
}()

address, err := waitForProcessReady(ctx, out, cfg.Stdout)
if err != nil {
cancel()
return nil, err
if err == nil { // ok
return &nodeInMemoryProcess{
address: address,
stop: cancel,
ccNodeError: ccStopErr,
}, nil
}

return &nodeInMemoryProcess{
address: address,
stop: cancel,
ccNodeError: ccStopErr,
}, nil
cancel()

select {
case err = <-ccStopErr: // return node error in priority
default:

Check warning on line 288 in gno.land/pkg/integration/process.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/process.go#L284-L288

Added lines #L284 - L288 were not covered by tests
}

return nil, err

Check warning on line 291 in gno.land/pkg/integration/process.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/process.go#L291

Added line #L291 was not covered by tests

}

Check failure on line 293 in gno.land/pkg/integration/process.go

View workflow job for this annotation

GitHub Actions / Run gno.land suite / Go Lint / lint

unnecessary trailing newline (whitespace)

func RunMain(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error {
Expand Down

0 comments on commit dfe212b

Please sign in to comment.