1
- import { assert , TransactionType } from '@algorandfoundation/algorand-typescript'
1
+ import { assert , Bytes , TransactionType } from '@algorandfoundation/algorand-typescript'
2
2
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
3
3
import { afterEach , describe , expect , it } from 'vitest'
4
+ import { ABI_RETURN_VALUE_LOG_PREFIX } from '../../src/constants'
4
5
import HelloWorldContract from './contract.algo'
5
6
6
7
describe ( 'HelloWorldContract' , ( ) => {
@@ -14,14 +15,20 @@ describe('HelloWorldContract', () => {
14
15
assert ( ctx . txn . lastActive . type === TransactionType . ApplicationCall , 'Last txn must be app' )
15
16
16
17
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 ] )
18
22
} )
19
23
it ( 'logs the returned value when sayHello is called' , async ( ) => {
20
24
const contract = ctx . contract . create ( HelloWorldContract )
21
25
const result = contract . sayHello ( 'John' , 'Doe' )
22
26
assert ( ctx . txn . lastActive . type === TransactionType . ApplicationCall , 'Last txn must be app' )
23
27
24
28
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 ] )
26
33
} )
27
34
} )
0 commit comments