Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Sep 23, 2024
1 parent 713c7eb commit 4cfbb95
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 38 deletions.
2 changes: 1 addition & 1 deletion tests/integration/connect_ccv_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewConnectCCVIntegrationSuite(
func (s *ConnectCCVSuite) TestCCVAggregation() {
ethusdc := connecttypes.NewCurrencyPair("ETH", "USDC")

s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 3600, ethusdc))
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 3600, enabledTicker(ethusdc)))

cc, closeFn, err := GetChainGRPC(s.chain)
s.Require().NoError(err)
Expand Down
19 changes: 7 additions & 12 deletions tests/integration/connect_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,21 +359,16 @@ func PassProposal(chain *cosmos.CosmosChain, propId string, timeout time.Duratio

// AddCurrencyPairs creates + submits the proposal to add the given currency-pairs to state, votes for the prop w/ all nodes,
// and waits for the proposal to pass.
func (s *ConnectIntegrationSuite) AddCurrencyPairs(chain *cosmos.CosmosChain, user cosmos.User, price float64, cps ...connecttypes.CurrencyPair) error {
creates := make([]mmtypes.Market, len(cps))
for i, cp := range cps {
func (s *ConnectIntegrationSuite) AddCurrencyPairs(chain *cosmos.CosmosChain, user cosmos.User, price float64,
tickers ...mmtypes.Ticker) error {
creates := make([]mmtypes.Market, len(tickers))
for i, ticker := range tickers {
creates[i] = mmtypes.Market{
Ticker: mmtypes.Ticker{
CurrencyPair: cp,
Decimals: 8,
MinProviderCount: 1,
Metadata_JSON: "",
Enabled: true,
},
Ticker: ticker,
ProviderConfigs: []mmtypes.ProviderConfig{
{
Name: static.Name,
OffChainTicker: cp.String(),
OffChainTicker: ticker.String(),
Metadata_JSON: fmt.Sprintf(`{"price": %f}`, price),
},
},
Expand Down Expand Up @@ -451,7 +446,7 @@ func QueryProposal(chain *cosmos.CosmosChain, propID string) (*govtypesv1.QueryP
})
}

// WaitForProposalStatus, waits for the deposit period for the proposal to end
// WaitForProposalStatus waits for the deposit period for the proposal to end
func WaitForProposalStatus(chain *cosmos.CosmosChain, propID string, timeout time.Duration, status govtypesv1.ProposalStatus) error {
return testutil.WaitForCondition(timeout, 1*time.Second, func() (bool, error) {
prop, err := QueryProposal(chain, propID)
Expand Down
79 changes: 61 additions & 18 deletions tests/integration/connect_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const (
defaultDenom = "stake"
validatorKey = "validator"
yes = "yes"
deposit = 1000000
userMnemonic = "foster poverty abstract scorpion short shrimp tilt edge romance adapt only benefit moral another where host egg echo ability wisdom lizard lazy pool roast"
userAccountAddressHex = "877E307618AB73E009A978AC32E0264791F6D40A"
gasPrice = 100
Expand Down Expand Up @@ -347,10 +346,16 @@ func (s *ConnectOracleIntegrationSuite) TestOracleModule() {

// pass a governance proposal to approve a new currency-pair, and check Prices are reported
s.Run("Add a currency-pair and check Prices", func() {
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, []connecttypes.CurrencyPair{
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, []mmtypes.Ticker{
{
Base: "BTC",
Quote: "USD",
CurrencyPair: connecttypes.CurrencyPair{
Base: "BTC",
Quote: "USD",
},
Decimals: 8,
MinProviderCount: 1,
Enabled: true,
Metadata_JSON: "",
},
}...))

Expand All @@ -365,14 +370,24 @@ func (s *ConnectOracleIntegrationSuite) TestOracleModule() {
s.Run("Add multiple Currency Pairs", func() {
cp1 := connecttypes.NewCurrencyPair("ETH", "USD")
cp2 := connecttypes.NewCurrencyPair("USDT", "USD")
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, []connecttypes.CurrencyPair{
cp1, cp2,
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, []mmtypes.Ticker{
enabledTicker(cp1),
enabledTicker(cp2),
}...))

resp, err := QueryCurrencyPairs(s.chain)
s.Require().NoError(err)
s.Require().True(len(resp.CurrencyPairs) == 3)
})

s.Run("remove a currency pair", func() {
disabledCP := connecttypes.NewCurrencyPair("DIS", "ABLE")
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, []mmtypes.Ticker{
disabledTicker(disabledCP),
}...))

})

}

func translateGRPCAddr(chain *cosmos.CosmosChain) string {
Expand All @@ -381,9 +396,16 @@ func translateGRPCAddr(chain *cosmos.CosmosChain) string {

func (s *ConnectOracleIntegrationSuite) TestNodeFailures() {
ethusdcCP := connecttypes.NewCurrencyPair("ETH", "USDC")
tickerETHUSDC := mmtypes.Ticker{
CurrencyPair: ethusdcCP,
Decimals: 8,
MinProviderCount: 1,
Enabled: true,
Metadata_JSON: "",
}

s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, []connecttypes.CurrencyPair{
ethusdcCP,
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, []mmtypes.Ticker{
tickerETHUSDC,
}...))

cc, closeFn, err := GetChainGRPC(s.chain)
Expand Down Expand Up @@ -577,19 +599,39 @@ func (s *ConnectOracleIntegrationSuite) TestNodeFailures() {
})
}

func enabledTicker(pair connecttypes.CurrencyPair) mmtypes.Ticker {
return mmtypes.Ticker{
CurrencyPair: pair,
Decimals: 8,
MinProviderCount: 1,
Enabled: true,
Metadata_JSON: "",
}
}

func disabledTicker(pair connecttypes.CurrencyPair) mmtypes.Ticker {
return mmtypes.Ticker{
CurrencyPair: pair,
Decimals: 8,
MinProviderCount: 1,
Enabled: false,
Metadata_JSON: "",
}
}

func (s *ConnectOracleIntegrationSuite) TestMultiplePriceFeeds() {
ethusdcCP := connecttypes.NewCurrencyPair("ETH", "USDC")
ethusdtCP := connecttypes.NewCurrencyPair("ETH", "USDT")
ethusdCP := connecttypes.NewCurrencyPair("ETH", "USD")

// add multiple currency pairs
cps := []connecttypes.CurrencyPair{
ethusdcCP,
ethusdtCP,
ethusdCP,
// add multiple tickers
tickers := []mmtypes.Ticker{
enabledTicker(ethusdcCP),
enabledTicker(ethusdtCP),
enabledTicker(ethusdCP),
}

s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, cps...))
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, tickers...))

cc, closeFn, err := GetChainGRPC(s.chain)
s.Require().NoError(err)
Expand Down Expand Up @@ -671,8 +713,8 @@ func (s *ConnectOracleIntegrationSuite) TestMultiplePriceFeeds() {
s.Require().NoError(err)

// query for the given currency pair
for _, cp := range cps {
resp, _, err := QueryCurrencyPair(s.chain, cp, height)
for _, ticker := range tickers {
resp, _, err := QueryCurrencyPair(s.chain, ticker.CurrencyPair, height)
s.Require().NoError(err)
s.Require().Equal(int64(110000000), resp.Price.Int64())
}
Expand Down Expand Up @@ -739,12 +781,13 @@ func (s *ConnectOracleIntegrationSuite) TestMultiplePriceFeeds() {
s.Require().NoError(err)

// query for the given currency pair
for _, cp := range cps {
resp, _, err := QueryCurrencyPair(s.chain, cp, height)
for _, ticker := range tickers {
resp, _, err := QueryCurrencyPair(s.chain, ticker.CurrencyPair, height)
s.Require().NoError(err)
s.Require().Equal(int64(110000000), resp.Price.Int64())
}
})

}

func getIDForCurrencyPair(ctx context.Context, client oracletypes.QueryClient, cp connecttypes.CurrencyPair) (uint64, error) {
Expand Down
11 changes: 6 additions & 5 deletions tests/integration/connect_validator_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"context"
mmtypes "github.com/skip-mev/connect/v2/x/marketmap/types"
"time"

stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down Expand Up @@ -30,13 +31,13 @@ func (s *ConnectOracleValidatorIntegrationSuite) TestUnbonding() {
ethusdCP := connecttypes.NewCurrencyPair("ETH", "USD")

// add multiple currency pairs
cps := []connecttypes.CurrencyPair{
ethusdcCP,
ethusdtCP,
ethusdCP,
tickers := []mmtypes.Ticker{
enabledTicker(ethusdcCP),
enabledTicker(ethusdtCP),
enabledTicker(ethusdCP),
}

s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, cps...))
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 1.1, tickers...))

cc, closeFn, err := GetChainGRPC(s.chain)
s.Require().NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

var (
providerChainID = "provider-1"
providerNumValidators = int(4)
providerNumValidators = 4
providerVersion = "v5.0.0-rc0"
)

Expand Down
1 change: 0 additions & 1 deletion x/marketmap/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgParams{}, "connect/x/marketmap/MsgParams")
legacy.RegisterAminoMsg(cdc, &MsgUpsertMarkets{}, "connect/x/marketmap/MsgUpsertMarkets")
legacy.RegisterAminoMsg(cdc, &MsgRemoveMarkets{}, "connect/x/marketmap/MsgRemoveMarkets")
legacy.RegisterAminoMsg(cdc, &MsgRemoveMarketAuthorities{}, "connect/x/marketmap/MsgRemoveMarketAuthorities")
}

// RegisterInterfaces registers the x/marketmap messages + message service w/ the InterfaceRegistry (registry).
Expand Down

0 comments on commit 4cfbb95

Please sign in to comment.