Skip to content

Commit

Permalink
swamp: add options to swamp config (#728)
Browse files Browse the repository at this point in the history
* swamp: add options to swamp config
  • Loading branch information
vgonkivs authored May 19, 2022
1 parent 0466d9c commit d99e946
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
10 changes: 10 additions & 0 deletions node/tests/swamp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ func DefaultComponents() *Components {
CoreCfg: tnCfg,
}
}

// Option for modifying Swamp's Config.
type Option func(*Components)

// WithBlockInterval sets a custom interval for block creation.
func WithBlockInterval(interval time.Duration) Option {
return func(c *Components) {
c.CoreCfg.Consensus.CreateEmptyBlocksInterval = interval
}
}
7 changes: 6 additions & 1 deletion node/tests/swamp/swamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ type Swamp struct {
}

// NewSwamp creates a new instance of Swamp.
func NewSwamp(t *testing.T, ic *Components) *Swamp {
func NewSwamp(t *testing.T, options ...Option) *Swamp {
if testing.Verbose() {
log.SetDebugLogging()
}

ic := DefaultComponents()
for _, option := range options {
option(ic)
}

var err error
ctx := context.Background()

Expand Down
10 changes: 5 additions & 5 deletions node/tests/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Steps:
6. Check LN is synced to height 30
*/
func TestSyncLightWithBridge(t *testing.T) {
sw := swamp.NewSwamp(t, swamp.DefaultComponents())
sw := swamp.NewSwamp(t)

bridge := sw.NewBridgeNode()

Expand Down Expand Up @@ -76,7 +76,7 @@ Steps:
9. Check LN is synced to height 40
*/
func TestSyncStartStopLightWithBridge(t *testing.T) {
sw := swamp.NewSwamp(t, swamp.DefaultComponents())
sw := swamp.NewSwamp(t)

bridge := sw.NewBridgeNode()

Expand Down Expand Up @@ -128,7 +128,7 @@ Steps:
6. Check FN is synced to height 30
*/
func TestSyncFullWithBridge(t *testing.T) {
sw := swamp.NewSwamp(t, swamp.DefaultComponents())
sw := swamp.NewSwamp(t)

bridge := sw.NewBridgeNode()

Expand Down Expand Up @@ -174,7 +174,7 @@ Steps:
9. Check LN is synced to height 50
*/
func TestSyncLightWithFull(t *testing.T) {
sw := swamp.NewSwamp(t, swamp.DefaultComponents())
sw := swamp.NewSwamp(t)

bridge := sw.NewBridgeNode()

Expand Down Expand Up @@ -236,7 +236,7 @@ Steps:
9. Check LN is synced to height 50
*/
func TestSyncLightWithTrustedPeers(t *testing.T) {
sw := swamp.NewSwamp(t, swamp.DefaultComponents())
sw := swamp.NewSwamp(t)

bridge := sw.NewBridgeNode()

Expand Down

0 comments on commit d99e946

Please sign in to comment.