mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 20:24:21 +01:00
Add integration tests for sweeping rounds (#339)
* add "block" scheduler type + sweep integration test * increase timeout in integrationtests * remove config logs * rename scheduler package name * rename package * rename packages
This commit is contained in:
@@ -8,7 +8,8 @@ import (
|
||||
"github.com/ark-network/ark/server/internal/core/application"
|
||||
"github.com/ark-network/ark/server/internal/core/ports"
|
||||
"github.com/ark-network/ark/server/internal/infrastructure/db"
|
||||
scheduler "github.com/ark-network/ark/server/internal/infrastructure/scheduler/gocron"
|
||||
blockscheduler "github.com/ark-network/ark/server/internal/infrastructure/scheduler/block"
|
||||
timescheduler "github.com/ark-network/ark/server/internal/infrastructure/scheduler/gocron"
|
||||
txbuilder "github.com/ark-network/ark/server/internal/infrastructure/tx-builder/covenant"
|
||||
cltxbuilder "github.com/ark-network/ark/server/internal/infrastructure/tx-builder/covenantless"
|
||||
fileunlocker "github.com/ark-network/ark/server/internal/infrastructure/unlocker/file"
|
||||
@@ -29,6 +30,7 @@ var (
|
||||
}
|
||||
supportedSchedulers = supportedType{
|
||||
"gocron": {},
|
||||
"block": {},
|
||||
}
|
||||
supportedTxBuilders = supportedType{
|
||||
"covenant": {},
|
||||
@@ -115,11 +117,23 @@ func (c *Config) Validate() error {
|
||||
if len(c.WalletAddr) <= 0 {
|
||||
return fmt.Errorf("missing onchain wallet address")
|
||||
}
|
||||
// round life time must be a multiple of 512
|
||||
if c.RoundLifetime < minAllowedSequence {
|
||||
return fmt.Errorf(
|
||||
"invalid round lifetime, must be a at least %d", minAllowedSequence,
|
||||
)
|
||||
if c.SchedulerType != "block" {
|
||||
return fmt.Errorf("scheduler type must be block if round lifetime is expressed in blocks")
|
||||
}
|
||||
} else {
|
||||
if c.SchedulerType != "gocron" {
|
||||
return fmt.Errorf("scheduler type must be gocron if round lifetime is expressed in seconds")
|
||||
}
|
||||
|
||||
// round life time must be a multiple of 512 if expressed in seconds
|
||||
if c.RoundLifetime%minAllowedSequence != 0 {
|
||||
c.RoundLifetime -= c.RoundLifetime % minAllowedSequence
|
||||
log.Infof(
|
||||
"round lifetime must be a multiple of %d, rounded to %d",
|
||||
minAllowedSequence, c.RoundLifetime,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if c.UnilateralExitDelay < minAllowedSequence {
|
||||
@@ -134,14 +148,6 @@ func (c *Config) Validate() error {
|
||||
)
|
||||
}
|
||||
|
||||
if c.RoundLifetime%minAllowedSequence != 0 {
|
||||
c.RoundLifetime -= c.RoundLifetime % minAllowedSequence
|
||||
log.Infof(
|
||||
"round lifetime must be a multiple of %d, rounded to %d",
|
||||
minAllowedSequence, c.RoundLifetime,
|
||||
)
|
||||
}
|
||||
|
||||
if c.UnilateralExitDelay%minAllowedSequence != 0 {
|
||||
c.UnilateralExitDelay -= c.UnilateralExitDelay % minAllowedSequence
|
||||
log.Infof(
|
||||
@@ -328,7 +334,9 @@ func (c *Config) schedulerService() error {
|
||||
var err error
|
||||
switch c.SchedulerType {
|
||||
case "gocron":
|
||||
svc = scheduler.NewScheduler()
|
||||
svc = timescheduler.NewScheduler()
|
||||
case "block":
|
||||
svc, err = blockscheduler.NewScheduler(c.EsploraURL)
|
||||
default:
|
||||
err = fmt.Errorf("unknown scheduler type")
|
||||
}
|
||||
@@ -367,7 +375,12 @@ func (c *Config) appService() error {
|
||||
}
|
||||
|
||||
func (c *Config) adminService() error {
|
||||
c.adminSvc = application.NewAdminService(c.wallet, c.repo, c.txBuilder)
|
||||
unit := ports.UnixTime
|
||||
if c.RoundLifetime < minAllowedSequence {
|
||||
unit = ports.BlockHeight
|
||||
}
|
||||
|
||||
c.adminSvc = application.NewAdminService(c.wallet, c.repo, c.txBuilder, unit)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user