Skip to content

Commit 72585a3

Browse files
committed
Merge branch 'main' of https://github.com/Markkos89/academy into feat/t3-siwe
2 parents 8cf3ec9 + 7ce0bb3 commit 72585a3

File tree

27 files changed

+881
-164
lines changed

27 files changed

+881
-164
lines changed

src/pages/lessons/projects/4.mdx

Lines changed: 222 additions & 164 deletions
Large diffs are not rendered by default.

src/utils/quizzes/lesson-4-quiz.json

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
{
2+
"title": "Quiz: Lesson 4",
3+
"questions": [
4+
{
5+
"question": "Choose those which automated testing of smart contracts can help achieve?",
6+
"options": [
7+
{
8+
"answer": "Faster 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+
},
23+
{
24+
"question": "Which testing approach is recommended for ensuring a secure smart contract?",
25+
"options": [
26+
{
27+
"answer": "Only manual testing with thorough code review"
28+
},
29+
{
30+
"answer": "Automated testing using unit tests exclusively"
31+
},
32+
{
33+
"answer": "A combination of manual testing, automated testing, and code auditing",
34+
"correct": true
35+
},
36+
{
37+
"answer": "Skipping testing to expedite the deployment process"
38+
}
39+
]
40+
},
41+
{
42+
"question": "Which three variables did we define with the 'let' keyword to use in our test suite?",
43+
"options": [
44+
{
45+
"answer": "tokenTier, tierID, onlyOwner"
46+
},
47+
{
48+
"answer": "symbol, collection, provider"
49+
},
50+
{
51+
"answer": "otherUser, contract, owner",
52+
"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."
61+
},
62+
{
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.",
100+
"correct": true
101+
},
102+
{
103+
"answer": "handle asynchronous operations in the test suite."
104+
}
105+
]
106+
},
107+
{
108+
"question": "How is 'expect' used to verify test results?",
109+
"options": [
110+
{
111+
"answer": "It waits for the test cases for the entire suite of tests."
112+
},
113+
{
114+
"answer": "It groups multiple tests together under one description."
115+
},
116+
{
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.",
130+
"correct": true
131+
},
132+
{
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
141+
}
142+
]
143+
},
144+
{
145+
"question": "What is the purpose of refactoring the original 'tokenURI()' method into helper functions?",
146+
"options": [
147+
{
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.",
155+
"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 improve the correctness and reliability of all 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 configured correctly.",
200+
"correct": true
201+
},
202+
{
203+
"answer": "To confirm that your contract is actually being interacted with.",
204+
"correct": true
205+
},
206+
{
207+
"answer": "To make the process of writing tests faster and more efficient."
208+
},
209+
{
210+
"answer": "To confirm that the contract owner can withdraw funds."
211+
}
212+
]
213+
}
214+
]
215+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"question": "Choose the reasons for using automated tests:",
3+
"options": [
4+
{
5+
"answer": "Warns of regressions if we upgrade code later",
6+
"correct": true
7+
},
8+
{
9+
"answer": "So we don’t have to use manual tests"
10+
},
11+
{
12+
"answer": "Build confidence in each component of our code",
13+
"correct": true
14+
},
15+
{
16+
"answer": "All of the above"
17+
}
18+
]
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"question": "What is the role of a testnet in smart contract development?",
3+
"options": [
4+
{
5+
"answer": "It helps to deploy smart contracts to the Ethereum mainnet."
6+
},
7+
{
8+
"answer": "To airdrop free Ether to devs, because testing gives the ecosystem a good name."
9+
},
10+
{
11+
"answer": "It's used to interact with smart contracts using real Ether."
12+
},
13+
{
14+
"answer": "It's a network that is used for testing smart contracts.",
15+
"correct": true
16+
}
17+
]
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"question": "What is the purpose of the 'require' statement in Solidity?",
3+
"options": [
4+
{
5+
"answer": "For specifying the visibility of a variable or function."
6+
},
7+
{
8+
"answer": "To be able to easily define a new modifier in the contract whenever we need it."
9+
},
10+
{
11+
"answer": "For declaring a new function in the contract."
12+
},
13+
{
14+
"answer": "To perform a conditional check, and revert the transaction if it fails.",
15+
"correct": true
16+
}
17+
]
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"question": "When writing unit tests for a smart contract, what should we be testing?",
3+
"options": [
4+
{
5+
"answer": "Functionality that only involves external contracts"
6+
},
7+
{
8+
"answer": "Only private functions that aren't externally accessible"
9+
},
10+
{
11+
"answer": "All functions and possible edge cases that the contract may encounter",
12+
"correct": true
13+
},
14+
{
15+
"answer": "Just the constructor function to ensure the contract gets deployed properly"
16+
}
17+
]
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"question": "What do you imagine one of the first steps is in this lesson?",
3+
"options": [
4+
{
5+
"answer": "To add your private key to the .gitignore file"
6+
},
7+
{
8+
"answer": "To harmonise Solidity versions across the project",
9+
"correct": true
10+
},
11+
{
12+
"answer": "To make sure to add an extra line of code to the contract to signal to Hardhat that we can test it"
13+
},
14+
{
15+
"answer": "To create a console.log line to the contract code so we can see the output of the tests"
16+
}
17+
]
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"question": "Which of the following can we achieve with automated testing?",
3+
"options": [
4+
{
5+
"answer": "Prove code actually works"
6+
},
7+
{
8+
"answer": "Help write more modular code"
9+
},
10+
{
11+
"answer": "Ensure a fixed bug stays fixed"
12+
},
13+
{
14+
"answer": "All of the above",
15+
"correct": true
16+
},
17+
{
18+
"answer": "Only a) and c)"
19+
}
20+
]
21+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"question": "How does the tokenURI function generate the token metadata?",
3+
"options": [
4+
{
5+
"answer": "By reading from an external file"
6+
},
7+
{
8+
"answer": "By using a predefined JSON template"
9+
},
10+
{
11+
"answer": "By dynamically generating SVG image and JSON data",
12+
"correct": true
13+
},
14+
{
15+
"answer": "By querying an off-chain API"
16+
}
17+
]
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"question": "What should be added to the scripts section of package.json to run tests using Hardhat?",
3+
"options": [
4+
{
5+
"answer": "\"scripts\": { \"test\": \"hardhat test\" }"
6+
},
7+
{
8+
"answer": "\"scripts\": { \"runTests\": \"hardhat test\" }"
9+
},
10+
{
11+
"answer": " \"scripts\": { \"test\": \"hardhat test --network hardhat\" }",
12+
"correct": true
13+
},
14+
{
15+
"answer": "\"scripts\": { \"runTests\": \"hardhat test --network hardhat\" }"
16+
}
17+
]
18+
}

0 commit comments

Comments
 (0)