-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c902e89
commit 6285f51
Showing
6 changed files
with
69 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package restore | ||
|
||
import "errors" | ||
|
||
const ( | ||
DefaultRemote = "http://127.0.0.1:26657" | ||
) | ||
|
||
var errInvalidRemote = errors.New("invalid remote address") | ||
|
||
// Config is the base chain restore config | ||
type Config struct { | ||
Remote string // the remote JSON-RPC URL of the chain | ||
} | ||
|
||
// DefaultConfig returns the default restore configuration | ||
func DefaultConfig() Config { | ||
return Config{ | ||
Remote: DefaultRemote, | ||
} | ||
} | ||
|
||
// ValidateConfig validates the base restore configuration | ||
func ValidateConfig(cfg Config) error { | ||
if cfg.Remote == "" { | ||
return errInvalidRemote | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package restore | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConfig_ValidateConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("invalid remote address", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
cfg := DefaultConfig() | ||
cfg.Remote = "" | ||
|
||
assert.ErrorIs(t, ValidateConfig(cfg), errInvalidRemote) | ||
}) | ||
|
||
t.Run("valid configuration", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
cfg := DefaultConfig() | ||
|
||
assert.NoError(t, ValidateConfig(cfg)) | ||
}) | ||
} |