@@ -32,6 +32,9 @@ const wallet = Wallet.fromMnemonic(mnemonic).connect(provider);
3232const network : CurrencyTypes . EvmChainName = 'sepolia' ;
3333const erc20ContractAddress = '0x9FBDa871d559710256a2502A2517b794B482Db40' ;
3434
35+ // Get the real wrapper address from the deployed contract
36+ const wrapperAddress = getCommerceEscrowWrapperAddress ( network ) ;
37+
3538const mockAuthorizeParams : AuthorizePaymentParams = {
3639 paymentReference : '0x0123456789abcdef' ,
3740 payer : wallet . address ,
@@ -75,7 +78,9 @@ describe('erc20-commerce-escrow-wrapper', () => {
7578 describe ( 'getCommerceEscrowWrapperAddress' , ( ) => {
7679 it ( 'should return address when wrapper is deployed on testnet' , ( ) => {
7780 const address = getCommerceEscrowWrapperAddress ( network ) ;
78- expect ( address ) . toBe ( '0x1234567890123456789012345678901234567890' ) ;
81+ // Verify it returns a valid Ethereum address
82+ expect ( address ) . toMatch ( / ^ 0 x [ 0 - 9 a - f A - F ] { 40 } $ / ) ;
83+ expect ( address ) . not . toBe ( '0x0000000000000000000000000000000000000000' ) ;
7984 } ) ;
8085
8186 it ( 'should throw when wrapper not found on mainnet' , ( ) => {
@@ -91,19 +96,12 @@ describe('erc20-commerce-escrow-wrapper', () => {
9196 } ) . toThrow ( 'No deployment for network: unsupported-network.' ) ;
9297 } ) ;
9398
94- it ( 'should return different addresses for different supported networks ' , ( ) => {
99+ it ( 'should return a valid address for sepolia network ' , ( ) => {
95100 const sepoliaAddress = getCommerceEscrowWrapperAddress ( 'sepolia' ) ;
96- const goerliAddress = getCommerceEscrowWrapperAddress ( 'goerli' ) ;
97- const mumbaiAddress = getCommerceEscrowWrapperAddress ( 'mumbai' ) ;
98-
99- // Verify all addresses are valid hex-formatted addresses
100- [ sepoliaAddress , goerliAddress , mumbaiAddress ] . forEach ( ( addr ) => {
101- expect ( addr ) . toMatch ( / ^ 0 x [ 0 - 9 a - f A - F ] { 40 } $ / ) ;
102- expect ( addr ) . not . toBe ( '0x0000000000000000000000000000000000000000' ) ;
103- } ) ;
104101
105- // Verify all addresses are different
106- expect ( new Set ( [ sepoliaAddress , goerliAddress , mumbaiAddress ] ) . size ) . toBe ( 3 ) ;
102+ // Verify the address is valid hex-formatted address
103+ expect ( sepoliaAddress ) . toMatch ( / ^ 0 x [ 0 - 9 a - f A - F ] { 40 } $ / ) ;
104+ expect ( sepoliaAddress ) . not . toBe ( '0x0000000000000000000000000000000000000000' ) ;
107105 } ) ;
108106 } ) ;
109107
@@ -226,7 +224,7 @@ describe('erc20-commerce-escrow-wrapper', () => {
226224 expect ( result ) . toBe ( '1000000000000000000' ) ;
227225 expect ( mockGetErc20Allowance ) . toHaveBeenCalledWith (
228226 wallet . address ,
229- '0x1234567890123456789012345678901234567890' , // wrapper address
227+ wrapperAddress , // real wrapper address from deployment
230228 provider ,
231229 erc20ContractAddress ,
232230 ) ;
@@ -631,7 +629,7 @@ describe('erc20-commerce-escrow-wrapper', () => {
631629 } ) ;
632630
633631 expect ( wallet . sendTransaction ) . toHaveBeenCalledWith ( {
634- to : '0x1234567890123456789012345678901234567890' ,
632+ to : wrapperAddress ,
635633 data : expect . stringMatching ( / ^ 0 x [ a - f A - F 0 - 9 ] + $ / ) ,
636634 value : 0 ,
637635 } ) ;
@@ -648,7 +646,7 @@ describe('erc20-commerce-escrow-wrapper', () => {
648646 } ) ;
649647
650648 expect ( wallet . sendTransaction ) . toHaveBeenCalledWith ( {
651- to : '0x1234567890123456789012345678901234567890' ,
649+ to : wrapperAddress ,
652650 data : expect . stringMatching ( / ^ 0 x [ a - f A - F 0 - 9 ] + $ / ) ,
653651 value : 0 ,
654652 } ) ;
@@ -665,7 +663,7 @@ describe('erc20-commerce-escrow-wrapper', () => {
665663 } ) ;
666664
667665 expect ( wallet . sendTransaction ) . toHaveBeenCalledWith ( {
668- to : '0x1234567890123456789012345678901234567890' ,
666+ to : wrapperAddress ,
669667 data : expect . stringMatching ( / ^ 0 x [ a - f A - F 0 - 9 ] + $ / ) ,
670668 value : 0 ,
671669 } ) ;
@@ -682,7 +680,7 @@ describe('erc20-commerce-escrow-wrapper', () => {
682680 } ) ;
683681
684682 expect ( wallet . sendTransaction ) . toHaveBeenCalledWith ( {
685- to : '0x1234567890123456789012345678901234567890' ,
683+ to : wrapperAddress ,
686684 data : expect . stringMatching ( / ^ 0 x [ a - f A - F 0 - 9 ] + $ / ) ,
687685 value : 0 ,
688686 } ) ;
@@ -699,7 +697,7 @@ describe('erc20-commerce-escrow-wrapper', () => {
699697 } ) ;
700698
701699 expect ( wallet . sendTransaction ) . toHaveBeenCalledWith ( {
702- to : '0x1234567890123456789012345678901234567890' ,
700+ to : wrapperAddress ,
703701 data : expect . stringMatching ( / ^ 0 x [ a - f A - F 0 - 9 ] + $ / ) ,
704702 value : 0 ,
705703 } ) ;
@@ -716,7 +714,7 @@ describe('erc20-commerce-escrow-wrapper', () => {
716714 } ) ;
717715
718716 expect ( wallet . sendTransaction ) . toHaveBeenCalledWith ( {
719- to : '0x1234567890123456789012345678901234567890' ,
717+ to : wrapperAddress ,
720718 data : expect . stringMatching ( / ^ 0 x [ a - f A - F 0 - 9 ] + $ / ) ,
721719 value : 0 ,
722720 } ) ;
0 commit comments