1- import { assert , TransactionType } from '@algorandfoundation/algorand-typescript'
1+ import { assert , Bytes , TransactionType } from '@algorandfoundation/algorand-typescript'
22import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
33import { afterEach , describe , expect , it } from 'vitest'
4+ import { ABI_RETURN_VALUE_LOG_PREFIX } from '../../src/constants'
45import HelloWorldContract from './contract.algo'
56
67describe ( 'HelloWorldContract' , ( ) => {
@@ -14,14 +15,20 @@ describe('HelloWorldContract', () => {
1415 assert ( ctx . txn . lastActive . type === TransactionType . ApplicationCall , 'Last txn must be app' )
1516
1617 expect ( result ) . toBe ( 'Bananas' )
17- expect ( ctx . exportLogs ( ctx . txn . lastActive . appId . id , 's' ) ) . toStrictEqual ( [ result ] )
18+ const bananasBytes = Bytes ( 'Bananas' )
19+ const abiLog = ABI_RETURN_VALUE_LOG_PREFIX . concat ( bananasBytes )
20+ const logs = ctx . exportLogs ( ctx . txn . lastActive . appId . id , 's' , 'b' )
21+ expect ( logs ) . toStrictEqual ( [ result , abiLog ] )
1822 } )
1923 it ( 'logs the returned value when sayHello is called' , async ( ) => {
2024 const contract = ctx . contract . create ( HelloWorldContract )
2125 const result = contract . sayHello ( 'John' , 'Doe' )
2226 assert ( ctx . txn . lastActive . type === TransactionType . ApplicationCall , 'Last txn must be app' )
2327
2428 expect ( result ) . toBe ( 'Hello John Doe' )
25- expect ( ctx . exportLogs ( ctx . txn . lastActive . appId . id , 's' ) ) . toStrictEqual ( [ result ] )
29+ const helloBytes = Bytes ( 'Hello John Doe' )
30+ const abiLog = ABI_RETURN_VALUE_LOG_PREFIX . concat ( helloBytes )
31+ const logs = ctx . exportLogs ( ctx . txn . lastActive . appId . id , 's' , 'b' )
32+ expect ( logs ) . toStrictEqual ( [ result , abiLog ] )
2633 } )
2734} )
0 commit comments