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
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e-polybft/cardanofw/test-apex-bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func SetupAndRunApexBridge(

fmt.Printf("Wallets have been created.\n")

require.NoError(t, apexSystem.RegisterChains())
require.NoError(t, apexSystem.RegisterChains("reactor"))

fmt.Printf("Chains have been registered\n")

Expand Down
8 changes: 6 additions & 2 deletions e2e-polybft/cardanofw/test-apex-chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

InitContracts(bridgeAdmin *crypto.ECDSAKey, bridgeURL string) error
GetGenerateConfigsParams(indx int) []string
PopulateApexSystem(apexSystem *ApexSystem)
Expand Down Expand Up @@ -99,7 +99,7 @@ func (t *TestApexChainDummy) PopulateApexSystem(apexSystem *ApexSystem) {
func (t *TestApexChainDummy) UpdateTxSendChainConfiguration(_ map[string]sendtx.ChainConfig) {
}

func (t *TestApexChainDummy) RegisterChain(validator *TestApexValidator) error {
func (t *TestApexChainDummy) RegisterChain(validator *TestApexValidator, system string) error {
return nil
}

Expand Down Expand Up @@ -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


}

var _ ITestApexChain = (*TestApexChainDummy)(nil)
61 changes: 55 additions & 6 deletions e2e-polybft/cardanofw/test-apex-system-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
ChainIDVector ChainID = "vector"
ChainIDNexus ChainID = "nexus"

ChainIDCardano ChainID = "cardano"

RunRelayerOnValidatorID = 1
)

Expand All @@ -26,9 +28,10 @@ type ApexSystemConfig struct {

BladeValidatorCount int

PrimeConfig *TestCardanoChainConfig
VectorConfig *TestCardanoChainConfig
NexusConfig *TestEVMChainConfig
PrimeConfig *TestCardanoChainConfig
VectorConfig *TestCardanoChainConfig
CardanoConfig *TestCardanoChainConfig
NexusConfig *TestEVMChainConfig

CustomOracleHandler func(mp map[string]interface{})
CustomRelayerHandler func(mp map[string]interface{})
Expand Down Expand Up @@ -62,6 +65,12 @@ func WithVectorEnabled(enabled bool) ApexSystemOptions {
}
}

func WithCardanoEnabled(enabled bool) ApexSystemOptions {
return func(h *ApexSystemConfig) {
h.CardanoConfig.IsEnabled = enabled
}
}

func WithNexusEnabled(enabled bool) ApexSystemOptions {
return func(h *ApexSystemConfig) {
h.NexusConfig.IsEnabled = enabled
Expand Down Expand Up @@ -92,6 +101,12 @@ func WithVectorConfig(config *TestCardanoChainConfig) ApexSystemOptions {
}
}

func WithCardanoConfig(config *TestCardanoChainConfig) ApexSystemOptions {
return func(h *ApexSystemConfig) {
h.CardanoConfig = config
}
}

func WithNexusConfig(config *TestEVMChainConfig) ApexSystemOptions {
return func(h *ApexSystemConfig) {
h.NexusConfig = config
Expand Down Expand Up @@ -119,9 +134,30 @@ func getDefaultApexSystemConfig() *ApexSystemConfig {

BladeValidatorCount: 4,

PrimeConfig: NewPrimeChainConfig(),
VectorConfig: NewVectorChainConfig(true),
NexusConfig: NewNexusChainConfig(false),
PrimeConfig: NewPrimeChainConfig(),
VectorConfig: NewVectorChainConfig(true),
CardanoConfig: NewCardanoChainConfig(false),
NexusConfig: NewNexusChainConfig(false),

CustomOracleHandler: nil,
CustomRelayerHandler: nil,

UserCnt: 10,
}
}

func getDefaultSkylinexSystemConfig() *ApexSystemConfig {
return &ApexSystemConfig{
APIValidatorID: 1,
APIPortStart: 40000,
APIKey: "test_api_key",

BladeValidatorCount: 4,

PrimeConfig: NewPrimeChainConfig(),
VectorConfig: NewCardanoChainConfig(false),
CardanoConfig: NewCardanoChainConfig(true),
NexusConfig: NewNexusChainConfig(false),

CustomOracleHandler: nil,
CustomRelayerHandler: nil,
Expand All @@ -138,6 +174,10 @@ func (asc *ApexSystemConfig) ServiceCount() int {
count++
}

if asc.CardanoConfig.IsEnabled {
count++
}

if asc.NexusConfig.IsEnabled {
count++
}
Expand All @@ -154,6 +194,10 @@ func (asc *ApexSystemConfig) applyPremineFundingOptions(users []*TestApexUser) {
asc.VectorConfig.PreminesAddresses = make([]string, 0, len(users))
}

if len(asc.CardanoConfig.PreminesAddresses) == 0 {
asc.CardanoConfig.PreminesAddresses = make([]string, 0, len(users))
}

if len(asc.NexusConfig.PreminesAddresses) == 0 {
asc.NexusConfig.PreminesAddresses = make([]types.Address, 0, len(users))
}
Expand All @@ -167,6 +211,11 @@ func (asc *ApexSystemConfig) applyPremineFundingOptions(users []*TestApexUser) {
hex.EncodeToString(user.VectorAddress.GetBytes()))
}

if user.HasCardanoWallet {
asc.CardanoConfig.PreminesAddresses = append(asc.CardanoConfig.PreminesAddresses,
hex.EncodeToString(user.CardanoAddress.GetBytes()))
}

if user.HasNexusWallet {
asc.NexusConfig.PreminesAddresses = append(asc.NexusConfig.PreminesAddresses, user.NexusAddress)
}
Expand Down
Loading
Loading