Skip to content

Commit

Permalink
s/deployer/default_account/
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jun 26, 2024
1 parent 0108894 commit ead440e
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 47 deletions.
14 changes: 6 additions & 8 deletions cmd/zetae2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ This is an example of config for interaction with Athens3:

```go
zeta_chain_id: "athens_7001-1"
accounts:
deployer
evm_address: "<your evm address>"
private_key: "<your evm private key>"
default_account:
evm_address: "<your evm address>"
private_key: "<your evm private key>"
rpcs:
zevm: "<zevm (ZetaChain) url>, generally using port 8545"
evm: "<evm url>, generally using port 8545"
Expand Down Expand Up @@ -102,10 +101,9 @@ Testing a gas token requires the following values to be defined in the config:

```go
zeta_chain_id
accounts:
deployer:
evm_address
private_key
default_account:
evm_address
private_key
rpcs:
zevm
evm
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func runBalances(cmd *cobra.Command, args []string) error {
"e2e",
cancel,
conf,
conf.Accounts.Deployer,
conf.DefaultAccount,
logger,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/bitcoin_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func runBitcoinAddress(cmd *cobra.Command, args []string) error {
"e2e",
cancel,
conf,
conf.Accounts.Deployer,
conf.DefaultAccount,
logger,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestReadConfig(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
conf, err := config.ReadConfig(tt.filePath)
require.NoError(t, err)
require.NotEmpty(t, conf.Accounts.Deployer.RawEVMAddress)
require.NotEmpty(t, conf.Accounts.Deployer.RawPrivateKey)
require.NotEmpty(t, conf.DefaultAccount.RawEVMAddress)
require.NotEmpty(t, conf.DefaultAccount.RawPrivateKey)
})
}
}
4 changes: 2 additions & 2 deletions cmd/zetae2e/config/example.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
zeta_chain_id: "athens_7001-1"
accounts:
default_account:
evm_address: "<your evm address>"
evm_priv_key: "<your evm private key>"
private_key: "<your evm private key>"
rpcs:
zevm: "<zevm (ZetaChain) url>, generally using port 8545"
evm: "<evm url>, generally using port 8545"
Expand Down
9 changes: 4 additions & 5 deletions cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
zeta_chain_id: "athens_7001-1"
accounts:
deployer:
bech32_address: zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd
evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC"
private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263"
default_account:
bech32_address: zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd
evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC"
private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263"
rpcs:
zevm: "http://0.0.0.0:9545"
evm: "http://0.0.0.0:8545"
Expand Down
9 changes: 4 additions & 5 deletions cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
zeta_chain_id: "athens_101-1"
accounts:
deployer:
bech32_address: "zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd"
evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC"
private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263"
default_account:
bech32_address: "zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd"
evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC"
private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263"
additional_accounts:
user_erc20:
bech32_address: "zeta1datate7xmwm4uk032f9rmcu0cwy7ch7kg6y6zv"
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
"deployer",
cancel,
conf,
conf.Accounts.Deployer,
conf.DefaultAccount,
logger,
runner.WithZetaTxServer(zetaTxServer),
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func runE2ETest(cmd *cobra.Command, args []string) error {
"e2e",
cancel,
conf,
conf.Accounts.Deployer,
conf.DefaultAccount,
logger,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/setup_bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func runSetupBitcoin(_ *cobra.Command, args []string) error {
"e2e",
cancel,
conf,
conf.Accounts.Deployer,
conf.DefaultAccount,
logger,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/show_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func runShowTSS(_ *cobra.Command, args []string) error {
"tss",
cancel,
conf,
conf.Accounts.Deployer,
conf.DefaultAccount,
logger,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func StressTest(cmd *cobra.Command, _ []string) {
// initialize E2E tests config
conf := must(local.GetConfig(cmd))

deployerAccount := conf.Accounts.Deployer
deployerAccount := conf.DefaultAccount

// Initialize clients ----------------------------------------------------------------
evmClient := must(ethclient.Dial(conf.RPCs.EVM))
Expand Down Expand Up @@ -129,7 +129,7 @@ func StressTest(cmd *cobra.Command, _ []string) {
"deployer",
cancel,
conf,
conf.Accounts.Deployer,
conf.DefaultAccount,
logger,
))

Expand Down
4 changes: 2 additions & 2 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ sleep 2

### Create the accounts and fund them with Ether on local Ethereum network

# unlock the deployer account
address=$(yq -r '.accounts.deployer.evm_address' config.yml)
# unlock the default account account
address=$(yq -r '.default_account.evm_address' config.yml)
echo "funding deployer address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545

Expand Down
4 changes: 2 additions & 2 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ then
cat $HOME/.zetacored/config/genesis.json | jq --arg address "$address" '.app_state["authority"]["policies"]["items"][2]["address"] = $address' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json

# give balance to runner accounts to deploy contracts directly on zEVM
# deployer
address=$(yq -r '.accounts.deployer.bech32_address' /root/config.yml)
# default account
address=$(yq -r '.default_account.bech32_address' /root/config.yml)
zetacored add-genesis-account "$address" 100000000000000000000000000azeta
# erc20 tester
address=$(yq -r '.additional_accounts.user_erc20.bech32_address' /root/config.yml)
Expand Down
12 changes: 4 additions & 8 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func (s DoubleQuotedString) AsEVMAddress() (ethcommon.Address, error) {

// Config contains the configuration for the e2e test
type Config struct {
Accounts Accounts `yaml:"accounts"`
// Default account to use when running tests and running setup
DefaultAccount Account `yaml:"default_account"`
AdditionalAccounts AdditionalAccounts `yaml:"additional_accounts"`
RPCs RPCs `yaml:"rpcs"`
Contracts Contracts `yaml:"contracts"`
Expand All @@ -53,11 +54,6 @@ type Account struct {
RawPrivateKey DoubleQuotedString `yaml:"private_key"`
}

// Accounts are the required accounts to run any e2e test
type Accounts struct {
Deployer Account `yaml:"deployer"`
}

// AdditionalAccounts are extra accounts required to run specific tests
type AdditionalAccounts struct {
UserERC20 Account `yaml:"user_erc20"`
Expand Down Expand Up @@ -207,7 +203,7 @@ func (c Config) Validate() error {
return errors.New("invalid bitcoin params")
}

err := c.Accounts.Deployer.Validate()
err := c.DefaultAccount.Validate()
if err != nil {
return fmt.Errorf("validating deployer account: %w", err)

Check warning on line 208 in e2e/config/config.go

View check run for this annotation

Codecov / codecov/patch

e2e/config/config.go#L206-L208

Added lines #L206 - L208 were not covered by tests
}
Expand All @@ -228,7 +224,7 @@ func (c Config) Validate() error {
// GenerateKeys generates new key pairs for all accounts
func (c *Config) GenerateKeys() error {
var err error
c.Accounts.Deployer, err = generateAccount()
c.DefaultAccount, err = generateAccount()
if err != nil {
return err

Check warning on line 229 in e2e/config/config.go

View check run for this annotation

Codecov / codecov/patch

e2e/config/config.go#L229

Added line #L229 was not covered by tests
}
Expand Down
8 changes: 3 additions & 5 deletions e2e/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ func TestConfigAdditionalAccountsSliceSynced(t *testing.T) {

func TestConfigInvalidAccount(t *testing.T) {
conf := Config{
Accounts: Accounts{
Deployer: Account{
RawEVMAddress: "asdf",
RawPrivateKey: "asdf",
},
DefaultAccount: Account{
RawEVMAddress: "asdf",
RawPrivateKey: "asdf",
},
}
err := conf.Validate()
Expand Down

0 comments on commit ead440e

Please sign in to comment.