-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/gas-stability-pool-chains
- Loading branch information
Showing
90 changed files
with
2,641 additions
and
1,607 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
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,89 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
ethcommon "github.com/ethereum/go-ethereum/common" | ||
"github.com/fatih/color" | ||
"github.com/spf13/cobra" | ||
"github.com/zeta-chain/zetacore/app" | ||
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/utils" | ||
) | ||
|
||
const flagSkipBTC = "skip-btc" | ||
|
||
// NewBalancesCmd returns the balances command | ||
// which shows from the key and rpc, the balance of the account on different network | ||
func NewBalancesCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "balances [config-file]", | ||
Short: "Show account balances on networks for E2E tests", | ||
RunE: runBalances, | ||
Args: cobra.ExactArgs(1), | ||
} | ||
cmd.Flags().Bool( | ||
flagSkipBTC, | ||
false, | ||
"skip the BTC network", | ||
) | ||
return cmd | ||
} | ||
|
||
func runBalances(cmd *cobra.Command, args []string) error { | ||
// read the config file | ||
conf, err := config.ReadConfig(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
skipBTC, err := cmd.Flags().GetBool(flagSkipBTC) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// initialize logger | ||
logger := runner.NewLogger(false, color.FgHiCyan, "") | ||
|
||
// set config | ||
app.SetConfig() | ||
|
||
// initialize context | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
|
||
// get EVM address from config | ||
evmAddr := conf.Accounts.EVMAddress | ||
if !ethcommon.IsHexAddress(evmAddr) { | ||
cancel() | ||
return errors.New("invalid EVM address") | ||
} | ||
|
||
// initialize deployer runner with config | ||
r, err := zetae2econfig.RunnerFromConfig( | ||
ctx, | ||
"e2e", | ||
cancel, | ||
conf, | ||
ethcommon.HexToAddress(evmAddr), | ||
conf.Accounts.EVMPrivKey, | ||
utils.FungibleAdminName, // placeholder value, not used | ||
FungibleAdminMnemonic, // placeholder value, not used | ||
logger, | ||
) | ||
if err != nil { | ||
cancel() | ||
return err | ||
} | ||
|
||
balances, err := r.GetAccountBalances(skipBTC) | ||
if err != nil { | ||
cancel() | ||
return err | ||
} | ||
r.PrintAccountBalances(balances) | ||
|
||
return nil | ||
} |
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,92 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
ethcommon "github.com/ethereum/go-ethereum/common" | ||
"github.com/fatih/color" | ||
"github.com/spf13/cobra" | ||
"github.com/zeta-chain/zetacore/app" | ||
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/utils" | ||
) | ||
|
||
const flagPrivKey = "privkey" | ||
|
||
// NewBitcoinAddressCmd returns the bitcoin address command | ||
// which shows from the used config file, the bitcoin address that can be used to receive funds for the E2E tests | ||
func NewBitcoinAddressCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "bitcoin-address [config-file] ", | ||
Short: "Show Bitcoin address to receive funds for E2E tests", | ||
RunE: runBitcoinAddress, | ||
Args: cobra.ExactArgs(1), | ||
} | ||
cmd.Flags().Bool( | ||
flagPrivKey, | ||
false, | ||
"show the priv key in WIF format", | ||
) | ||
return cmd | ||
} | ||
|
||
func runBitcoinAddress(cmd *cobra.Command, args []string) error { | ||
showPrivKey, err := cmd.Flags().GetBool(flagPrivKey) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// read the config file | ||
conf, err := config.ReadConfig(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// initialize logger | ||
logger := runner.NewLogger(false, color.FgHiYellow, "") | ||
|
||
// set config | ||
app.SetConfig() | ||
|
||
// initialize context | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
|
||
// get EVM address from config | ||
evmAddr := conf.Accounts.EVMAddress | ||
if !ethcommon.IsHexAddress(evmAddr) { | ||
cancel() | ||
return errors.New("invalid EVM address") | ||
} | ||
|
||
// initialize deployer runner with config | ||
r, err := zetae2econfig.RunnerFromConfig( | ||
ctx, | ||
"e2e", | ||
cancel, | ||
conf, | ||
ethcommon.HexToAddress(evmAddr), | ||
conf.Accounts.EVMPrivKey, | ||
utils.FungibleAdminName, // placeholder value, not used | ||
FungibleAdminMnemonic, // placeholder value, not used | ||
logger, | ||
) | ||
if err != nil { | ||
cancel() | ||
return err | ||
} | ||
|
||
addr, privKey, err := r.GetBtcAddress() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
logger.Print("* BTC address: %s", addr) | ||
if showPrivKey { | ||
logger.Print("* BTC privkey: %s", privKey) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.