-
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.
- Loading branch information
1 parent
7cc26ca
commit 3aff75e
Showing
4 changed files
with
143 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/guregu/null/v5" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestConfigValidateInvalidTracingConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
config := Config{ | ||
TracingConfig: TracingConfig{Enabled: null.BoolFrom(true)}, | ||
} | ||
|
||
err := config.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestConfigValidateNoChains(t *testing.T) { | ||
t.Parallel() | ||
|
||
config := Config{} | ||
|
||
err := config.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestConfigValidateInvalidChain(t *testing.T) { | ||
t.Parallel() | ||
|
||
config := Config{ | ||
Chains: []*Chain{{}}, | ||
} | ||
|
||
err := config.Validate() | ||
require.Error(t, err) | ||
} | ||
|
||
func TestConfigValidateValid(t *testing.T) { | ||
t.Parallel() | ||
|
||
config := Config{ | ||
Chains: []*Chain{{ | ||
Name: "chain", | ||
LCDEndpoint: "test", | ||
Validators: []Validator{{Address: "test"}}, | ||
}}, | ||
} | ||
|
||
err := config.Validate() | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestDisplayWarningsChainWarning(t *testing.T) { | ||
t.Parallel() | ||
|
||
config := Config{ | ||
Chains: []*Chain{{ | ||
Name: "chain", | ||
LCDEndpoint: "test", | ||
Validators: []Validator{{Address: "test"}}, | ||
}}, | ||
} | ||
|
||
warnings := config.DisplayWarnings() | ||
require.NotEmpty(t, warnings) | ||
} | ||
|
||
func TestDisplayWarningsEmpty(t *testing.T) { | ||
t.Parallel() | ||
|
||
config := Config{ | ||
Chains: []*Chain{{ | ||
Name: "chain", | ||
LCDEndpoint: "test", | ||
BaseDenom: "test", | ||
Validators: []Validator{{Address: "test"}}, | ||
}}, | ||
} | ||
|
||
warnings := config.DisplayWarnings() | ||
require.Empty(t, warnings) | ||
} | ||
|
||
func TestCoingeckoCurrencies(t *testing.T) { | ||
t.Parallel() | ||
|
||
config := Config{ | ||
Chains: []*Chain{{ | ||
Denoms: DenomInfos{ | ||
{Denom: "denom1", CoingeckoCurrency: "denom1"}, | ||
{Denom: "denom2"}, | ||
}, | ||
ConsumerChains: []*ConsumerChain{{ | ||
Denoms: DenomInfos{ | ||
{Denom: "denom3", CoingeckoCurrency: "denom3"}, | ||
{Denom: "denom4"}, | ||
}, | ||
}}, | ||
}}, | ||
} | ||
|
||
currencies := config.GetCoingeckoCurrencies() | ||
require.Len(t, currencies, 2) | ||
require.Contains(t, currencies, "denom1") | ||
require.Contains(t, currencies, "denom3") | ||
} |