-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add utils and types test (#61)
* chore: add utils and types test * chore: add logger tests * chore: add chain query test * chore: fixed linting * chore: add display warning * chore: add tests for chain * chore: add tests for consumer chain * chore: add tests for denom info * chore: add tests for tracing * chore: fix linting * chore: add tests for tracing * chore: moved validator to a separate file * chore: add config test * chore: add tests for get config * chore: added displayWarning for missing consensus address
- Loading branch information
1 parent
cce5388
commit 4bb8f21
Showing
28 changed files
with
1,055 additions
and
56 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,8 @@ | ||
package assets | ||
|
||
import ( | ||
"embed" | ||
) | ||
|
||
//go:embed * | ||
var EmbedFS embed.FS |
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 @@ | ||
notvalid |
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,10 @@ | ||
[[chains]] | ||
name = "sentinel" | ||
lcd-endpoint = "https://api.sentinel.quokkastake.io" | ||
coingecko-currency = "sentinel" | ||
base-denom = "udvpn" | ||
denom = "dvpn" | ||
bech-wallet-prefix = "sent" | ||
validators = [ | ||
{ address = "sentvaloper1rw9wtyhsus7jvx55v3qv5nzun054ma6kz4237k" } | ||
] |
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,139 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestChainMethods(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{ | ||
LCDEndpoint: "example", | ||
Name: "chain", | ||
Queries: map[string]bool{"enabled": true}, | ||
} | ||
|
||
assert.Equal(t, "example", chain.GetHost()) | ||
assert.Equal(t, "chain", chain.GetName()) | ||
assert.Len(t, chain.GetQueries(), 1) | ||
} | ||
|
||
func TestChainValidateNoName(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{} | ||
err := chain.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestChainValidateNoEndpoint(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{Name: "test"} | ||
err := chain.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestChainValidateNoValidators(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{Name: "test", LCDEndpoint: "test"} | ||
err := chain.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestChainValidateInvalidValidator(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{ | ||
Name: "test", | ||
LCDEndpoint: "test", | ||
Validators: []Validator{{}}, | ||
} | ||
err := chain.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestChainValidateInvalidDenom(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{ | ||
Name: "test", | ||
LCDEndpoint: "test", | ||
Validators: []Validator{{Address: "test"}}, | ||
Denoms: DenomInfos{{}}, | ||
} | ||
err := chain.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestChainValidateInvalidConsumer(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{ | ||
Name: "test", | ||
LCDEndpoint: "test", | ||
Validators: []Validator{{Address: "test"}}, | ||
Denoms: DenomInfos{{Denom: "ustake", DisplayDenom: "stake"}}, | ||
ConsumerChains: []*ConsumerChain{{}}, | ||
} | ||
err := chain.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestChainValidateValid(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{ | ||
Name: "test", | ||
LCDEndpoint: "test", | ||
Validators: []Validator{{Address: "test"}}, | ||
Denoms: DenomInfos{{Denom: "ustake", DisplayDenom: "stake"}}, | ||
} | ||
err := chain.Validate() | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestChainDisplayWarningsNoBaseDenom(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{ | ||
Name: "test", | ||
LCDEndpoint: "test", | ||
Validators: []Validator{{Address: "test"}}, | ||
Denoms: DenomInfos{{Denom: "ustake", DisplayDenom: "stake", CoingeckoCurrency: "stake"}}, | ||
} | ||
warnings := chain.DisplayWarnings() | ||
require.NotEmpty(t, warnings) | ||
} | ||
|
||
func TestChainDisplayWarningsDenomWarning(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{ | ||
Name: "test", | ||
LCDEndpoint: "test", | ||
BaseDenom: "ustake", | ||
Validators: []Validator{{Address: "test", ConsensusAddress: "test"}}, | ||
Denoms: DenomInfos{{Denom: "ustake", DisplayDenom: "stake"}}, | ||
} | ||
warnings := chain.DisplayWarnings() | ||
require.NotEmpty(t, warnings) | ||
} | ||
|
||
func TestChainDisplayWarningsEmpty(t *testing.T) { | ||
t.Parallel() | ||
|
||
chain := Chain{ | ||
Name: "test", | ||
LCDEndpoint: "test", | ||
BaseDenom: "ustake", | ||
Validators: []Validator{{Address: "test", ConsensusAddress: "test"}}, | ||
Denoms: DenomInfos{{Denom: "ustake", DisplayDenom: "stake", CoingeckoCurrency: "stake"}}, | ||
} | ||
warnings := chain.DisplayWarnings() | ||
require.Empty(t, warnings) | ||
} |
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
Oops, something went wrong.