@@ -183,24 +183,25 @@ describe(`XRequestProcessor tests`, function () {
183183 expect ( processorContractBalance ) . to . equal ( repostAmount )
184184 } )
185185
186- it ( 'interactWithPost() - User should NOT be able to invoke actions without ERC20 balance ' , async function ( ) {
187- const { user1, processorContract, tokenContract } = await loadFixture (
186+ it ( 'interactWithPost() - User should be able to invoke XActionType.TokenAnalysis actions ' , async function ( ) {
187+ const { owner , user1, processorContract, tokenContract } = await loadFixture (
188188 deployXRequestProcessorFixture
189189 )
190190
191- const spender = await processorContract . getAddress ( )
192- await tokenContract . connect ( user1 ) . approve ( spender , likeAmount )
191+ await tokenContract . connect ( owner ) . transfer ( user1 . address , tokenAnalysisAmount )
192+ const processorContractAddress = await processorContract . getAddress ( )
193+ await tokenContract . connect ( user1 ) . approve ( processorContractAddress , tokenAnalysisAmount )
193194
194- const userBalance = await tokenContract . balanceOf ( user1 . address )
195- expect ( userBalance ) . to . equal ( 0n )
195+ const userBalanceBefore = await tokenContract . balanceOf ( user1 . address )
196+ expect ( userBalanceBefore ) . to . equal ( tokenAnalysisAmount )
196197
197- const xPostUri = 'https://x.com/SpaceX/status/1928107204931940365 '
198+ const ticker = 'GIANTAI '
198199 await expect (
199- processorContract . connect ( user1 ) . interactWithPost ( XActionType . Like , xPostUri )
200- ) . to . be . revertedWithCustomError ( tokenContract , 'ERC20InsufficientBalance' )
200+ processorContract . connect ( user1 ) . interactWithPost ( XActionType . TokenAnalysis , ticker )
201+ ) . not . to . be . reverted
201202 } )
202203
203- it ( 'interactWithPost() - User should NOT be able to invoke XActionType.TokenAnalysis through this method ' , async function ( ) {
204+ it ( 'interactWithPost() - User should NOT be able to invoke XActionType.TokenAnalysis with invalid TICKER ' , async function ( ) {
204205 const { owner, user1, processorContract, tokenContract } = await loadFixture (
205206 deployXRequestProcessorFixture
206207 )
@@ -212,13 +213,13 @@ describe(`XRequestProcessor tests`, function () {
212213 const userBalanceBefore = await tokenContract . balanceOf ( user1 . address )
213214 expect ( userBalanceBefore ) . to . equal ( tokenAnalysisAmount )
214215
215- const xPostUri = 'https://x.com/SpaceX/status/1928107204931940365 '
216+ const ticker = 'SUPER_LONG_AND_INVALID_TICKER_NAME '
216217 await expect (
217- processorContract . connect ( user1 ) . interactWithPost ( XActionType . TokenAnalysis , xPostUri )
218+ processorContract . connect ( user1 ) . interactWithPost ( XActionType . TokenAnalysis , ticker )
218219 ) . to . be . reverted
219220 } )
220221
221- it ( 'analyzeToken () - User should be able to invoke token analysis action ' , async function ( ) {
222+ it ( 'interactWithPost () - User should NOT be able to invoke actions with empty URI or TICKER ' , async function ( ) {
222223 const { owner, user1, processorContract, tokenContract } = await loadFixture (
223224 deployXRequestProcessorFixture
224225 )
@@ -230,41 +231,29 @@ describe(`XRequestProcessor tests`, function () {
230231 const userBalanceBefore = await tokenContract . balanceOf ( user1 . address )
231232 expect ( userBalanceBefore ) . to . equal ( tokenAnalysisAmount )
232233
233- await expect ( processorContract . connect ( user1 ) . analyzeToken ( 'GIANTAI' ) ) . to . emit (
234- processorContract ,
235- 'NewTokenAnalysis'
236- )
237-
238- const userBalanceAfter = await tokenContract . balanceOf ( user1 . address )
239- expect ( userBalanceAfter ) . to . equal ( 0n )
240-
241- const processorContractBalance = await tokenContract . balanceOf ( processorContractAddress )
242- expect ( processorContractBalance ) . to . equal ( tokenAnalysisAmount )
234+ const xPostUri = ''
235+ await expect (
236+ processorContract . connect ( user1 ) . interactWithPost ( XActionType . TokenAnalysis , xPostUri )
237+ ) . to . be . reverted
243238 } )
244239
245- it ( 'analyzeToken () - User should NOT be able to invoke token analysis without ERC20 balance' , async function ( ) {
240+ it ( 'interactWithPost () - User should NOT be able to invoke actions without ERC20 balance' , async function ( ) {
246241 const { user1, processorContract, tokenContract } = await loadFixture (
247242 deployXRequestProcessorFixture
248243 )
249244
250245 const spender = await processorContract . getAddress ( )
251- await tokenContract . connect ( user1 ) . approve ( spender , tokenAnalysisAmount )
246+ await tokenContract . connect ( user1 ) . approve ( spender , likeAmount )
252247
253248 const userBalance = await tokenContract . balanceOf ( user1 . address )
254249 expect ( userBalance ) . to . equal ( 0n )
255250
251+ const xPostUri = 'https://x.com/SpaceX/status/1928107204931940365'
256252 await expect (
257- processorContract . connect ( user1 ) . analyzeToken ( 'GIANTAI' )
253+ processorContract . connect ( user1 ) . interactWithPost ( XActionType . Like , xPostUri )
258254 ) . to . be . revertedWithCustomError ( tokenContract , 'ERC20InsufficientBalance' )
259255 } )
260256
261- it ( 'analyzeToken() - Should throw when invalid token ticker is provided' , async function ( ) {
262- const { user1, processorContract } = await loadFixture ( deployXRequestProcessorFixture )
263-
264- const invalidTicker = 'INVALID_SUPER_LONG_TICKER_NAME'
265- await expect ( processorContract . connect ( user1 ) . analyzeToken ( invalidTicker ) ) . to . be . reverted
266- } )
267-
268257 it ( 'getPaymentTokenAddress() - Should return the ERC20 address set during deploy time' , async function ( ) {
269258 const { processorContract, tokenContract } = await loadFixture ( deployXRequestProcessorFixture )
270259
0 commit comments