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

Added wrapper checks in e2e tests #395

Merged
merged 4 commits into from
Dec 11, 2024
Merged
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
170 changes: 127 additions & 43 deletions integrationTests/relayers/slowTests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ func GenerateTestUSDCToken() framework.TestTokenParams {
OnMvx: big.NewInt(1000),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(5000 + 7000 + 1000),
MvxToken: framework.ChainSpecificToken,
},
},
framework.SecondHalfBridge: map[string]*framework.DeltaBalanceHolder{
framework.Alice: {
Expand Down Expand Up @@ -114,15 +119,26 @@ func GenerateTestUSDCToken() framework.TestTokenParams {
OnMvx: big.NewInt(1000),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(5000 + 7000 + 1000 - 2500 - 300),
MvxToken: framework.ChainSpecificToken,
},
},
},
MintBurnChecks: &framework.MintBurnBalances{
TotalUniversalMint: big.NewInt(5000 + 7000 + 1000),
TotalChainSpecificMint: big.NewInt(5000 + 7000 + 1000 + 900),
TotalUniversalBurn: big.NewInt(2500 + 300),
TotalChainSpecificBurn: big.NewInt(2500 - 50 + 300 - 50 + 900 - 50),
SafeMintValue: big.NewInt(5000 + 7000 + 1000 + 900),
SafeBurnValue: big.NewInt(2500 - 50 + 300 - 50 + 900 - 50),
MvxTotalUniversalMint: big.NewInt(5000 + 7000 + 1000),
MvxTotalChainSpecificMint: big.NewInt(5000 + 7000 + 1000 + 900),
MvxTotalUniversalBurn: big.NewInt(2500 + 300),
MvxTotalChainSpecificBurn: big.NewInt(2500 - 50 + 300 - 50 + 900 - 50),
MvxSafeMintValue: big.NewInt(5000 + 7000 + 1000 + 900),
MvxSafeBurnValue: big.NewInt(2500 - 50 + 300 - 50 + 900 - 50),

EthSafeMintValue: big.NewInt(0),
EthSafeBurnValue: big.NewInt(0),
},
SpecialChecks: &framework.SpecialBalanceChecks{
WrapperDeltaLiquidityCheck: big.NewInt(5000 + 7000 + 1000 - 2500 - 300),
},
}
}
Expand All @@ -139,10 +155,14 @@ func ApplyUSDCRefundBalances(token *framework.TestTokenParams) {
token.DeltaBalances[framework.SecondHalfBridge][framework.Alice].OnEth = big.NewInt(-5000 - 7000 - 1000 - 900 + 950 + 850)
// no funds remain in the called test 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(5000 + 7000 + 1000 - 2500 - 300 - 1000)

token.MintBurnChecks.MvxTotalChainSpecificBurn = big.NewInt(2500 - 50 + 300 - 50 + 1000 - 50 + 900 - 50)
token.MintBurnChecks.MvxTotalUniversalBurn = big.NewInt(2500 + 300 + 1000)
token.MintBurnChecks.MvxSafeBurnValue = big.NewInt(2500 - 50 + 300 - 50 + 1000 - 50 + 900 - 50)

token.MintBurnChecks.TotalChainSpecificBurn = big.NewInt(2500 - 50 + 300 - 50 + 1000 - 50 + 900 - 50)
token.MintBurnChecks.TotalUniversalBurn = big.NewInt(2500 + 300 + 1000)
token.MintBurnChecks.SafeBurnValue = big.NewInt(2500 - 50 + 300 - 50 + 1000 - 50 + 900 - 50)
token.SpecialChecks.WrapperDeltaLiquidityCheck = big.NewInt(5000 + 7000 + 1000 - 2500 - 300 - 1000)
}

// GenerateTestMEMEToken will generate a test MEME token
Expand Down Expand Up @@ -210,6 +230,11 @@ func GenerateTestMEMEToken() framework.TestTokenParams {
OnMvx: big.NewInt(0),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(0),
MvxToken: framework.ChainSpecificToken,
},
},
framework.SecondHalfBridge: map[string]*framework.DeltaBalanceHolder{
framework.Alice: {
Expand Down Expand Up @@ -237,15 +262,26 @@ func GenerateTestMEMEToken() framework.TestTokenParams {
OnMvx: big.NewInt(1000),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(0),
MvxToken: framework.ChainSpecificToken,
},
},
},
MintBurnChecks: &framework.MintBurnBalances{
TotalUniversalMint: big.NewInt(0),
TotalChainSpecificMint: big.NewInt(0),
TotalUniversalBurn: big.NewInt(0),
TotalChainSpecificBurn: big.NewInt(0),
SafeMintValue: big.NewInt(0),
SafeBurnValue: big.NewInt(0),
MvxTotalUniversalMint: big.NewInt(0),
MvxTotalChainSpecificMint: big.NewInt(0),
MvxTotalUniversalBurn: big.NewInt(0),
MvxTotalChainSpecificBurn: big.NewInt(0),
MvxSafeMintValue: big.NewInt(0),
MvxSafeBurnValue: big.NewInt(0),

EthSafeMintValue: big.NewInt(4000 - 50 + 6000 - 50 + 2000 - 50),
EthSafeBurnValue: big.NewInt(2400 + 200 + 1000),
},
SpecialChecks: &framework.SpecialBalanceChecks{
WrapperDeltaLiquidityCheck: big.NewInt(0),
},
}
}
Expand All @@ -258,6 +294,8 @@ func ApplyMEMERefundBalances(token *framework.TestTokenParams) {
token.DeltaBalances[framework.SecondHalfBridge][framework.Bob].OnEth = big.NewInt(4000 - 50 - 2400 + 6000 - 50 - 200 + 2000 - 50 - 1000 + 950)
// no funds remain in the test caller SC
token.DeltaBalances[framework.SecondHalfBridge][framework.CalledTestSC].OnMvx = big.NewInt(0)

token.MintBurnChecks.EthSafeMintValue = big.NewInt(4000 - 50 + 6000 - 50 + 2000 - 50 + 1000 - 50)
}

// GenerateTestEUROCToken will generate a test EUROC token
Expand Down Expand Up @@ -329,6 +367,11 @@ func GenerateTestEUROCToken() framework.TestTokenParams {
OnMvx: big.NewInt(1010),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(0),
MvxToken: framework.ChainSpecificToken,
},
},
framework.SecondHalfBridge: map[string]*framework.DeltaBalanceHolder{
framework.Alice: {
Expand Down Expand Up @@ -356,15 +399,26 @@ func GenerateTestEUROCToken() framework.TestTokenParams {
OnMvx: big.NewInt(1010),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(0),
MvxToken: framework.ChainSpecificToken,
},
},
},
MintBurnChecks: &framework.MintBurnBalances{
TotalUniversalMint: big.NewInt(5010 + 7010 + 1010 + 700),
TotalChainSpecificMint: big.NewInt(0),
TotalUniversalBurn: big.NewInt(2510 - 50 + 310 - 50 + 700 - 50),
TotalChainSpecificBurn: big.NewInt(0),
SafeMintValue: big.NewInt(5010 + 7010 + 1010 + 700),
SafeBurnValue: big.NewInt(2510 - 50 + 310 - 50 + 700 - 50),
MvxTotalUniversalMint: big.NewInt(5010 + 7010 + 1010 + 700),
MvxTotalChainSpecificMint: big.NewInt(0),
MvxTotalUniversalBurn: big.NewInt(2510 - 50 + 310 - 50 + 700 - 50),
MvxTotalChainSpecificBurn: big.NewInt(0),
MvxSafeMintValue: big.NewInt(5010 + 7010 + 1010 + 700),
MvxSafeBurnValue: big.NewInt(2510 - 50 + 310 - 50 + 700 - 50),

EthSafeMintValue: big.NewInt(2510 - 50 + 310 - 50 + 650),
EthSafeBurnValue: big.NewInt(5010 + 7010 + 1010 + 700),
},
SpecialChecks: &framework.SpecialBalanceChecks{
WrapperDeltaLiquidityCheck: big.NewInt(0),
},
}
}
Expand All @@ -380,8 +434,9 @@ func ApplyEUROCRefundBalances(token *framework.TestTokenParams) {
// no funds remain in the called test SC
token.DeltaBalances[framework.SecondHalfBridge][framework.CalledTestSC].OnMvx = big.NewInt(0)

token.MintBurnChecks.TotalUniversalBurn = big.NewInt(2510 - 50 + 310 - 50 + 700 - 50 + 1010 - 50)
token.MintBurnChecks.SafeBurnValue = big.NewInt(2510 - 50 + 310 - 50 + 700 - 50 + 1010 - 50)
token.MintBurnChecks.MvxTotalUniversalBurn = big.NewInt(2510 - 50 + 310 - 50 + 700 - 50 + 1010 - 50)
token.MintBurnChecks.MvxSafeBurnValue = big.NewInt(2510 - 50 + 310 - 50 + 700 - 50 + 1010 - 50)
token.MintBurnChecks.EthSafeMintValue = big.NewInt(2510 - 50 + 310 - 50 + 650 + 1010 - 50)
}

// GenerateTestMEXToken will generate a test MEX token
Expand Down Expand Up @@ -449,6 +504,11 @@ func GenerateTestMEXToken() framework.TestTokenParams {
OnMvx: big.NewInt(0),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(0),
MvxToken: framework.ChainSpecificToken,
},
},
framework.SecondHalfBridge: map[string]*framework.DeltaBalanceHolder{
framework.Alice: {
Expand Down Expand Up @@ -476,15 +536,26 @@ func GenerateTestMEXToken() framework.TestTokenParams {
OnMvx: big.NewInt(1010),
MvxToken: framework.UniversalToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(0),
MvxToken: framework.ChainSpecificToken,
},
},
},
MintBurnChecks: &framework.MintBurnBalances{
TotalUniversalMint: big.NewInt(2410 + 210 + 1010),
TotalChainSpecificMint: big.NewInt(0),
TotalUniversalBurn: big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50),
TotalChainSpecificBurn: big.NewInt(0),
SafeMintValue: big.NewInt(2410 + 210 + 1010),
SafeBurnValue: big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50),
MvxTotalUniversalMint: big.NewInt(2410 + 210 + 1010),
MvxTotalChainSpecificMint: big.NewInt(0),
MvxTotalUniversalBurn: big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50),
MvxTotalChainSpecificBurn: big.NewInt(0),
MvxSafeMintValue: big.NewInt(2410 + 210 + 1010),
MvxSafeBurnValue: big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50),

EthSafeMintValue: big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50),
EthSafeBurnValue: big.NewInt(2410 + 210 + 1010),
},
SpecialChecks: &framework.SpecialBalanceChecks{
WrapperDeltaLiquidityCheck: big.NewInt(0),
},
}
}
Expand All @@ -498,8 +569,9 @@ func ApplyMEXRefundBalances(token *framework.TestTokenParams) {
// no funds remain in the test caller SC
token.DeltaBalances[framework.SecondHalfBridge][framework.CalledTestSC].OnMvx = big.NewInt(0)

token.MintBurnChecks.TotalUniversalBurn = big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50 + 1010 - 50)
token.MintBurnChecks.SafeBurnValue = big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50 + 1010 - 50)
token.MintBurnChecks.MvxTotalUniversalBurn = big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50 + 1010 - 50)
token.MintBurnChecks.MvxSafeBurnValue = big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50 + 1010 - 50)
token.MintBurnChecks.EthSafeMintValue = big.NewInt(4010 - 50 + 6010 - 50 + 2010 - 50 + 1010 - 50)
}

// GenerateUnlistedTokenFromEth will generate an unlisted token on Eth
Expand Down Expand Up @@ -594,12 +666,18 @@ func GenerateUnlistedTokenFromEth() framework.TestTokenParams {
},
},
MintBurnChecks: &framework.MintBurnBalances{
TotalUniversalMint: big.NewInt(0),
TotalChainSpecificMint: big.NewInt(0),
TotalUniversalBurn: big.NewInt(0),
TotalChainSpecificBurn: big.NewInt(0),
SafeMintValue: big.NewInt(0),
SafeBurnValue: big.NewInt(0),
MvxTotalUniversalMint: big.NewInt(0),
MvxTotalChainSpecificMint: big.NewInt(0),
MvxTotalUniversalBurn: big.NewInt(0),
MvxTotalChainSpecificBurn: big.NewInt(0),
MvxSafeMintValue: big.NewInt(0),
MvxSafeBurnValue: big.NewInt(0),

EthSafeBurnValue: big.NewInt(0),
EthSafeMintValue: big.NewInt(0),
},
SpecialChecks: &framework.SpecialBalanceChecks{
WrapperDeltaLiquidityCheck: big.NewInt(0),
},
}
}
Expand Down Expand Up @@ -694,12 +772,18 @@ func GenerateUnlistedTokenFromMvx() framework.TestTokenParams {
},
},
MintBurnChecks: &framework.MintBurnBalances{
TotalUniversalMint: big.NewInt(0),
TotalChainSpecificMint: big.NewInt(0),
TotalUniversalBurn: big.NewInt(0),
TotalChainSpecificBurn: big.NewInt(0),
SafeMintValue: big.NewInt(0),
SafeBurnValue: big.NewInt(0),
MvxTotalUniversalMint: big.NewInt(0),
MvxTotalChainSpecificMint: big.NewInt(0),
MvxTotalUniversalBurn: big.NewInt(0),
MvxTotalChainSpecificBurn: big.NewInt(0),
MvxSafeMintValue: big.NewInt(0),
MvxSafeBurnValue: big.NewInt(0),

EthSafeMintValue: big.NewInt(0),
EthSafeBurnValue: big.NewInt(0),
},
SpecialChecks: &framework.SpecialBalanceChecks{
WrapperDeltaLiquidityCheck: big.NewInt(0),
},
}
}
Expand Down
26 changes: 20 additions & 6 deletions integrationTests/relayers/slowTests/edgeCases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func TestRelayerShouldExecuteSimultaneousSwapsAndNotCatchErrors(t *testing.T) {
OnMvx: big.NewInt(0),
MvxToken: framework.ChainSpecificToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(5000),
MvxToken: framework.ChainSpecificToken,
},
},
framework.SecondHalfBridge: map[string]*framework.DeltaBalanceHolder{
framework.Alice: {
Expand All @@ -83,16 +88,25 @@ func TestRelayerShouldExecuteSimultaneousSwapsAndNotCatchErrors(t *testing.T) {
OnMvx: big.NewInt(50),
MvxToken: framework.ChainSpecificToken,
},
framework.WrapperSC: {
OnEth: big.NewInt(0),
OnMvx: big.NewInt(5000 + 5000 - 200),
MvxToken: framework.ChainSpecificToken,
},
},
}
usdcToken.MintBurnChecks = &framework.MintBurnBalances{
TotalUniversalMint: big.NewInt(5000 + 5000),
TotalChainSpecificMint: big.NewInt(5000 + 5000),
TotalUniversalBurn: big.NewInt(200),
TotalChainSpecificBurn: big.NewInt(200 - 50),
SafeMintValue: big.NewInt(5000 + 5000),
SafeBurnValue: big.NewInt(200 - 50),
MvxTotalUniversalMint: big.NewInt(5000 + 5000),
MvxTotalChainSpecificMint: big.NewInt(5000 + 5000),
MvxTotalUniversalBurn: big.NewInt(200),
MvxTotalChainSpecificBurn: big.NewInt(200 - 50),
MvxSafeMintValue: big.NewInt(5000 + 5000),
MvxSafeBurnValue: big.NewInt(200 - 50),

EthSafeMintValue: big.NewInt(0),
EthSafeBurnValue: big.NewInt(0),
}
usdcToken.SpecialChecks.WrapperDeltaLiquidityCheck = big.NewInt(5000 + 5000 - 200)

_ = testRelayersWithChainSimulatorAndTokensForSimultaneousSwaps(
t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ func TestRelayersShouldExecuteTransfersWithInitSupply(t *testing.T) {
usdcInitialValue := big.NewInt(100000)
usdcToken := GenerateTestUSDCToken()
usdcToken.InitialSupplyValue = usdcInitialValue.String()
usdcToken.MintBurnChecks.SafeMintValue.Add(usdcToken.MintBurnChecks.SafeMintValue, usdcInitialValue)
usdcToken.MintBurnChecks.MvxSafeMintValue.Add(usdcToken.MintBurnChecks.MvxSafeMintValue, usdcInitialValue)

memeInitialValue := big.NewInt(200000)
memeToken := GenerateTestMEMEToken()
memeToken.InitialSupplyValue = memeInitialValue.String()
memeToken.MintBurnChecks.EthSafeMintValue.Add(memeToken.MintBurnChecks.EthSafeMintValue, memeInitialValue)

_ = testRelayersWithChainSimulatorAndTokens(
t,
Expand All @@ -165,12 +166,14 @@ func TestRelayersShouldExecuteTransfersWithInitSupplyMintBurn(t *testing.T) {
eurocInitialValue := big.NewInt(100010)
eurocToken := GenerateTestEUROCToken()
eurocToken.InitialSupplyValue = eurocInitialValue.String()
eurocToken.MintBurnChecks.SafeMintValue.Add(eurocToken.MintBurnChecks.SafeMintValue, eurocInitialValue)
eurocToken.MintBurnChecks.MvxSafeMintValue.Add(eurocToken.MintBurnChecks.MvxSafeMintValue, eurocInitialValue)
eurocToken.MintBurnChecks.EthSafeBurnValue.Add(eurocToken.MintBurnChecks.EthSafeBurnValue, eurocInitialValue)

mexInitialValue := big.NewInt(300000)
mexToken := GenerateTestMEXToken()
mexToken.InitialSupplyValue = mexInitialValue.String()
mexToken.MintBurnChecks.SafeBurnValue.Add(mexToken.MintBurnChecks.SafeBurnValue, mexInitialValue)
mexToken.MintBurnChecks.MvxSafeBurnValue.Add(mexToken.MintBurnChecks.MvxSafeBurnValue, mexInitialValue)
mexToken.MintBurnChecks.EthSafeMintValue.Add(mexToken.MintBurnChecks.EthSafeMintValue, mexInitialValue)

_ = testRelayersWithChainSimulatorAndTokens(
t,
Expand Down Expand Up @@ -373,12 +376,12 @@ func createBadToken() framework.TestTokenParams {
},
},
MintBurnChecks: &framework.MintBurnBalances{
TotalUniversalMint: big.NewInt(0),
TotalChainSpecificMint: big.NewInt(0),
TotalUniversalBurn: big.NewInt(0),
TotalChainSpecificBurn: big.NewInt(0),
SafeMintValue: big.NewInt(0),
SafeBurnValue: big.NewInt(0),
MvxTotalUniversalMint: big.NewInt(0),
MvxTotalChainSpecificMint: big.NewInt(0),
MvxTotalUniversalBurn: big.NewInt(0),
MvxTotalChainSpecificBurn: big.NewInt(0),
MvxSafeMintValue: big.NewInt(0),
MvxSafeBurnValue: big.NewInt(0),
},
}
}
Expand Down
1 change: 0 additions & 1 deletion integrationTests/relayers/slowTests/framework/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const (
WrapperSC = "Wrapper SC"
CalledTestSC = "Called test SC"
SafeSC = "Safe SC"
AddressZero = "AddressZero"
)

// NewKeysStore will create a KeysStore instance and generate all keys
Expand Down
Loading
Loading