Skip to content

Commit 0503d41

Browse files
committed
Add the final quiz....finally
1 parent 98f2170 commit 0503d41

File tree

2 files changed

+156
-22
lines changed

2 files changed

+156
-22
lines changed

pages/lessons/projects/4.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Here you'll:
2222
- Walk away with many practical tests for smart contracts
2323
- Nibble on some food for thought about test-driven development
2424

25-
<SideDrawer buttonText="Warm-up Questions" title="Some previous knowledge, some prediction">
25+
<SideDrawer buttonText="Warm-up Questions" title="Check out Your Previous Knowledge">
2626
<Question question="lesson-4/1-intro/Q1" />
2727
<Question question="lesson-4/1-intro/Q2" />
2828
<Question question="lesson-4/1-intro/Q3" />
@@ -61,13 +61,10 @@ you have all the Hardhat dependencies installed.
6161
Otherwise let's create a new Hardhat project and copy in the contract which
6262
we'll be testing.
6363

64-
{/* DO WE NEED TO MAKE SURE WE HAVE THE MOST RECENT VERSION OF NPM? LET'S SEE IF THERE'S IMPROVEMENT */}
65-
6664
To create a new project, please refer to _Lesson 3 - Tier NFTs_ and search for
6765
the “First things first 👷‍♂️" section to get your project going. Follow the steps
6866
until "Let’s start coding”, then open up your code editor.
6967

70-
{/* AND DO WE NEED TO ENSURE LEARNERS ACTUALLY FINISH ALL THE STEPS IN LESSON 3 FOR hardhat configurations, deployment variables, etc */}
7168

7269
_If you are using VSCode, type `code .` in your terminal to open VSCode._
7370

@@ -945,17 +942,19 @@ With TDD:
945942
Bolting on tests after the fact can be painful and boring, and you lose the
946943
potential code improvements you can make when you test as you go.
947944

948-
<br/>
945+
<br/><br/>
949946
<Quiz quiz="lesson-4-quiz" />
950-
<br/>
947+
<br/><br/>
951948

952949
Go forth, test, and prosper knowing you have confidence in the code you're
953950
deploying into the world.
954951

955952
import { ContributorFooter } from '../../../components/mdx/ContributorFooter'
956953

954+
957955
<ContributorFooter
958956
authors={['brianfive']}
959957
reviewers={['piablo', 'georgemac510']}
960-
contributors={[]}
958+
contributors={[]}
961959
/>
960+

utils/quizzes/lesson-4-quiz.json

Lines changed: 150 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
{
22
"title": "Quiz: Lesson 4",
33
"questions": [
4+
{
5+
"question": "Choose those which automated testing of smart contracts can help achieve?",
6+
"options": [
7+
{
8+
"answer": "Faster development and deployment process."
9+
},
10+
{
11+
"answer": "Finding every possible bug and vulnerability."
12+
},
13+
{
14+
"answer": "Improving the overall code quality.",
15+
"correct": true
16+
},
17+
{
18+
"answer": "Ensuring the smart contract is free of errors.",
19+
"correct": true
20+
}
21+
]
22+
},
423
{
524
"question": "Which testing approach is recommended for ensuring a secure smart contract?",
625
"options": [
@@ -20,58 +39,174 @@
2039
]
2140
},
2241
{
23-
"question": "What can automated testing of smart contracts help achieve?",
42+
"question": "Which three variables did we define with the 'let' keyword to use in our test suite?",
2443
"options": [
2544
{
26-
"answer": "Faster development and deployment process."
45+
"answer": "tokenTier, tierID, onlyOwner."
2746
},
2847
{
29-
"answer": "Finding every possible bug and vulnerability."
48+
"answer": "symbol, collection, provider."
3049
},
3150
{
32-
"answer": "Improving the overall code quality.",
51+
"answer": "otherUser, contract, owner.",
3352
"correct": true
53+
}
54+
]
55+
},
56+
{
57+
"question": "During testing, which role does the 'beforeEach' function serve in the test suite?",
58+
"options": [
59+
{
60+
"answer": "It deploys a new instance of the contract before executing each test case."
3461
},
3562
{
36-
"answer": "Ensuring the smart contract is free of errors.",
63+
"answer": "It sets up the testing environment, and initializes contract variables once before all test cases.",
64+
"correct": true
65+
},
66+
{
67+
"answer": "It performs cleanup tasks after each test case is executed."
68+
},
69+
{
70+
"answer": "It executes the contract's constructor function before running any tests."
71+
}
72+
]
73+
},
74+
{
75+
"question": "In the context of our testing, what role does 'describe' play?",
76+
"options": [
77+
{
78+
"answer": "It describes the purpose of the smart contract."
79+
},
80+
{
81+
"answer": "It organises and groups related tests together.",
82+
"correct": true
83+
},
84+
{
85+
"answer": "It handles asynchronous operations in the test suite."
86+
}
87+
]
88+
},
89+
{
90+
"question": "The role of the 'it' function in a test suite is to:",
91+
"options": [
92+
{
93+
"answer": "organise and group related tests together."
94+
},
95+
{
96+
"answer": "irritate the knights formerly known as The Knights of Ni"
97+
},
98+
{
99+
"answer": "define an individual test case or scenario.",
37100
"correct": true
101+
},
102+
{
103+
"answer": "handle asynchronous operations in the test suite."
38104
}
39105
]
40106
},
41107
{
42-
"question": "Which best describes 'gas' in the context of smart contracts?",
108+
"question": "How is 'expect' used to verify test results?",
43109
"options": [
44110
{
45-
"answer": "The cost of deploying a smart contract on the blockchain."
111+
"answer": "It waits for the test cases for the entire suite of tests."
46112
},
47113
{
48-
"answer": "The unit of currency used in smart contract transactions."
114+
"answer": "It groups multiple tests together under one description."
49115
},
50116
{
51-
"answer": "A measure of the computational effort required to execute a transaction or contract.",
117+
"answer": "It waits for an asynchronous call to complete, and returns the result."
118+
},
119+
{
120+
"answer": "It compares the actual result with the anticipated outcome to check if they match.",
121+
"correct": true
122+
}
123+
]
124+
},
125+
{
126+
"question": "In the 'withdraw()' tests, what do the 'await contract.mint()' calls before each test ensure?",
127+
"options": [
128+
{
129+
"answer": "The contract owner's wallet balance is increased.",
52130
"correct": true
53131
},
54132
{
55-
"answer": "The reward given to validators for running a validator node."
133+
"answer": "The 'withdraw()' function can be executed successfully."
134+
},
135+
{
136+
"answer": "The contract has enough Ether to allow withdrawal."
137+
},
138+
{
139+
"answer": "The contract has at least one minted TierNFT.",
140+
"correct": true
56141
}
57142
]
58143
},
59144
{
60-
"question": "What are some potential risks of deploying a smart contract without proper testing?",
145+
"question": "What is the purpose of refactoring the original 'tokenURI()' method into helper functions?",
61146
"options": [
62147
{
63-
"answer": "Loss of funds",
148+
"answer": "To optimize contract performance."
149+
},
150+
{
151+
"answer": "To maintain backward compatibility."
152+
},
153+
{
154+
"answer": "To make the tokenURI() method more testable and maintainable.",
64155
"correct": true
156+
}
157+
]
158+
},
159+
{
160+
"question": "Why is it beneficial to have tests for the helper functions?",
161+
"options": [
162+
{
163+
"answer": "To receive gas refunds"
164+
},
165+
{
166+
"answer": "To decrease the number of transactions"
167+
},
168+
{
169+
"answer": "To ensure the correctness and reliability of the smart contract's behavior.",
170+
"correct": true
171+
},
172+
{
173+
"answer": "To optimize the contract deployment process"
174+
}
175+
]
176+
},
177+
{
178+
"question": "Why is it essential to test the original 'tokenURI()' method before and after refactoring?",
179+
"options": [
180+
{
181+
"answer": "To verify that the helper functions are working correctly"
182+
},
183+
{
184+
"answer": "To ensure that the refactoring did not introduce bugs or alter functionality",
185+
"correct": true
186+
},
187+
{
188+
"answer": "To test cross-browser compatibility"
189+
},
190+
{
191+
"answer": "To measure performance improvements"
192+
}
193+
]
194+
},
195+
{
196+
"question": "Why is it essential to ensure that tests fail before they pass?",
197+
"options": [
198+
{
199+
"answer": "To verify that the test environment is set up correctly."
65200
},
66201
{
67-
"answer": "Security vulnerabilities",
202+
"answer": "To identify potential bugs in the smart contract code.",
68203
"correct": true
69204
},
70205
{
71-
"answer": "Lengthy deployment process"
206+
"answer": "To make the process of writing tests faster and more efficient."
72207
},
73208
{
74-
"answer": "Inefficient gas usage"
209+
"answer": "To confirm that the contract owner can withdraw funds."
75210
}
76211
]
77212
}

0 commit comments

Comments
 (0)