-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for most used admin transactions (#2473)
* add policy accounts * seperate policy accounts for each policy type * remove fungible admin and add changelog * generate files * add test for add inbound tracker * add sub function * add UpdateGasPriceIncreaseFlags * add changelog * rename proto files * use retry package * rebase develop * use constant backoff * generate files * resolve comments 2 * generate
- Loading branch information
Showing
16 changed files
with
1,051 additions
and
152 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
34 changes: 34 additions & 0 deletions
34
docs/cli/zetacored/zetacored_query_crosschain_show-inbound-tracker.md
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,34 @@ | ||
# query crosschain show-inbound-tracker | ||
|
||
shows an inbound tracker by chainID and txHash | ||
|
||
``` | ||
zetacored query crosschain show-inbound-tracker [chainID] [txHash] [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
--grpc-addr string the gRPC endpoint to use for this chain | ||
--grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS | ||
--height int Use a specific height to query state at (this can error if the node is pruning state) | ||
-h, --help help for show-inbound-tracker | ||
--node string [host]:[port] to Tendermint RPC interface for this chain | ||
-o, --output string Output format (text|json) | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--chain-id string The network chain ID | ||
--home string directory for config and data | ||
--log_format string The logging format (json|plain) | ||
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic) | ||
--log_no_color Disable colored logs | ||
--trace print out full stack trace on errors | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [zetacored query crosschain](zetacored_query_crosschain.md) - Querying commands for the crosschain module | ||
|
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,105 @@ | ||
package e2etests | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/zeta-chain/zetacore/e2e/runner" | ||
"github.com/zeta-chain/zetacore/e2e/utils" | ||
"github.com/zeta-chain/zetacore/pkg/chains" | ||
"github.com/zeta-chain/zetacore/pkg/coin" | ||
"github.com/zeta-chain/zetacore/testutil/sample" | ||
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" | ||
observertypes "github.com/zeta-chain/zetacore/x/observer/types" | ||
) | ||
|
||
// TestCriticalAdminTransactions tests critical admin transactions that are the most used on mainnet . | ||
// The complete list is | ||
// MsgUpdateChainParams | ||
// MsgRefundAbortedCCTX | ||
// MsgEnableCCTX | ||
// MsgDisableCCTX | ||
// MsgUpdateGasPriceIncreaseFlags | ||
// MsgAddInboundTracker | ||
// MsgUpdateZRC20LiquidityCap | ||
// MsgDeploySystemContracts | ||
// MsgWhitelistERC20 | ||
// MsgPauseZRC20 | ||
// MsgMigrateTssFunds | ||
// MsgUpdateTssAddress | ||
// | ||
// However, the transactions other than `AddToInboundTracker` and `UpdateGasPriceIncreaseFlags` have already been used in other tests. | ||
func TestCriticalAdminTransactions(r *runner.E2ERunner, _ []string) { | ||
TestAddToInboundTracker(r) | ||
TestUpdateGasPriceIncreaseFlags(r) | ||
} | ||
|
||
func TestUpdateGasPriceIncreaseFlags(r *runner.E2ERunner) { | ||
// Set default flags on zetacore | ||
defaultFlags := observertypes.DefaultGasPriceIncreaseFlags | ||
msgGasPriceFlags := observertypes.NewMsgUpdateGasPriceIncreaseFlags( | ||
r.ZetaTxServer.MustGetAccountAddressFromName(utils.OperationalPolicyName), | ||
defaultFlags, | ||
) | ||
_, err := r.ZetaTxServer.BroadcastTx(utils.OperationalPolicyName, msgGasPriceFlags) | ||
require.NoError(r, err) | ||
|
||
// create a new set of flag values by incrementing the epoch length by 1 | ||
defaultFlagsUpdated := defaultFlags | ||
defaultFlagsUpdated.EpochLength = defaultFlags.EpochLength + 1 | ||
|
||
// Update the flags on zetacore with the new values | ||
msgGasPriceFlags = observertypes.NewMsgUpdateGasPriceIncreaseFlags( | ||
r.ZetaTxServer.MustGetAccountAddressFromName(utils.OperationalPolicyName), | ||
defaultFlagsUpdated, | ||
) | ||
_, err = r.ZetaTxServer.BroadcastTx(utils.OperationalPolicyName, msgGasPriceFlags) | ||
require.NoError(r, err) | ||
|
||
r.WaitForBlocks(1) | ||
|
||
// Verify that the flags have been updated | ||
flags, err := r.ObserverClient.CrosschainFlags(r.Ctx, &observertypes.QueryGetCrosschainFlagsRequest{}) | ||
require.NoError(r, err) | ||
require.Equal(r, defaultFlagsUpdated.EpochLength, flags.CrosschainFlags.GasPriceIncreaseFlags.EpochLength) | ||
} | ||
|
||
func TestAddToInboundTracker(r *runner.E2ERunner) { | ||
chainEth := chains.GoerliLocalnet | ||
chainBtc := chains.BitcoinRegtest | ||
msgEth := crosschaintypes.NewMsgAddInboundTracker( | ||
r.ZetaTxServer.MustGetAccountAddressFromName(utils.EmergencyPolicyName), | ||
chainEth.ChainId, | ||
coin.CoinType_Gas, | ||
sample.Hash().Hex(), | ||
) | ||
_, err := r.ZetaTxServer.BroadcastTx(utils.EmergencyPolicyName, msgEth) | ||
require.NoError(r, err) | ||
|
||
msgBtc := crosschaintypes.NewMsgAddInboundTracker( | ||
r.ZetaTxServer.MustGetAccountAddressFromName(utils.EmergencyPolicyName), | ||
chainBtc.ChainId, | ||
coin.CoinType_Gas, | ||
sample.BtcHash().String(), | ||
) | ||
|
||
_, err = r.ZetaTxServer.BroadcastTx(utils.EmergencyPolicyName, msgBtc) | ||
require.NoError(r, err) | ||
|
||
r.WaitForBlocks(1) | ||
|
||
tracker, err := r.CctxClient.InboundTracker(r.Ctx, &crosschaintypes.QueryInboundTrackerRequest{ | ||
ChainId: msgEth.ChainId, | ||
TxHash: msgEth.TxHash, | ||
}) | ||
require.NoError(r, err) | ||
require.NotNil(r, tracker) | ||
require.Equal(r, msgEth.TxHash, tracker.InboundTracker.TxHash) | ||
|
||
tracker, err = r.CctxClient.InboundTracker(r.Ctx, &crosschaintypes.QueryInboundTrackerRequest{ | ||
ChainId: msgBtc.ChainId, | ||
TxHash: msgBtc.TxHash, | ||
}) | ||
require.NoError(r, err) | ||
require.NotNil(r, tracker) | ||
require.Equal(r, msgBtc.TxHash, tracker.InboundTracker.TxHash) | ||
} |
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
Oops, something went wrong.