-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): support running against live networks (#1630)
* add NodeRunner impl for connecting to live network * refactor out node runner setups * remove hardcoded denom for DeployedErc20 * further specify restrictions on DeployedErc20 * don't override .env funded account mnemonic * lower amounts for convert to coin e2e tests * lower fund values used by e2e tests * add doc comments for all e2e functions & types
- Loading branch information
1 parent
336bac7
commit 7cff7be
Showing
17 changed files
with
298 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# E2E_KAVA_FUNDED_ACCOUNT_MNEMONIC is for a funded account used to intialize all new testing accounts. | ||
# Should be funded with KAVA and have an ERC20 balance | ||
E2E_KAVA_FUNDED_ACCOUNT_MNEMONIC='tent fitness boat among census primary pipe nose dream glance cave turtle electric fabric jacket shaft easy myself genuine this sibling pulse word unfold' | ||
|
||
# E2E_RUN_KVTOOL_NETWORKS must be false to trigger run on live network | ||
E2E_RUN_KVTOOL_NETWORKS=false | ||
|
||
# Configure the endpoints for connecting to the running network here. | ||
E2E_KAVA_RPC_URL='http://localhost:26657' | ||
E2E_KAVA_GRPC_URL='http://localhost:9090' | ||
E2E_KAVA_EMV_RPC_URL='http://localhost:8545' | ||
|
||
# E2E_INCLUDE_IBC_TESTS is not currently supported for running tests against a live network. | ||
E2E_INCLUDE_IBC_TESTS=false | ||
|
||
# E2E_KAVA_ERC20_ADDRESS is the address of a pre-deployed ERC20 token. | ||
# The E2E_KAVA_FUNDED_ACCOUNT_MNEMONIC account must have a balance. | ||
# The ERC20 must be enabled via x/evmutil params for conversion to sdk.Coin. | ||
# The corresponding sdk.Coin must be a supported vault in x/earn. | ||
E2E_KAVA_ERC20_ADDRESS=0xeA7100edA2f805356291B0E55DaD448599a72C6d |
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
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,80 @@ | ||
package runner | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
) | ||
|
||
// LiveNodeRunnerConfig implements NodeRunner. | ||
// It connects to a running network via the RPC, GRPC, and EVM urls. | ||
type LiveNodeRunnerConfig struct { | ||
KavaRpcUrl string | ||
KavaGrpcUrl string | ||
KavaEvmRpcUrl string | ||
} | ||
|
||
// LiveNodeRunner implements NodeRunner for an already-running chain. | ||
// If a LiveNodeRunner is used, end-to-end tests are run against a live chain. | ||
type LiveNodeRunner struct { | ||
config LiveNodeRunnerConfig | ||
} | ||
|
||
var _ NodeRunner = LiveNodeRunner{} | ||
|
||
// NewLiveNodeRunner creates a new LiveNodeRunner. | ||
func NewLiveNodeRunner(config LiveNodeRunnerConfig) *LiveNodeRunner { | ||
return &LiveNodeRunner{config} | ||
} | ||
|
||
// StartChains implements NodeRunner. | ||
// It initializes connections to the chain based on parameters. | ||
// It attempts to ping the necessary endpoints and panics if they cannot be reached. | ||
func (r LiveNodeRunner) StartChains() Chains { | ||
fmt.Println("establishing connection to live kava network") | ||
chains := NewChains() | ||
|
||
kavaChain := ChainDetails{ | ||
RpcUrl: r.config.KavaRpcUrl, | ||
GrpcUrl: r.config.KavaGrpcUrl, | ||
EvmRpcUrl: r.config.KavaEvmRpcUrl, | ||
} | ||
|
||
if err := waitForChainStart(kavaChain); err != nil { | ||
panic(fmt.Sprintf("failed to ping chain: %s", err)) | ||
} | ||
|
||
// determine chain id | ||
grpc, err := kavaChain.GrpcConn() | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to establish grpc conn to %s: %s", r.config.KavaGrpcUrl, err)) | ||
} | ||
tm := tmservice.NewServiceClient(grpc) | ||
nodeInfo, err := tm.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{}) | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to fetch kava node info: %s", err)) | ||
} | ||
kavaChain.ChainId = nodeInfo.DefaultNodeInfo.Network | ||
|
||
// determine staking denom | ||
staking := stakingtypes.NewQueryClient(grpc) | ||
stakingParams, err := staking.Params(context.Background(), &stakingtypes.QueryParamsRequest{}) | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to fetch kava staking params: %s", err)) | ||
} | ||
kavaChain.StakingDenom = stakingParams.Params.BondDenom | ||
|
||
chains.Register("kava", &kavaChain) | ||
|
||
fmt.Printf("successfully connected to live network %+v\n", kavaChain) | ||
|
||
return chains | ||
} | ||
|
||
// Shutdown implements NodeRunner. | ||
// As the chains are externally operated, this is a no-op. | ||
func (LiveNodeRunner) Shutdown() { | ||
fmt.Println("shutting down e2e test connections.") | ||
} |
Oops, something went wrong.