Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement E2E infrastructure for skyline system #13

Draft
wants to merge 5 commits into
base: feat/skyline
Choose a base branch
from

Conversation

Dejan-Nedic
Copy link

Description

Please provide a detailed description of what was done in this PR

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

Manual tests

Please complete this section if you ran manual tests for this functionality, otherwise delete it

Documentation update

Please link the documentation update PR in this section if it's present, otherwise delete it

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

@Dejan-Nedic
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@@ -330,6 +415,51 @@ func (a *ApexSystem) GenerateConfigs() error {
})
}

func (a *ApexSystem) GenerateSkylineConfigs() error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for two public functions. There should be two private functions and one existing public function that calls those two in an if-else statement, depending on some config (IsReactor or IsSkyline if that is not already in the config).

@@ -355,14 +382,27 @@ func (ec *TestCardanoChain) BridgingRequest(
})
}

exchangeRates := []sendtx.ExchangeRateEntry{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is hardcoded (this is not place to set config parameters). Call extern function via some interface or put these in config

@@ -137,4 +137,8 @@ func (t *TestApexChainDummy) CreateMetadata(
return nil, nil
}

func (t *TestApexChainDummy) SetNativeTokenName(string) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this from all the files

@@ -0,0 +1,77 @@
package cardanofw

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need two have two separate files for skyline and reactor. Just depending on config (IsReactor) execute one of constructor methods. Everything else is the same

@@ -15,7 +15,7 @@ type ITestApexChain interface {
CreateWallets(validator *TestApexValidator) error
CreateAddresses(bladeAdmin *crypto.ECDSAKey, bridgeURL string) error
FundWallets(ctx context.Context) error
RegisterChain(validator *TestApexValidator) error
RegisterChain(validator *TestApexValidator, system string) error

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

system string should be some config parameter IsSkyline or IsReactor. interface method should not be changed

@@ -211,14 +212,56 @@ func (a *ApexSystem) InitContracts(ctx context.Context) error {
return nil
}

func (a *ApexSystem) GetTokenName(chainId string, networkType cardanowallet.CardanoNetworkType) string {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider passing t *testing.T as parameter (t.Helper() is mandatory) and do require.NoError instead of _

@@ -259,6 +315,35 @@ func (a *ApexSystem) FundWallets(ctx context.Context) error {
})
}

func (a *ApexSystem) FundWalletsSkyline(ctx context.Context) error {
Copy link

@igorcrevar igorcrevar Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should not exists
if there are tokens in configuration than tokens should be funded too

Just put token fund part of the code in cardano-chain (with if condition of-course)

func (ec *TestCardanoChain) RegisterChain(validator *TestApexValidator) error {
return validator.RegisterChain(ec.ChainID(), ec.config.InitialHotWalletAmount, ChainTypeCardano)
func (ec *TestCardanoChain) RegisterChain(validator *TestApexValidator, system string) error {
if system == "skyline" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just call

		return validator.RegisterChain(ec.ChainID(), ec.config.InitialHotWalletAmount, ec.config.InitialHotWalletTokenAmount, ChainTypeCardano)```

there is no need for two cases

@@ -450,3 +490,11 @@ func (ec *TestCardanoChain) submitTx(
return txHash, nil
}, infracommon.WithRetryCount(retryCount), infracommon.WithRetryWaitTime(retryWaitTime))
}

func GetExchangeRate(sourceChainID string, destinationChainID string) (float64, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this... we will later add dynamic exchange rate through some interface implementation

networkType cardanowallet.CardanoNetworkType, txProvider cardanowallet.ITxProvider,
minterUser *TestApexUser, addrToFund string, lovelaceFundAmount uint64, tokenFundAmount uint64,
) (*cardanowallet.TokenAmount, error) {
minterWallet, _ := minterUser.GetCardanoWallet(chain)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate code from GetTokenName
change that to receive wallet and than use here also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants