Skip to content

Commit

Permalink
Merge pull request #408 from multiversx/integration-tests-tada-token
Browse files Browse the repository at this point in the history
Tests for TADA type token
  • Loading branch information
iulianpascalau authored Jan 14, 2025
2 parents 8a39b05 + 2105061 commit 135495b
Show file tree
Hide file tree
Showing 3 changed files with 273 additions and 0 deletions.
150 changes: 150 additions & 0 deletions integrationTests/relayers/slowTests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,156 @@ func ApplyMEMERefundBalances(token *framework.TestTokenParams) {
token.MintBurnChecks.EthSafeMintValue = big.NewInt(4000 - 50 + 6000 - 50 + 2000 - 50 + 1300 - 50 + 1000 - 50)
}

// GenerateTestTADAToken will generate a test MEME token
func GenerateTestTADAToken() framework.TestTokenParams {
//TADA is ethNative = false, ethMintBurn = true, mvxNative = true, mvxMintBurn = false, hasChainSpecificToken = true
return framework.TestTokenParams{
IssueTokenParams: framework.IssueTokenParams{
AbstractTokenIdentifier: "TADA",
NumOfDecimalsUniversal: 1,
NumOfDecimalsChainSpecific: 1,
MvxUniversalTokenTicker: "TADA",
MvxChainSpecificTokenTicker: "ETHTADA",
MvxUniversalTokenDisplayName: "WrappedTADA",
MvxChainSpecificTokenDisplayName: "EthereumWrappedTADA",
ValueToMintOnMvx: "10000000000",
IsMintBurnOnMvX: true,
IsNativeOnMvX: true,
HasChainSpecificToken: true,
EthTokenName: "EthTADA",
EthTokenSymbol: "TADA",
ValueToMintOnEth: "10000000000",
IsMintBurnOnEth: true,
IsNativeOnEth: false,
},
TestOperations: []framework.TokenOperations{
{
ValueToTransferToMvx: big.NewInt(3100),
ValueToSendFromMvX: big.NewInt(5980),
},
{
ValueToTransferToMvx: big.NewInt(800),
ValueToSendFromMvX: big.NewInt(2300),
},
{
ValueToTransferToMvx: big.NewInt(2000),
ValueToSendFromMvX: big.NewInt(4000),
MvxSCCallData: createScCallData("callPayable", 50000000),
},
{
ValueToTransferToMvx: nil,
ValueToSendFromMvX: big.NewInt(29),
IsFaultyDeposit: true,
},
{
ValueToTransferToMvx: nil,
ValueToSendFromMvX: big.NewInt(670),
InvalidReceiver: ethZeroAddress,
IsFaultyDeposit: true,
},
{
ValueToTransferToMvx: big.NewInt(1900),
ValueToSendFromMvX: nil,
InvalidReceiver: mvxZeroAddress,
},
},
DeltaBalances: map[framework.HalfBridgeIdentifier]framework.DeltaBalancesOnKeys{
framework.FirstHalfBridge: map[string]*framework.DeltaBalanceHolder{
framework.Alice: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(-5980 - 2300 - 4000),
MvxToken: framework.UniversalToken,
},
framework.Bob: {
OnEth: big.NewInt(5980 - 50 + 2300 - 50 + 4000 - 50),
OnMvx: big.NewInt(0),
MvxToken: framework.UniversalToken,
},
framework.SafeSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(50 + 50 + 50),
MvxToken: framework.ChainSpecificToken,
},
framework.CalledTestSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(0),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(-5980 - 2300 - 4000),
MvxToken: framework.ChainSpecificToken,
},
},
framework.SecondHalfBridge: map[string]*framework.DeltaBalanceHolder{
framework.Alice: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(-5980 - 2300 - 4000),
MvxToken: framework.UniversalToken,
},
framework.Bob: {
OnEth: big.NewInt(5980 - 50 - 3100 + 2300 - 50 - 800 + 4000 - 50 - 2000 - 1900 + 1850),
OnMvx: big.NewInt(0),
MvxToken: framework.UniversalToken,
},
framework.Charlie: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(3100 + 800),
MvxToken: framework.UniversalToken,
},
framework.SafeSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(50 + 50 + 50 + 50),
MvxToken: framework.ChainSpecificToken,
},
framework.CalledTestSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(2000),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(-5980 - 2300 - 4000 + 3100 + 800 + 2000),
MvxToken: framework.ChainSpecificToken,
},
},
},
MintBurnChecks: &framework.MintBurnBalances{
MvxTotalUniversalMint: big.NewInt(3100 + 800 + 2000),
MvxTotalChainSpecificMint: big.NewInt(3100 + 800 + 2000 + 1900),
MvxTotalUniversalBurn: big.NewInt(5980 + 2300 + 4000),
MvxTotalChainSpecificBurn: big.NewInt(5980 - 50 + 2300 - 50 + 4000 - 50 + 1900 - 50),
MvxSafeMintValue: big.NewInt(3100 + 800 + 2000 + 1900),
MvxSafeBurnValue: big.NewInt(5980 - 50 + 2300 - 50 + 4000 - 50 + 1900 - 50),

EthSafeMintValue: big.NewInt(5980 - 50 + 2300 - 50 + 4000 - 50 + 1900 - 50),
EthSafeBurnValue: big.NewInt(3100 + 800 + 2000 + 1900),
},
SpecialChecks: &framework.SpecialBalanceChecks{
WrapperDeltaLiquidityCheck: big.NewInt(-5980 - 2300 - 4000 + 3100 + 800 + 2000),
},
}
}

// ApplyTADARefundBalances will apply the refund balances on the involved entities for the MEME token
func ApplyTADARefundBalances(token *framework.TestTokenParams) {
// we need to add the 1000 MEME tokens as the third bridge was done that include the refund on the Ethereum side
token.DeltaBalances[framework.SecondHalfBridge][framework.SafeSC].OnMvx = big.NewInt(50 + 50 + 50 + 50 + 50)
// Bob will get his tokens back from the refund
token.DeltaBalances[framework.SecondHalfBridge][framework.Bob].OnEth = big.NewInt(5980 - 50 - 3100 + 2300 - 50 - 800 + 4000 - 50 - 1900 + 1850 - 2000 + 1950)
// no funds remain in the test caller SC
token.DeltaBalances[framework.SecondHalfBridge][framework.CalledTestSC].OnMvx = big.NewInt(0)
// we need to subtract the refunded value from the wrapper contract
token.DeltaBalances[framework.SecondHalfBridge][framework.WrapperSC].OnMvx = big.NewInt(-5980 - 2300 - 4000 + 3100 + 800 + 2000 - 2000)

token.MintBurnChecks.MvxTotalChainSpecificBurn = big.NewInt(5980 - 50 + 2300 - 50 + 4000 - 50 + 2000 - 50 + 1900 - 50)
token.MintBurnChecks.MvxTotalUniversalBurn = big.NewInt(5980 + 2300 + 4000 + 2000)
token.MintBurnChecks.EthSafeMintValue = big.NewInt(5980 - 50 + 2300 - 50 + 4000 - 50 + 2000 - 50 + 1900 - 50)
token.MintBurnChecks.MvxSafeBurnValue = big.NewInt(5980 - 50 + 2300 - 50 + 4000 - 50 + 2000 - 50 + 1900 - 50)

token.SpecialChecks.WrapperDeltaLiquidityCheck = big.NewInt(-5980 - 2300 - 4000 + 3100 + 800 + 2000 - 2000)
}

// GenerateTestEUROCToken will generate a test EUROC token
func GenerateTestEUROCToken() framework.TestTokenParams {
//EUROC is ethNative = true, ethMintBurn = true, mvxNative = false, mvxMintBurn = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestRelayersShouldExecuteTransfersWithMintBurnTokens(t *testing.T) {
make(chan error),
GenerateTestEUROCToken(),
GenerateTestMEXToken(),
GenerateTestTADAToken(),
)
}

Expand Down Expand Up @@ -96,18 +97,23 @@ func TestRelayersShouldExecuteTransfersWithSCCallsWithArgumentsWithMintBurnToken
mexToken := GenerateTestMEXToken()
mexToken.TestOperations[2].MvxSCCallData = callData

tadaToken := GenerateTestTADAToken()
tadaToken.TestOperations[2].MvxSCCallData = callData

testSetup := testRelayersWithChainSimulatorAndTokens(
t,
make(chan error),
eurocToken,
mexToken,
tadaToken,
)

testCallPayableWithParamsWasCalled(
testSetup,
37,
eurocToken.AbstractTokenIdentifier,
mexToken.AbstractTokenIdentifier,
tadaToken.AbstractTokenIdentifier,
)
}

Expand Down Expand Up @@ -175,11 +181,18 @@ func TestRelayersShouldExecuteTransfersWithInitSupplyMintBurn(t *testing.T) {
mexToken.MintBurnChecks.MvxSafeBurnValue.Add(mexToken.MintBurnChecks.MvxSafeBurnValue, mexInitialValue)
mexToken.MintBurnChecks.EthSafeMintValue.Add(mexToken.MintBurnChecks.EthSafeMintValue, mexInitialValue)

tadaInitialValue := big.NewInt(300000)
tadaToken := GenerateTestTADAToken()
tadaToken.InitialSupplyValue = tadaInitialValue.String()
tadaToken.MintBurnChecks.MvxSafeBurnValue.Add(tadaToken.MintBurnChecks.MvxSafeBurnValue, tadaInitialValue)
tadaToken.MintBurnChecks.EthSafeMintValue.Add(tadaToken.MintBurnChecks.EthSafeMintValue, tadaInitialValue)

_ = testRelayersWithChainSimulatorAndTokens(
t,
make(chan error),
eurocToken,
mexToken,
tadaToken,
)
}

Expand Down
Loading

0 comments on commit 135495b

Please sign in to comment.