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

Integraton tests for dynamic price changes #406

Open
wants to merge 7 commits into
base: feat/v3.1
Choose a base branch
from

Conversation

cosmatudor
Copy link

No description provided.

iulianpascalau and others added 4 commits December 18, 2024 13:22
- changed max bridge amount on safe
- changed aggregation fee
…ce-changes

# Conflicts:
#	executors/multiversx/module/scCallsModule.go
#	integrationTests/relayers/slowTests/edgeCases_test.go
@cosmatudor cosmatudor changed the base branch from main to feat/v3.1 January 8, 2025 12:38
# Conflicts:
#	executors/multiversx/module/scCallsModule.go
#	integrationTests/relayers/slowTests/framework/testSetup.go
@@ -35,22 +34,22 @@ type scCallsModule struct {
}

// NewScCallsModule creates a starts a new scCallsModule instance
func NewScCallsModule(cfg config.ScCallsModuleConfig, log logger.Logger) (*scCallsModule, error) {
func NewScCallsModule(cfg config.ScCallsModuleConfig, proxy multiversx.Proxy, log logger.Logger) (*scCallsModule, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

extract parameters into a Arg structure

Copy link
Contributor

Choose a reason for hiding this comment

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

also missing check for nil log instance

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess is my fault by not checking the log instance for nil :(

@@ -236,4 +218,4 @@ func (module *scCallsModule) Close() error {
}

return lastError
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

missing new line

func NewScCallsModule(cfg config.ScCallsModuleConfig, log logger.Logger) (*scCallsModule, error) {
func NewScCallsModule(cfg config.ScCallsModuleConfig, proxy multiversx.Proxy, log logger.Logger) (*scCallsModule, error) {
if check.IfNil(proxy) {
return nil, errNilProxy //TODO: add unit test for this
Copy link
Contributor

Choose a reason for hiding this comment

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

remove todo

Comment on lines +63 to +64
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "nil proxy")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe consider exporting the error and check here against error?

Copy link
Contributor

Choose a reason for hiding this comment

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

The check should be made on the existing errNilProxy error. The error, however, does not necessarily need to be exported since we are using the same package for production code & test code


module, err := NewScCallsModule(cfg, &testsCommon.LoggerStub{})
module, err := NewScCallsModule(cfg, proxy, &testsCommon.LoggerStub{})
Copy link
Contributor

Choose a reason for hiding this comment

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

use a mocked component instead of a real proxy

Copy link
Contributor

Choose a reason for hiding this comment

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

agree, we should use a stub proxy instance for these tests

assert.NotNil(t, err)
assert.Contains(t, err.Error(), "invalid caching duration, provided: 0s, minimum: 1s")
assert.Nil(t, module)
assert.Nil(t, proxy)
Copy link
Contributor

Choose a reason for hiding this comment

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

all proxy tests should be removed now from this component

logger "github.com/multiversx/mx-chain-logger-go"
"github.com/stretchr/testify/require"
)

const ScCallsDeltaLimit = 10
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be unexported

})
}

func testRelayersWithChainSimulatorAndTokensForChangedAggregationFee(tb testing.TB, manualStopChan chan error, tokens ...framework.TestTokenParams) *framework.TestSetup {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is very similar to testRelayersWithChainSimulatorAndTokensForChangedMaxBridgeAmount.. can we remove the duplicated code?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe provide the handler as a parameter? The one given to the RegisterBeforeTransactionSendHandler function

@@ -766,7 +766,7 @@ func (handler *MultiversxHandler) setPairDecimalsOnAggregator(ctx context.Contex
log.Info("setPairDecimals tx executed", "hash", hash, "status", txResult.Status)
}

func (handler *MultiversxHandler) setMaxBridgeAmountOnSafe(ctx context.Context, params IssueTokenParams) {
func (handler *MultiversxHandler) SetMaxBridgeAmountOnSafe(ctx context.Context, params IssueTokenParams, maxBridgedAmountForToken string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this needed as exported? if so, missing comment

@@ -35,22 +34,22 @@ type scCallsModule struct {
}

// NewScCallsModule creates a starts a new scCallsModule instance
func NewScCallsModule(cfg config.ScCallsModuleConfig, log logger.Logger) (*scCallsModule, error) {
func NewScCallsModule(cfg config.ScCallsModuleConfig, proxy multiversx.Proxy, log logger.Logger) (*scCallsModule, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess is my fault by not checking the log instance for nil :(

@@ -1,7 +1,10 @@
package module

import (
"github.com/multiversx/mx-sdk-go/blockchain"
Copy link
Contributor

Choose a reason for hiding this comment

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

go imports

Comment on lines +63 to +64
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "nil proxy")
Copy link
Contributor

Choose a reason for hiding this comment

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

The check should be made on the existing errNilProxy error. The error, however, does not necessarily need to be exported since we are using the same package for production code & test code


module, err := NewScCallsModule(cfg, &testsCommon.LoggerStub{})
module, err := NewScCallsModule(cfg, proxy, &testsCommon.LoggerStub{})
Copy link
Contributor

Choose a reason for hiding this comment

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

agree, we should use a stub proxy instance for these tests

})
}

func testRelayersWithChainSimulatorAndTokensForChangedAggregationFee(tb testing.TB, manualStopChan chan error, tokens ...framework.TestTokenParams) *framework.TestSetup {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe provide the handler as a parameter? The one given to the RegisterBeforeTransactionSendHandler function

if firstProcessRun {
firstProcessRun = false

//TODO: remove this example
Copy link
Contributor

Choose a reason for hiding this comment

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

remove TODO & this example?

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.

3 participants