diff --git a/integrationTests/relayers/slowTests/common.go b/integrationTests/relayers/slowTests/common.go index dc7a5750..69816d10 100644 --- a/integrationTests/relayers/slowTests/common.go +++ b/integrationTests/relayers/slowTests/common.go @@ -646,6 +646,93 @@ func GenerateUnlistedTokenFromMvx() framework.TestTokenParams { } } +// GenerateFrozenToken will generate a token that will be frozen +func GenerateFrozenToken() framework.TestTokenParams { + return framework.TestTokenParams{ + IssueTokenParams: framework.IssueTokenParams{ + AbstractTokenIdentifier: "FROZEN", + NumOfDecimalsUniversal: 2, + NumOfDecimalsChainSpecific: 2, + MvxUniversalTokenTicker: "FROZEN", + MvxChainSpecificTokenTicker: "FROZEN", + MvxUniversalTokenDisplayName: "TestFROZEN", + MvxChainSpecificTokenDisplayName: "TestFROZEN", + ValueToMintOnMvx: "10000000000", + IsMintBurnOnMvX: true, + IsNativeOnMvX: false, + HasChainSpecificToken: false, + EthTokenName: "EthFROZEN", + EthTokenSymbol: "FROZEN", + ValueToMintOnEth: "10000000000", + IsMintBurnOnEth: true, + IsNativeOnEth: true, + IsFrozen: true, + }, + TestOperations: []framework.TokenOperations{ + { + ValueToTransferToMvx: big.NewInt(2000), + ValueToSendFromMvX: nil, + }, + { + ValueToTransferToMvx: big.NewInt(1500), + ValueToSendFromMvX: nil, + MvxSCCallData: createScCallData("callPayable", 50000000), + }, + }, + DeltaBalances: map[framework.HalfBridgeIdentifier]framework.DeltaBalancesOnKeys{ + framework.FirstHalfBridge: map[string]*framework.DeltaBalanceHolder{ + framework.Alice: { + OnEth: big.NewInt(-2000 - 1500), + OnMvx: big.NewInt(0), + MvxToken: framework.UniversalToken, + }, + framework.Bob: { + OnEth: big.NewInt(0), + OnMvx: big.NewInt(0), + MvxToken: framework.UniversalToken, + }, + framework.SafeSC: { + OnEth: big.NewInt(0), + OnMvx: big.NewInt(0), + MvxToken: framework.ChainSpecificToken, + }, + framework.CalledTestSC: { + OnEth: big.NewInt(0), + OnMvx: big.NewInt(0), + MvxToken: framework.UniversalToken, + }, + }, + framework.SecondHalfBridge: map[string]*framework.DeltaBalanceHolder{ + framework.Alice: { + OnEth: big.NewInt(-2000 - 1500 + 1950 + 1450), + OnMvx: big.NewInt(0), + MvxToken: framework.UniversalToken, + }, + framework.Bob: { + OnEth: big.NewInt(0), + OnMvx: big.NewInt(0), + MvxToken: framework.UniversalToken, + }, + framework.Charlie: { + OnEth: big.NewInt(0), + OnMvx: big.NewInt(0), + MvxToken: framework.UniversalToken, + }, + framework.SafeSC: { + OnEth: big.NewInt(0), + OnMvx: big.NewInt(50), + MvxToken: framework.ChainSpecificToken, + }, + framework.CalledTestSC: { + OnEth: big.NewInt(0), + OnMvx: big.NewInt(0), + MvxToken: framework.UniversalToken, + }, + }, + }, + } +} + func createScCallData(function string, gasLimit uint64, args ...string) []byte { codec := testsCommon.TestMultiversXCodec{} callData := parsers.CallData{ diff --git a/integrationTests/relayers/slowTests/framework/multiversxHandler.go b/integrationTests/relayers/slowTests/framework/multiversxHandler.go index d1746d93..9796c2ad 100644 --- a/integrationTests/relayers/slowTests/framework/multiversxHandler.go +++ b/integrationTests/relayers/slowTests/framework/multiversxHandler.go @@ -22,6 +22,7 @@ const ( slashAmount = "00" zeroStringValue = "0" canAddSpecialRoles = "canAddSpecialRoles" + canFreeze = "canFreeze" trueStr = "true" esdtRoleLocalMint = "ESDTRoleLocalMint" esdtRoleLocalBurn = "ESDTRoleLocalBurn" @@ -59,6 +60,7 @@ const ( pauseFunction = "pause" issueFunction = "issue" setSpecialRoleFunction = "setSpecialRole" + freezeFunction = "freeze" esdtTransferFunction = "ESDTTransfer" setPairDecimalsFunction = "setPairDecimals" addWrappedTokenFunction = "addWrappedToken" @@ -564,6 +566,9 @@ func (handler *MultiversxHandler) issueAndWhitelistTokensWithChainSpecific(ctx c if params.PreventWhitelist { return } + if params.IsFrozen { + handler.freezeToken(ctx, params) + } handler.setLocalRolesForUniversalTokenOnWrapper(ctx, params) handler.transferChainSpecificTokenToSCs(ctx, params) handler.addUniversalTokenToWrapper(ctx, params) @@ -586,6 +591,9 @@ func (handler *MultiversxHandler) issueAndWhitelistTokens(ctx context.Context, p if params.PreventWhitelist { return } + if params.IsFrozen { + handler.freezeToken(ctx, params) + } handler.setRolesForSpecificTokenOnSafe(ctx, params) handler.addMappingInMultisig(ctx, params) @@ -609,6 +617,8 @@ func (handler *MultiversxHandler) issueUniversalToken(ctx context.Context, param hex.EncodeToString([]byte(params.MvxUniversalTokenTicker)), hex.EncodeToString(valueToMintInt.Bytes()), fmt.Sprintf("%02x", params.NumOfDecimalsUniversal), + hex.EncodeToString([]byte(canFreeze)), + hex.EncodeToString([]byte(trueStr)), hex.EncodeToString([]byte(canAddSpecialRoles)), hex.EncodeToString([]byte(trueStr))} @@ -635,6 +645,8 @@ func (handler *MultiversxHandler) issueChainSpecificToken(ctx context.Context, p hex.EncodeToString([]byte(params.MvxChainSpecificTokenTicker)), hex.EncodeToString(valueToMintInt.Bytes()), fmt.Sprintf("%02x", params.NumOfDecimalsChainSpecific), + hex.EncodeToString([]byte(canFreeze)), + hex.EncodeToString([]byte(trueStr)), hex.EncodeToString([]byte(canAddSpecialRoles)), hex.EncodeToString([]byte(trueStr))} @@ -940,6 +952,26 @@ func (handler *MultiversxHandler) setMaxBridgeAmountOnMultitransfer(ctx context. log.Info("multi-transfer set max bridge amount for token tx executed", "hash", hash, "status", txResult.Status) } +func (handler *MultiversxHandler) freezeToken(ctx context.Context, params IssueTokenParams) { + tkData := handler.TokensRegistry.GetTokenData(params.AbstractTokenIdentifier) + + scCallParams := []string{ + hex.EncodeToString([]byte(tkData.MvxUniversalToken)), + handler.BobKeys.MvxAddress.Hex(), + } + + hash, txResult := handler.scCallAndCheckTx( + ctx, + handler.OwnerKeys, + handler.ESDTSystemContractAddress, + zeroStringValue, + setCallsGasLimit, + freezeFunction, + scCallParams) + + log.Info("freeze token tx executed", "hash", hash, "status", txResult.Status) +} + func (handler *MultiversxHandler) getTokenNameFromResult(txResult data.TransactionOnNetwork) string { for _, event := range txResult.Logs.Events { if event.Identifier == issueFunction { diff --git a/integrationTests/relayers/slowTests/framework/types.go b/integrationTests/relayers/slowTests/framework/types.go index f5a0dca9..40bd55ce 100644 --- a/integrationTests/relayers/slowTests/framework/types.go +++ b/integrationTests/relayers/slowTests/framework/types.go @@ -14,6 +14,7 @@ type IssueTokenParams struct { InitialSupplyParams AbstractTokenIdentifier string PreventWhitelist bool + IsFrozen bool // MultiversX NumOfDecimalsUniversal int diff --git a/integrationTests/relayers/slowTests/refundWithChainSimulator_test.go b/integrationTests/relayers/slowTests/refundWithChainSimulator_test.go index 116385c5..37bfea33 100644 --- a/integrationTests/relayers/slowTests/refundWithChainSimulator_test.go +++ b/integrationTests/relayers/slowTests/refundWithChainSimulator_test.go @@ -367,6 +367,15 @@ func TestRelayersShouldExecuteTransfersWithRefund(t *testing.T) { mexToken, ) }) + t.Run("frozen token for receiver should refund", func(t *testing.T) { + frozenToken := GenerateFrozenToken() + + testRelayersWithChainSimulatorAndTokensAndRefund( + t, + make(chan error), + frozenToken, + ) + }) } func testRelayersWithChainSimulatorAndTokensAndRefund(tb testing.TB, manualStopChan chan error, tokens ...framework.TestTokenParams) {