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

[Phase 1]: Tunnel offchain relayer #1

Merged
merged 20 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test
  • Loading branch information
nkitlabs committed Oct 14, 2024
commit 606b71e61f0fd6856c1c1b7993696dfbcbde1df0
50 changes: 50 additions & 0 deletions falcon/app_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package falcon_test

import (
"os"
"path"
"testing"

"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/require"

"github.com/bandprotocol/falcon/falcon"
)

func TestInitConfig(t *testing.T) {
tmpDir := t.TempDir()

// Test InitConfig
app := falcon.NewApp(nil, nil, tmpDir, false, nil)

err := app.InitConfigFile(tmpDir)
require.NoError(t, err)

require.FileExists(t, path.Join(tmpDir, "config", "config.toml"))

// read the file
b, err := os.ReadFile(path.Join(tmpDir, "config", "config.toml"))
require.NoError(t, err)

// unmarshal data
actual := falcon.Config{}
err = toml.Unmarshal(b, &actual)
require.NoError(t, err)

expect := falcon.DefaultConfig()

require.Equal(t, expect, actual)
}

func TestInitExistingConfig(t *testing.T) {
tmpDir := t.TempDir()

// Test InitConfig
app := falcon.NewApp(nil, nil, tmpDir, false, nil)

err := app.InitConfigFile(tmpDir)
require.NoError(t, err)

err = app.InitConfigFile(tmpDir)
require.ErrorContains(t, err, "config already exists:")
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ require (
github.com/pelletier/go-toml/v2 v2.2.2
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
Expand Down