I got two questions :
First :
I have some custom error type declared in the smart contract and I want to check the appropriate error to be returned from the function call , I wonder how can I get the response ?
For example :
#[msg("Username length should not exceed 100 characters")]
PhoneNumberLengthExceeded,
And I have this test :
await program.methods.signUp("sajjad", "09146979106555555555", "").accounts({
user: secondUser.publicKey,
authority: provider.wallet.publicKey,
systemProgram: SystemProgram.programId,
clock: anchor.web3.SYSVAR_CLOCK_PUBKEY,
}).signers([secondUser]).rpc({ skipPreflight: true });
which throws PhoneNumberLengthExceeded and messes up the test .
Second how can I write tests for the build in errors ?
which is thrown for example when the second user is being created with the first user Keypair which is obvious .