Let’s Write More Tests
Explore how to write comprehensive tests for Solidity smart contracts, including creating and verifying creator and applicant profiles, job postings, and job applications. Understand account context switching and key Solidity concepts like msg.sender and tx.origin to ensure reliable contract behavior. Practice extending tests to cover application approval and rejection to deepen your development skills in building secure Ethereum dApps.
Let’s continue by writing more test cases. Specifically, we’ll test creator and applicant profile creation, job creation, and application. For practice, we recommend testing further for application approval and rejection.
Writing the tests
Let’s write a test to check how our creator profile creation works.
Testing the creator profile function
Copy and paste the test case code below into your project:
Line 6: We import
remix_accounts.sol, a library to help us switch account contexts.Line 12: We introduce a custom transaction context for the sender account used when initializing the contract. We use the first account as the manager. Currently, we can only set custom context values for
senderandvalue. We do this using the NatSpec comment format: Three forward slashes (///) followed by the parameter key prefixed with a hash (#), ending with a colon and space (: ). For example, if we want to send a value of 20 ...