From 76738bc0a60144ea94167c4c781ad0f040729a63 Mon Sep 17 00:00:00 2001 From: Lucas Willems Date: Sat, 14 Dec 2024 12:24:27 +0100 Subject: [PATCH] Add test for SC transferring ESDT to non-existing account --- .../output-reproducible/world/world.wasm | Bin 7527 -> 8198 bytes xsuite/contracts/world/src/lib.rs | 7 ++++++ xsuite/src/world/fsworld.test.ts | 22 +++++++++++++++++ xsuite/src/world/lsworld.test.ts | 23 ++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/xsuite/contracts/output-reproducible/world/world.wasm b/xsuite/contracts/output-reproducible/world/world.wasm index 88f445cc342921061fd013f7a562548ce616f85a..f0ac1a9c3b99a80a08027e8cb0fa3d6c800a4ba0 100755 GIT binary patch literal 8198 zcmb7JTWn;>S*}y(boXf=dtBr3dOc%@t?r!=JK4$HcJ09#h);X$*~D|pcy^btKu=Hm zOuO6dZf{>a>#SruJELWQYzRb(!~+jJgq4s0A%PGgAf6CH3YP>#9s>vkM0n!?p=g)y zt2(Ey2qB!ej@=gGwzDs8%Y8hAvyT@%gtJEodfq<% zIJ_rryQa%$GJrO>RmMt$eQ0 zS&KS&&b=sn0<#tvuCI$M--C9w(kRuJTdihGNJ56T3f;SRqt>pEcGOrG z=|R{^wNY(v2#>Idtx}^@iPo1|QK=J!?cGLssZ_6v5e|+WLQ>f6L~Sv|fqcB`YPa60 z-fEQ^ZS1|gcIno&m0QbiM&)iN62k_ArTlW#A=Xz*^=>2_4ot@wFk+B!@gq}IygQ~` zi5itoOz~K}a&15c2Ia9z)VbE(BBq3-wiQOg2QY=LN_Q)2bgV?C+FKwClE%m@4N5gy z@69+uI!7(i1Q;Vc-lv{K-zk+hm+H-Sw-s|Y8j}t+4oGdXzv_CcTB$;Xx88iY1XWo2 z`}}gzTD@A1L_i{r$0IAP=2pSjM?$P+BjInY(`-SRSDK|*;T6jyJS2bS!!K>;tk=MfCTnk1x1x5Zw6)!b-)KcUkK*P09((}zA@~6P zX9nj#vd2VXCyy{XN(QE4Mi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p|rZ6y!I*;?f_sDqac* zGoN|qxL!(~-BM3SLU;{dEbRb~thHr7Fp%v4@U7H&=Y1UR%MN|8dSKmVxHvKf;K@N) zBCzYF>ehp&h=wW}Y?Iv)h>ejV-os=KE=d+jq;(3m7~|`2|Dk#_51qhPFWhB=DNcSx zZi0ZPeS6i@l$G$9t#08~*eSOV_7ABqjSPlB0-{$;_Ul(`gYX0j8C8!H zbms=dFg{ILPQK!PTz1NCgoq882hFx_So9JONkD%O=$oLO3jH!@vWxhy7(O%fPadN0 zfUd6W`8DX;WM%R@OzMc%6LnpDSbwALSfaNQMjiT{x~2{1OyP}5;6o{ZI&~DcI0uj{ za(ehS=+pHZ_<)|P&$J9M@4gW6sQl*PHB^5pmU38sufDK8 zYAU8Kv}Y-OEO->hw>E5Q$gicINj@0h1p3=eLH!Zqs3SAvt0;|xzTOaol@K>}$AL37 z4I52^$=y`br`NJXt?s0C5wWAO=jywES&t&M89nlboqXWZk$4h8jQybXZp zhd|4rEVM@Wa(U9YU#P@sl!n{L$21Bh0)`4DQ$IsSTWuy9)QecGHY8;=N&~#%ixS*` z(CpH`X*}P(Y1J!V7s6e88ARF%Hz1Bbmu)zITOd&2ExFeOKZX9$=B}MorlLlUhm*?8 z1Tndf;tf6A1q0oKxajPZ`8)N^=Ft$LN|PPb+AE2&9lNO8dF?1mA3|W9hb2Hxr`t2~ z)A*QXhGKLb!ODfN&x&8B{Y@WlGHQ0MOdxhc{bFG72j9Ki-$Jj2s+)SSA5yyXd9igoO3x&66*E!Wv{A1qJU5^$v^Pc~OX;!MpG~ z@Kg@3t`G%9y?~xtO;51g8gSI6qIf_9qIf{Vr+5Gi6bvE?E)fOS?*B^+F897~+l<<& zC*J4!yBiMc`y1}0KDg$3oZ}7jjO$(3uWiige{D?bt*t})Y5ecC?nvM{ (BigUint, MultiEsdtPayment) { let BackTransfers { total_egld_amount, esdt_payments } = self.blockchain().get_back_transfers(); diff --git a/xsuite/src/world/fsworld.test.ts b/xsuite/src/world/fsworld.test.ts index 689b7e17..56c2ac4e 100644 --- a/xsuite/src/world/fsworld.test.ts +++ b/xsuite/src/world/fsworld.test.ts @@ -1097,6 +1097,28 @@ test.concurrent("FSWallet.callContract - change the state", async () => { }); }); +test.concurrent( + "FSWallet.callContract - transfer ESDT to non-existent account", + async () => { + using world = await FSWorld.start(); + const { wallet, contract } = await createAccounts(world); + const nonExistentWallet = world.newWallet(createAddressLike("wallet")); + await wallet.callContract({ + callee: contract, + funcName: "transfer_received", + funcArgs: [nonExistentWallet], + esdts: [{ id: fftId, amount: 10n ** 17n }], + gasLimit: 10_000_000, + }); + assertAccount(await wallet.getAccount(), { + hasKvs: { esdts: [{ id: fftId, amount: 9n * 10n ** 17n }] }, + }); + assertAccount(await nonExistentWallet.getAccount(), { + hasKvs: { esdts: [{ id: fftId, amount: 10n ** 17n }] }, + }); + }, +); + test.concurrent( "FSWallet.callContract - succeeding async call v2", async () => { diff --git a/xsuite/src/world/lsworld.test.ts b/xsuite/src/world/lsworld.test.ts index acb3305e..a60ad657 100644 --- a/xsuite/src/world/lsworld.test.ts +++ b/xsuite/src/world/lsworld.test.ts @@ -1099,6 +1099,29 @@ test.concurrent("LSWallet.callContract - change the state", async () => { }); }); +// TODO-MvX: To run once Mandos is fixed +test.todo( + "LSWallet.callContract - transfer ESDT to non-existent account", + async () => { + using world = await LSWorld.start(); + const { wallet, contract } = await createAccounts(world); + const nonExistentWallet = world.newWallet(createAddressLike("wallet")); + await wallet.callContract({ + callee: contract, + funcName: "transfer_received", + funcArgs: [nonExistentWallet], + esdts: [{ id: fftId, amount: 10n ** 17n }], + gasLimit: 10_000_000, + }); + assertAccount(await wallet.getAccount(), { + hasKvs: { esdts: [{ id: fftId, amount: 9n * 10n ** 17n }] }, + }); + assertAccount(await nonExistentWallet.getAccount(), { + hasKvs: { esdts: [{ id: fftId, amount: 10n ** 17n }] }, + }); + }, +); + test.concurrent("LSWallet.callContract - failure", async () => { using world = await LSWorld.start(); const { wallet, contract } = await createAccounts(world);