@@ -10,6 +10,8 @@ test.describe('Basename Registration', () => {
1010 metamask,
1111 node,
1212 } ) => {
13+ test . setTimeout ( 120000 ) ; // Increase timeout to 2 minutes
14+
1315 // Validate prerequisites
1416 if ( ! metamask ) {
1517 throw new Error ( 'MetaMask is not defined' ) ;
@@ -22,21 +24,54 @@ test.describe('Basename Registration', () => {
2224 // Common preparation steps (wallet needs funds to connect)
2325 const { mainPage } = await prepareBasenameFlow ( page , metamask ) ;
2426
27+ // Add a small delay to ensure everything is stable
28+ console . log ( '[test] Waiting for network to stabilize...' ) ;
29+ await mainPage . waitForTimeout ( 2000 ) ;
30+
2531 // Get the first default wallet address from Anvil (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
26- const walletAddress = ( await node . getAccounts ( ) ) [ 0 ] ;
27- console . log ( '[test] Using default Anvil wallet address:' , walletAddress ) ;
32+ let walletAddress ;
33+ try {
34+ const accounts = await node . getAccounts ( ) ;
35+ walletAddress = accounts [ 0 ] ;
36+ console . log ( '[test] Using default Anvil wallet address:' , walletAddress ) ;
37+ } catch ( error ) {
38+ console . error ( '[test] Failed to get accounts:' , error ) ;
39+ throw error ;
40+ }
41+
42+ // Set wallet balance to a tiny amount - enough for RPC calls but not for registration
43+ // Registration costs around 0.002 ETH, so 0.0001 ETH should be insufficient
44+ const insufficientBalance = BigInt ( '100000000000000' ) ; // 0.0001 ETH in wei
2845
29- // NOW set wallet balance to 0 after connection is established
30- await node . setBalance ( walletAddress , 0n ) ;
31- console . log ( '[test] Set wallet balance to 0' ) ;
46+ try {
47+ console . log ( '[test] About to set balance...' ) ;
48+ await node . setBalance ( walletAddress , insufficientBalance ) ;
49+ console . log ( '[test] Set wallet balance to 0.0001 ETH (insufficient for registration)' ) ;
50+ } catch ( error ) {
51+ console . error ( '[test] Failed to set balance:' , error ) ;
52+ throw error ;
53+ }
54+
55+ // Another small delay after balance change
56+ await mainPage . waitForTimeout ( 1000 ) ;
3257
3358 // Attempt registration with no funds
34- await initiateRegistration ( mainPage ) ;
35- await page . waitForLoadState ( 'networkidle' ) ;
59+ try {
60+ await initiateRegistration ( mainPage ) ;
61+ await page . waitForLoadState ( 'networkidle' ) ;
62+ } catch ( error ) {
63+ console . error ( '[test] Failed to initiate registration:' , error ) ;
64+ throw error ;
65+ }
3666
3767 // Approve the transaction (it should fail due to insufficient funds)
38- await handleTransaction ( metamask , ActionApprovalType . APPROVE ) ;
39- await page . waitForLoadState ( 'networkidle' ) ;
68+ try {
69+ await handleTransaction ( metamask , ActionApprovalType . APPROVE ) ;
70+ await page . waitForLoadState ( 'networkidle' ) ;
71+ } catch ( error ) {
72+ console . error ( '[test] Failed to handle transaction:' , error ) ;
73+ throw error ;
74+ }
4075
4176 // Look for failure message
4277 await expect ( page . getByText ( / f a i l e d | r e j e c t e d | i n s u f f i c i e n t / i) ) . toBeVisible ( { timeout : 30000 } ) ;
0 commit comments