Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Allow Creating test network without init #128

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore: Allow creating new test network without init
  • Loading branch information
kukugi committed Apr 14, 2021
commit 05f6384947881eaa87b3a3defa769cba78602e7a
27 changes: 27 additions & 0 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,33 @@ func New(t *testing.T, cfg Config) *Network {
return network
}

// New creates a new Network for integration tests without init.
func NewWithoutInit(t *testing.T, cfg Config, baseDir string, validators []*Validator) *Network {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does it use this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be used when running lbm node in lbm cli-test

// only one caller/test can create and use a network at a time
t.Log("acquiring test network lock")
lock.Lock()

network := &Network{
T: t,
BaseDir: baseDir,
Validators: validators,
Config: cfg,
}

t.Log("starting test network...")
for _, v := range network.Validators {
require.NoError(t, startInProcess(cfg, v))
}

t.Log("started test network")

// Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as any
// defer in a test would not be called.
server.TrapSignal(network.Cleanup)

return network
}

// LatestHeight returns the latest height of the network or an error if the
// query fails or no validators exist.
func (n *Network) LatestHeight() (int64, error) {
Expand Down