-
Notifications
You must be signed in to change notification settings - Fork 25
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
5866285
commit 1f74c79
Showing
13 changed files
with
266 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[[chains]] |
File renamed without changes.
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,13 @@ | ||
interval = "@hourly" | ||
|
||
[[chains]] | ||
name = "bitsong" | ||
pretty-name = "Bitsong" | ||
keplr-name = "bitsong" | ||
mintscan-prefix = "bitsong" | ||
lcd-endpoints = ["https://lcd-bitsong-app.cosmostation.io"] | ||
wallets = [ | ||
{ address = "bitsong14rvn7anf22e00vj5x3al4w50ns78s7n4t8yxcy", alias = "Validator wallet" }, | ||
] | ||
type = "cosmos" | ||
proposals-type = "v1beta1" |
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
File renamed without changes.
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,88 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigNoConfigProvided(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd", "validate-config"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigFailedToLoad(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd", "validate-config", "--config", "../assets/config-not-found.toml"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigInvalid(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd", "validate-config", "--config", "../assets/config-invalid.toml"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigWithWarnings(t *testing.T) { | ||
os.Args = []string{"cmd", "validate-config", "--config", "../assets/config-with-warnings.toml"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigValid(t *testing.T) { | ||
os.Args = []string{"cmd", "validate-config", "--config", "../assets/config-valid.toml"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestStartNoConfigProvided(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestStartConfigProvided(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd", "--config", "../assets/config-invalid.toml"} | ||
main() | ||
assert.True(t, true) | ||
} |
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,96 @@ | ||
package fetchers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestTestFetcherGetProposals(t *testing.T) { | ||
t.Parallel() | ||
|
||
fetcher1 := TestFetcher{WithProposalsError: true} | ||
proposals1, height1, err1 := fetcher1.GetAllProposals(0, context.Background()) | ||
assert.Empty(t, proposals1) | ||
assert.Equal(t, int64(123), height1) | ||
require.Error(t, err1) | ||
|
||
fetcher2 := TestFetcher{WithPassedProposals: true} | ||
proposals2, height2, err2 := fetcher2.GetAllProposals(0, context.Background()) | ||
assert.NotEmpty(t, proposals2) | ||
assert.Equal(t, int64(123), height2) | ||
require.Nil(t, err2) | ||
|
||
fetcher3 := TestFetcher{} | ||
proposals3, height3, err3 := fetcher3.GetAllProposals(0, context.Background()) | ||
assert.NotEmpty(t, proposals3) | ||
assert.Equal(t, int64(123), height3) | ||
require.Nil(t, err3) | ||
} | ||
|
||
func TestTestFetcherGetVote(t *testing.T) { | ||
t.Parallel() | ||
|
||
fetcher1 := TestFetcher{WithVoteError: true} | ||
vote1, height1, err1 := fetcher1.GetVote("proposal", "vote", 0, context.Background()) | ||
assert.Nil(t, vote1) | ||
assert.Equal(t, int64(456), height1) | ||
require.Error(t, err1) | ||
|
||
fetcher2 := TestFetcher{WithVote: true} | ||
vote2, height2, err2 := fetcher2.GetVote("proposal", "vote", 0, context.Background()) | ||
assert.NotNil(t, vote2) | ||
assert.Equal(t, int64(456), height2) | ||
require.Nil(t, err2) | ||
|
||
fetcher3 := TestFetcher{} | ||
vote3, height3, err3 := fetcher3.GetVote("proposal", "vote", 0, context.Background()) | ||
assert.Nil(t, vote3) | ||
assert.Equal(t, int64(456), height3) | ||
require.Nil(t, err3) | ||
} | ||
|
||
func TestTestFetcherTally(t *testing.T) { | ||
t.Parallel() | ||
|
||
fetcher1 := TestFetcher{WithTallyError: true} | ||
tally1, err1 := fetcher1.GetTallies(context.Background()) | ||
assert.NotNil(t, tally1) | ||
assert.Empty(t, tally1.TallyInfos) | ||
assert.Nil(t, tally1.Chain) | ||
require.Error(t, err1) | ||
|
||
fetcher2 := TestFetcher{WithTallyNotEmpty: true} | ||
tally2, err2 := fetcher2.GetTallies(context.Background()) | ||
assert.NotNil(t, tally2) | ||
assert.NotEmpty(t, tally2.TallyInfos) | ||
assert.NotNil(t, tally2.Chain) | ||
require.Nil(t, err2) //nolint:testifylint // not working | ||
|
||
fetcher3 := TestFetcher{} | ||
tally3, err3 := fetcher3.GetTallies(context.Background()) | ||
assert.NotNil(t, tally3) | ||
assert.Empty(t, tally3.TallyInfos) | ||
assert.Nil(t, tally3.Chain) | ||
require.Nil(t, err3) //nolint:testifylint // not working | ||
} | ||
|
||
func TestTestFetcherParams(t *testing.T) { | ||
t.Parallel() | ||
|
||
fetcher1 := TestFetcher{WithParamsError: true} | ||
params1, errs1 := fetcher1.GetChainParams(context.Background()) | ||
assert.NotNil(t, params1) | ||
assert.Empty(t, params1.Params) | ||
assert.Nil(t, params1.Chain) | ||
require.NotEmpty(t, errs1) | ||
|
||
fetcher2 := TestFetcher{} | ||
params2, errs2 := fetcher2.GetChainParams(context.Background()) | ||
assert.NotNil(t, params2) | ||
assert.NotEmpty(t, params2.Params) | ||
assert.NotNil(t, params2.Chain) | ||
require.Empty(t, errs2) | ||
} |
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,20 @@ | ||
package fs | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
type OsFS struct { | ||
} | ||
|
||
func (fs *OsFS) ReadFile(name string) ([]byte, error) { | ||
return os.ReadFile(name) | ||
} | ||
|
||
func (fs *OsFS) WriteFile(name string, data []byte, perms os.FileMode) error { | ||
return os.WriteFile(name, data, perms) | ||
} | ||
|
||
func (fs *OsFS) Create(path string) (File, error) { | ||
return os.Create(path) | ||
} |
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,33 @@ | ||
package fs | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestOsFsRead(t *testing.T) { | ||
t.Parallel() | ||
|
||
fs := &OsFS{} | ||
file, err := fs.ReadFile("not-found.test") | ||
assert.Empty(t, file) | ||
require.Error(t, err) | ||
} | ||
|
||
func TestOsFsWrite(t *testing.T) { | ||
t.Parallel() | ||
|
||
fs := &OsFS{} | ||
err := fs.WriteFile("/etc/fstab", []byte{}, 0) | ||
require.Error(t, err) | ||
} | ||
|
||
func TestOsFsCreate(t *testing.T) { | ||
t.Parallel() | ||
|
||
fs := &OsFS{} | ||
_, err := fs.Create("/etc/fstab") | ||
require.Error(t, err) | ||
} |
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