From 188a0947e8adf3e4183a09cb4a38d18d9373892e Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Fri, 25 Apr 2025 17:00:09 -0500 Subject: [PATCH 1/6] initiate sui fungible token withdrawAndCall e2e tests --- cmd/zetae2e/local/local.go | 7 +- e2e/config/config.go | 1 - e2e/contracts/sui/connected.mv | Bin 665 -> 656 bytes e2e/contracts/sui/example/Makefile | 4 +- e2e/contracts/sui/example/Move.lock | 24 ++--- e2e/contracts/sui/example/connected.mv | Bin 665 -> 0 bytes .../sui/example/sources/example.move | 7 +- e2e/contracts/sui/example/token.mv | Bin 629 -> 0 bytes e2e/e2etests/e2etests.go | 46 ++++++--- .../test_sui_token_withdraw_and_call.go | 75 ++++++++++++++ ...oken_withdraw_and_call_revert_with_call.go | 94 ++++++++++++++++++ e2e/e2etests/test_sui_withdraw_and_call.go | 6 +- ..._sui_withdraw_and_call_revert_with_call.go | 8 +- e2e/runner/setup_sui.go | 7 +- e2e/runner/sui.go | 30 ++++++ 15 files changed, 256 insertions(+), 53 deletions(-) delete mode 100644 e2e/contracts/sui/example/connected.mv delete mode 100644 e2e/contracts/sui/example/token.mv create mode 100644 e2e/e2etests/test_sui_token_withdraw_and_call.go create mode 100644 e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 2f6fe4cce0..f6cfd737c6 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -521,11 +521,12 @@ func localE2ETest(cmd *cobra.Command, _ []string) { e2etests.TestSuiTokenDepositAndCallName, e2etests.TestSuiTokenDepositAndCallRevertName, e2etests.TestSuiWithdrawName, - e2etests.TestSuiWithdrawRevertWithCallName, - e2etests.TestSuiTokenWithdrawName, - // https://github.com/zeta-chain/node/issues/3742 e2etests.TestSuiWithdrawAndCallName, + e2etests.TestSuiWithdrawRevertWithCallName, e2etests.TestSuiWithdrawAndCallRevertWithCallName, + e2etests.TestSuiTokenWithdrawName, + e2etests.TestSuiTokenWithdrawAndCallName, + e2etests.TestSuiTokenWithdrawAndCallRevertWithCallName, e2etests.TestSuiDepositRestrictedName, e2etests.TestSuiWithdrawRestrictedName, } diff --git a/e2e/config/config.go b/e2e/config/config.go index 5662fedd20..e071d4f867 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -151,7 +151,6 @@ type SuiExample struct { GlobalConfigID DoubleQuotedString `yaml:"global_config_id"` PartnerID DoubleQuotedString `yaml:"partner_id"` ClockID DoubleQuotedString `yaml:"clock_id"` - PoolID DoubleQuotedString `yaml:"pool_id"` } // Sui contains the addresses of predeployed contracts on the Sui chain diff --git a/e2e/contracts/sui/connected.mv b/e2e/contracts/sui/connected.mv index 9923fca1ff048f2501a9f4caafc750ecfda85b91..82a298c9a2e17e8b080fafcdcb478bcdc5b94ebc 100644 GIT binary patch delta 88 zcmV-e0H^<%1&{?Vp&aWA1^@s63jqKS0uU+#Iwk~Q3I%FX2fP8&0SJx*Knl(S8Vl$H u0u1T{at+*(FGT?Xk#;Ky1`7oN2>=HO0I{;U0SN>V0t^NV01F0_bOI$cBoV;? delta 97 zcmV-n0G|Jl1(^jep&aWA1^@s63jqKS0uU+#Iwu5S3I%Ig2gL!>0SK1^Knm9b8Vm6Q z0u1v5at-B?FGT_Z0FiYo5eEwe0SN#H2ml8Q0|E&E2?4RGxd90U5dsVc3jhlTlWPJc D#*Pvv diff --git a/e2e/contracts/sui/example/Makefile b/e2e/contracts/sui/example/Makefile index 6fb133a100..b6e66b5e24 100644 --- a/e2e/contracts/sui/example/Makefile +++ b/e2e/contracts/sui/example/Makefile @@ -10,8 +10,8 @@ clean: # Build the package and generate bytecode build: sui move build - cp build/example/bytecode_modules/token.mv . - cp build/example/bytecode_modules/connected.mv . + cp build/example/bytecode_modules/token.mv ../token.mv + cp build/example/bytecode_modules/connected.mv ../connected.mv # Help target help: diff --git a/e2e/contracts/sui/example/Move.lock b/e2e/contracts/sui/example/Move.lock index 8593c3c4da..066d6a7621 100644 --- a/e2e/contracts/sui/example/Move.lock +++ b/e2e/contracts/sui/example/Move.lock @@ -2,11 +2,10 @@ [move] version = 3 -manifest_digest = "795BC4DE1AC42C1015B85547951A89D7F9AD63EA50982960E095E815C560BFCC" -deps_digest = "397E6A9F7A624706DBDFEE056CE88391A15876868FD18A88504DA74EB458D697" +manifest_digest = "9AE1AA02EF00BB882BBF7AA642D0DDF8A788CB1C25ACA9667399B8001C02CF81" +deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C" dependencies = [ { id = "Bridge", name = "Bridge" }, - { id = "DeepBook", name = "DeepBook" }, { id = "MoveStdlib", name = "MoveStdlib" }, { id = "Sui", name = "Sui" }, { id = "SuiSystem", name = "SuiSystem" }, @@ -14,7 +13,7 @@ dependencies = [ [[move.package]] id = "Bridge" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "9c04e1840eb5", subdir = "crates/sui-framework/packages/bridge" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "fbb68879cbd1", subdir = "crates/sui-framework/packages/bridge" } dependencies = [ { id = "MoveStdlib", name = "MoveStdlib" }, @@ -22,22 +21,13 @@ dependencies = [ { id = "SuiSystem", name = "SuiSystem" }, ] -[[move.package]] -id = "DeepBook" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "9c04e1840eb5", subdir = "crates/sui-framework/packages/deepbook" } - -dependencies = [ - { id = "MoveStdlib", name = "MoveStdlib" }, - { id = "Sui", name = "Sui" }, -] - [[move.package]] id = "MoveStdlib" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "9c04e1840eb5", subdir = "crates/sui-framework/packages/move-stdlib" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "fbb68879cbd1", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] id = "Sui" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "9c04e1840eb5", subdir = "crates/sui-framework/packages/sui-framework" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "fbb68879cbd1", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ { id = "MoveStdlib", name = "MoveStdlib" }, @@ -45,7 +35,7 @@ dependencies = [ [[move.package]] id = "SuiSystem" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "9c04e1840eb5", subdir = "crates/sui-framework/packages/sui-system" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "fbb68879cbd1", subdir = "crates/sui-framework/packages/sui-system" } dependencies = [ { id = "MoveStdlib", name = "MoveStdlib" }, @@ -53,6 +43,6 @@ dependencies = [ ] [move.toolchain-version] -compiler-version = "1.45.0" +compiler-version = "1.47.0" edition = "2024.beta" flavor = "sui" diff --git a/e2e/contracts/sui/example/connected.mv b/e2e/contracts/sui/example/connected.mv deleted file mode 100644 index 9923fca1ff048f2501a9f4caafc750ecfda85b91..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 665 zcmbtSOODh)47FX~q^hSs%nUGMkHiTYR!9v(BP1A!nGKsLom4~UP=%5-G$&!rVYmPr zPQZ#4;sQ85AP#^ff8=LBmt6jQ=ZDh(;1FgsyC)vpm1VBBFU=SHiuRLun12&z?x!IC zOLUX(lEA}F%+TQiPw^Js2C@Kx6GZx7y_6v1~&*fgo%(qM{MLA zH0a|aM6XXWM60dNwbNcr&{zw`Da^o(fuIaBPNKGy6N8u&DxPVhn=ZXA)*pw^Q&Y<( zHiL-agHG!=TyIh=MzZO<-MVe6V(7})Z$jt$*JT%q>mt$b8a1SCi1sg@4||?|co?tr ze}sT&%8M6B$es>XTw5~|tFs*Da=es-EWp#4xDQ^Aet}-N(UV6yDrOa^#$C|I( +public entry fun on_call( in_coins: Coin, cetus_config: &mut GlobalConfig, - _pool: &mut Pool, + // Note: this pool type is hardcoded as and therefore causes type mismatch error in the + // fungible token withdrawAndCall test, where the SOURCE_COIN type is FAKE_USDC instead of TOKEN. + // Disabling the pool object for now is the easiest solution to allow the E2E tests to go through. + // _pool: &mut Pool, _cetus_partner: &mut Partner, _clock: &Clock, data: vector, diff --git a/e2e/contracts/sui/example/token.mv b/e2e/contracts/sui/example/token.mv deleted file mode 100644 index de339780214e484ce6f1e4b5a4309f3a235ccad2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 629 zcmbtSy>1gh5T2R+z1wvhCn;0Xf}lHz(xO6;#wnxYa$ZXZ_MWxg6E-hE!xPZ)8axd> zZ$QP|k+f;pl}0n)H!~W|H$Sd_I}HFOf+zn>ynHV2yy`xiU-%R4ckx005wr5ERQ{WM z4GWx+p$odCD-Z-o1_1~>vWt_Iqm_z4X~SKCc}EO+R0w2^MItvpM-XQvq8IZsw({J0 zAStve^h|2KAPdGSkj6>0AQT7W1iMp=R-;2KfB{ngmD6X$>M2n&#o5eHHKU`g;sK^= zDnN;`aRGwUk;fY|iJQq~-$g%~cOf_HCO7(KpSwP))y>;C@7*ee<}jqwve_4_ Date: Fri, 25 Apr 2025 17:49:19 -0500 Subject: [PATCH 2/6] create a unified function to create E2E tests WAC payload --- .../test_sui_token_withdraw_and_call.go | 21 +++----------- ...oken_withdraw_and_call_revert_with_call.go | 18 ++---------- e2e/e2etests/test_sui_withdraw_and_call.go | 29 ++++++------------- ..._sui_withdraw_and_call_revert_with_call.go | 18 ++---------- e2e/runner/sui.go | 20 +++++++++++++ 5 files changed, 37 insertions(+), 69 deletions(-) diff --git a/e2e/e2etests/test_sui_token_withdraw_and_call.go b/e2e/e2etests/test_sui_token_withdraw_and_call.go index c4fb36cc75..4af1225a20 100644 --- a/e2e/e2etests/test_sui_token_withdraw_and_call.go +++ b/e2e/e2etests/test_sui_token_withdraw_and_call.go @@ -1,7 +1,6 @@ package e2etests import ( - "encoding/hex" "math/big" "github.com/stretchr/testify/require" @@ -9,7 +8,6 @@ import ( "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" - "github.com/zeta-chain/node/pkg/contracts/sui" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) @@ -21,17 +19,7 @@ func TestSuiTokenWithdrawAndCall(r *runner.E2ERunner, args []string) { targetPackageID := r.SuiExample.PackageID.String() amount := utils.ParseBigInt(r, args[0]) - // Given example contract on_call function arguments - // only the CCTX's coinType (0x***::fake_usdc::FAKE_USDC) is needed, no additional arguments - argumentTypes := []string{} - objects := []string{ - r.SuiExample.GlobalConfigID.String(), - r.SuiExample.PartnerID.String(), - r.SuiExample.ClockID.String(), - } - - // Given sui address - // the example contract will just forward the withdrawn token to this address + // use the deployer address as on_call payload message signer, err := r.Account.SuiSigner() require.NoError(r, err, "get deployer signer") suiAddress := signer.Address() @@ -40,10 +28,9 @@ func TestSuiTokenWithdrawAndCall(r *runner.E2ERunner, args []string) { balanceBefore := r.SuiGetFungibleTokenBalance(suiAddress) calledCountBefore := r.SuiGetConnectedCalledCount() - // create the payload message - message, err := hex.DecodeString(suiAddress[2:]) // remove 0x prefix + // create the on_call payload + payloadOnCall, err := r.SuiCreateExampleWACPayload(suiAddress) require.NoError(r, err) - payload := sui.NewCallPayload(argumentTypes, objects, message) // ACT // approve both SUI gas budget token and fungible token ZRC20 @@ -54,7 +41,7 @@ func TestSuiTokenWithdrawAndCall(r *runner.E2ERunner, args []string) { tx := r.SuiWithdrawAndCallFungibleToken( targetPackageID, amount, - payload, + payloadOnCall, gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) r.Logger.EVMTransaction(*tx, "withdraw_and_call") diff --git a/e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go b/e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go index bbca16e746..5d6b3f86c2 100644 --- a/e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go +++ b/e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go @@ -1,7 +1,6 @@ package e2etests import ( - "encoding/hex" "math/big" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -10,7 +9,6 @@ import ( "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" - "github.com/zeta-chain/node/pkg/contracts/sui" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) @@ -25,18 +23,9 @@ func TestSuiTokenWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []strin targetPackageID := r.SuiExample.PackageID.String() amount := utils.ParseBigInt(r, args[0]) - // Given example contract on_call function arguments - // only the CCTX's coinType (0x***::fake_usdc::FAKE_USDC) is needed, no additional arguments - argumentTypes := []string{} - objects := []string{ - r.SuiExample.GlobalConfigID.String(), - r.SuiExample.PartnerID.String(), - r.SuiExample.ClockID.String(), - } - - // define an invalid address to cause 'on_call' failure + // create the payload for 'on_call' with invalid address invalidAddress := "8f569597ebca884b784d32678a6f" - message, err := hex.DecodeString(invalidAddress) + payloadOnCall, err := r.SuiCreateExampleWACPayload(invalidAddress) require.NoError(r, err) // given ZEVM revert address (the dApp) @@ -48,9 +37,6 @@ func TestSuiTokenWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []strin payloadOnRevert := randomPayload(r) r.AssertTestDAppEVMCalled(false, payloadOnRevert, amount) - // create the payload for 'on_call' - payloadOnCall := sui.NewCallPayload(argumentTypes, objects, message) - // ACT // approve both SUI gas budget token and fungible token ZRC20 r.ApproveSUIZRC20(r.GatewayZEVMAddr) diff --git a/e2e/e2etests/test_sui_withdraw_and_call.go b/e2e/e2etests/test_sui_withdraw_and_call.go index 1cba71b4ff..484806dd12 100644 --- a/e2e/e2etests/test_sui_withdraw_and_call.go +++ b/e2e/e2etests/test_sui_withdraw_and_call.go @@ -1,7 +1,6 @@ package e2etests import ( - "encoding/hex" "math/big" "github.com/stretchr/testify/require" @@ -9,7 +8,6 @@ import ( "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" - "github.com/zeta-chain/node/pkg/contracts/sui" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) @@ -21,27 +19,18 @@ func TestSuiWithdrawAndCall(r *runner.E2ERunner, args []string) { targetPackageID := r.SuiExample.PackageID.String() amount := utils.ParseBigInt(r, args[0]) - // Given example contract on_call function arguments - // only the CCTX's coinType (0x02::sui::SUI) is needed, no additional arguments - argumentTypes := []string{} - objects := []string{ - r.SuiExample.GlobalConfigID.String(), - r.SuiExample.PartnerID.String(), - r.SuiExample.ClockID.String(), - } + // use the deployer address as on_call payload message + signer, err := r.Account.SuiSigner() + require.NoError(r, err, "get deployer signer") + suiAddress := signer.Address() - // define a deterministic address and use it for on_call payload message - // the example contract will just forward the withdrawn SUI token to this address - suiAddress := "0x34a30aaee833d649d7313ddfe4ff5b6a9bac48803236b919369e6636fe93392e" - message, err := hex.DecodeString(suiAddress[2:]) // remove 0x prefix - require.NoError(r, err) + // Given initial balance and called_count balanceBefore := r.SuiGetSUIBalance(suiAddress) - - // query the called_count before withdraw and call calledCountBefore := r.SuiGetConnectedCalledCount() - // create the payload - payload := sui.NewCallPayload(argumentTypes, objects, message) + // create the on_call payload + payloadOnCall, err := r.SuiCreateExampleWACPayload(suiAddress) + require.NoError(r, err) // ACT // approve SUI ZRC20 token @@ -51,7 +40,7 @@ func TestSuiWithdrawAndCall(r *runner.E2ERunner, args []string) { tx := r.SuiWithdrawAndCallSUI( targetPackageID, amount, - payload, + payloadOnCall, gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) r.Logger.EVMTransaction(*tx, "withdraw_and_call") diff --git a/e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go b/e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go index ffb4950433..9d8d1a3dbd 100644 --- a/e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go +++ b/e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go @@ -1,7 +1,6 @@ package e2etests import ( - "encoding/hex" "math/big" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -10,7 +9,6 @@ import ( "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" - "github.com/zeta-chain/node/pkg/contracts/sui" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) @@ -25,18 +23,9 @@ func TestSuiWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string) { targetPackageID := r.SuiExample.PackageID.String() amount := utils.ParseBigInt(r, args[0]) - // Given example contract on_call function arguments - // only the CCTX's coinType (0x02::sui::SUI) is needed, no additional arguments - argumentTypes := []string{} - objects := []string{ - r.SuiExample.GlobalConfigID.String(), - r.SuiExample.PartnerID.String(), - r.SuiExample.ClockID.String(), - } - - // define an invalid address to cause 'on_call' failure + // create the payload for 'on_call' with invalid address invalidAddress := "8f569597ebca884b784d32678a6f" - message, err := hex.DecodeString(invalidAddress) + payloadOnCall, err := r.SuiCreateExampleWACPayload(invalidAddress) require.NoError(r, err) // given ZEVM revert address (the dApp) @@ -48,9 +37,6 @@ func TestSuiWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string) { payloadOnRevert := randomPayload(r) r.AssertTestDAppEVMCalled(false, payloadOnRevert, amount) - // create the payload for 'on_call' - payloadOnCall := sui.NewCallPayload(argumentTypes, objects, message) - // ACT // approve SUI ZRC20 token r.ApproveSUIZRC20(r.GatewayZEVMAddr) diff --git a/e2e/runner/sui.go b/e2e/runner/sui.go index a65c76074e..d17298dded 100644 --- a/e2e/runner/sui.go +++ b/e2e/runner/sui.go @@ -238,6 +238,26 @@ func (r *E2ERunner) SuiMintUSDC( return r.suiExecuteTx(signer, tx) } +// SuiCreateExampleWACPayload creates a payload for on_call function in Sui the example package +// The example on_call function will just forward the withdrawn token to given 'suiAddress' +func (r *E2ERunner) SuiCreateExampleWACPayload(suiAddress string) (sui.CallPayload, error) { + // only the CCTX's coinType is needed, no additional arguments + argumentTypes := []string{} + objects := []string{ + r.SuiExample.GlobalConfigID.String(), + r.SuiExample.PartnerID.String(), + r.SuiExample.ClockID.String(), + } + + // create the payload message from the sui address + message, err := hex.DecodeString(suiAddress[2:]) // remove 0x prefix + if err != nil { + return sui.CallPayload{}, err + } + + return sui.NewCallPayload(argumentTypes, objects, message), nil +} + // SuiGetConnectedCalledCount reads the called_count from the GlobalConfig object in connected module func (r *E2ERunner) SuiGetConnectedCalledCount() uint64 { // Get object data From f629d8a7d607866d92b79ea97524609afb55c2f1 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Fri, 25 Apr 2025 17:55:37 -0500 Subject: [PATCH 3/6] add sui token withdraw and call E2E tests --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 130ca286c2..884592af48 100644 --- a/changelog.md +++ b/changelog.md @@ -41,6 +41,7 @@ ### Tests * [3692](https://github.com/zeta-chain/node/pull/3692) - e2e staking test for `MsgUndelegate` tx, to test observer staking hooks +* [3831](https://github.com/zeta-chain/node/pull/3831) - e2e tests for sui fungible token withdraw and call ### Refactor From 0d770b1b3693d9f30f74c25452bb4e943dff7f35 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Mon, 28 Apr 2025 15:30:55 -0500 Subject: [PATCH 4/6] try consolidating #gosec G101 comments in e2e tests --- e2e/e2etests/e2etests.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index d71c24e7f0..9c2290737b 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -95,19 +95,20 @@ const ( /* Sui tests */ + // #nosec G101: Potential hardcoded credentials (gosec), not a credential TestSuiDepositName = "sui_deposit" TestSuiDepositAndCallName = "sui_deposit_and_call" TestSuiDepositAndCallRevertName = "sui_deposit_and_call_revert" - TestSuiTokenDepositName = "sui_token_deposit" // #nosec G101: Potential hardcoded credentials (gosec), not a credential - TestSuiTokenDepositAndCallName = "sui_token_deposit_and_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential - TestSuiTokenDepositAndCallRevertName = "sui_token_deposit_and_call_revert" // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestSuiTokenDepositName = "sui_token_deposit" + TestSuiTokenDepositAndCallName = "sui_token_deposit_and_call" + TestSuiTokenDepositAndCallRevertName = "sui_token_deposit_and_call_revert" TestSuiWithdrawName = "sui_withdraw" - TestSuiTokenWithdrawName = "sui_token_withdraw" // #nosec G101: Potential hardcoded credentials (gosec), not a credential - TestSuiTokenWithdrawAndCallName = "sui_token_withdraw_and_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential - TestSuiTokenWithdrawAndCallRevertWithCallName = "sui_token_withdraw_and_call_revert_with_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestSuiTokenWithdrawName = "sui_token_withdraw" + TestSuiTokenWithdrawAndCallName = "sui_token_withdraw_and_call" + TestSuiTokenWithdrawAndCallRevertWithCallName = "sui_token_withdraw_and_call_revert_with_call" TestSuiWithdrawAndCallName = "sui_withdraw_and_call" - TestSuiWithdrawRevertWithCallName = "sui_withdraw_revert_with_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential - TestSuiWithdrawAndCallRevertWithCallName = "sui_withdraw_and_call_revert_with_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestSuiWithdrawRevertWithCallName = "sui_withdraw_revert_with_call" + TestSuiWithdrawAndCallRevertWithCallName = "sui_withdraw_and_call_revert_with_call" TestSuiDepositRestrictedName = "sui_deposit_restricted" TestSuiWithdrawRestrictedName = "sui_withdraw_restricted" From 5f5b8bd731c67c4436a735858835420d7928c1d2 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Mon, 28 Apr 2025 15:43:20 -0500 Subject: [PATCH 5/6] add #gosec G101 back because one single comment won't apply for all test names --- e2e/e2etests/e2etests.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 9c2290737b..d71c24e7f0 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -95,20 +95,19 @@ const ( /* Sui tests */ - // #nosec G101: Potential hardcoded credentials (gosec), not a credential TestSuiDepositName = "sui_deposit" TestSuiDepositAndCallName = "sui_deposit_and_call" TestSuiDepositAndCallRevertName = "sui_deposit_and_call_revert" - TestSuiTokenDepositName = "sui_token_deposit" - TestSuiTokenDepositAndCallName = "sui_token_deposit_and_call" - TestSuiTokenDepositAndCallRevertName = "sui_token_deposit_and_call_revert" + TestSuiTokenDepositName = "sui_token_deposit" // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestSuiTokenDepositAndCallName = "sui_token_deposit_and_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestSuiTokenDepositAndCallRevertName = "sui_token_deposit_and_call_revert" // #nosec G101: Potential hardcoded credentials (gosec), not a credential TestSuiWithdrawName = "sui_withdraw" - TestSuiTokenWithdrawName = "sui_token_withdraw" - TestSuiTokenWithdrawAndCallName = "sui_token_withdraw_and_call" - TestSuiTokenWithdrawAndCallRevertWithCallName = "sui_token_withdraw_and_call_revert_with_call" + TestSuiTokenWithdrawName = "sui_token_withdraw" // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestSuiTokenWithdrawAndCallName = "sui_token_withdraw_and_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestSuiTokenWithdrawAndCallRevertWithCallName = "sui_token_withdraw_and_call_revert_with_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential TestSuiWithdrawAndCallName = "sui_withdraw_and_call" - TestSuiWithdrawRevertWithCallName = "sui_withdraw_revert_with_call" - TestSuiWithdrawAndCallRevertWithCallName = "sui_withdraw_and_call_revert_with_call" + TestSuiWithdrawRevertWithCallName = "sui_withdraw_revert_with_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestSuiWithdrawAndCallRevertWithCallName = "sui_withdraw_and_call_revert_with_call" // #nosec G101: Potential hardcoded credentials (gosec), not a credential TestSuiDepositRestrictedName = "sui_deposit_restricted" TestSuiWithdrawRestrictedName = "sui_withdraw_restricted" From 1c067b999a2e51d58384f0b3227ef73daea2e868 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Mon, 28 Apr 2025 16:32:18 -0500 Subject: [PATCH 6/6] remove hardcoded invalid sui payload message as long as it replicate execution error --- .../test_sui_token_withdraw_and_call_revert_with_call.go | 4 +++- e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go b/e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go index 5d6b3f86c2..82fdb0ae6d 100644 --- a/e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go +++ b/e2e/e2etests/test_sui_token_withdraw_and_call_revert_with_call.go @@ -9,6 +9,7 @@ import ( "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" + "github.com/zeta-chain/node/testutil/sample" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) @@ -24,7 +25,8 @@ func TestSuiTokenWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []strin amount := utils.ParseBigInt(r, args[0]) // create the payload for 'on_call' with invalid address - invalidAddress := "8f569597ebca884b784d32678a6f" + // taking the first 10 letters to form an invalid address + invalidAddress := sample.SuiAddress(r)[:10] payloadOnCall, err := r.SuiCreateExampleWACPayload(invalidAddress) require.NoError(r, err) diff --git a/e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go b/e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go index 9d8d1a3dbd..ee0bd41e19 100644 --- a/e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go +++ b/e2e/e2etests/test_sui_withdraw_and_call_revert_with_call.go @@ -9,6 +9,7 @@ import ( "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" + "github.com/zeta-chain/node/testutil/sample" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) @@ -24,7 +25,8 @@ func TestSuiWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string) { amount := utils.ParseBigInt(r, args[0]) // create the payload for 'on_call' with invalid address - invalidAddress := "8f569597ebca884b784d32678a6f" + // taking the first 10 letters to form an invalid address + invalidAddress := sample.SuiAddress(r)[:10] payloadOnCall, err := r.SuiCreateExampleWACPayload(invalidAddress) require.NoError(r, err)