@@ -7,6 +7,7 @@ import evmSwap from "../../lib/abis/evmSwap";
77import { decodeEventLog } from "viem" ;
88
99const evmSwapPrecompileAddress = "0x0000000000000000000000000000000000000901" ;
10+ const bridgePotEvmAddress = "0x6d6f646c686d63732f656e310000000000000000" ;
1011
1112describe ( "evm to native tokens swap" , ( ) => {
1213 let node : RunNodeState ;
@@ -28,6 +29,13 @@ describe("evm to native tokens swap", () => {
2829 const targetNativeAccount =
2930 "0x7700000000000000000000000000000000000000000000000000000000000077" ;
3031
32+ const aliceBalanceBefore = await publicClient . getBalance ( {
33+ address : alice . account . address ,
34+ } ) ;
35+ const bridgePotEvmAddressBalanceBefore = await publicClient . getBalance ( {
36+ address : bridgePotEvmAddress ,
37+ } ) ;
38+
3139 const swapTxHash = await alice . writeContract ( {
3240 abi : evmSwap . abi ,
3341 address : evmSwapPrecompileAddress ,
@@ -59,5 +67,22 @@ describe("evm to native tokens swap", () => {
5967 value : swapBalance ,
6068 } ,
6169 } ) ;
70+
71+ const fee = swapTxReceipt . cumulativeGasUsed * swapTxReceipt . effectiveGasPrice ;
72+
73+ const aliceBalanceAfter = await publicClient . getBalance ( {
74+ address : alice . account . address ,
75+ } ) ;
76+ expect ( aliceBalanceAfter ) . toEqual ( aliceBalanceBefore - swapBalance - fee ) ;
77+
78+ const bridgePotEvmAddressBalanceAfter = await publicClient . getBalance ( {
79+ address : bridgePotEvmAddress ,
80+ } ) ;
81+ expect ( bridgePotEvmAddressBalanceAfter ) . toEqual ( bridgePotEvmAddressBalanceBefore + swapBalance + fee ) ;
82+
83+ const evmSwapPrecompileBalance = await publicClient . getBalance ( {
84+ address : evmSwapPrecompileAddress ,
85+ } ) ;
86+ expect ( evmSwapPrecompileBalance ) . toEqual ( 0n ) ;
6287 } ) ;
6388} ) ;
0 commit comments