Skip to content

Commit 97aaf55

Browse files
Merge pull request #3 from algorandfoundation/fixes
Fixes
2 parents 1fd4adc + 226d4b9 commit 97aaf55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1368
-797
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ jobs:
5252
with:
5353
path: artifacts
5454

55+
- name: Install @algorandfoundation/algorand-typescript-testing dependencies and patch for bundling
56+
run: npm i --include=prod && npx patch-package --patch-dir ../../patches
57+
working-directory: artifacts/algo-ts-testing
58+
5559
- name: Generate semantic version for @algorandfoundation/algorand-typescript-testing
5660
run: npx semantic-release
5761
env:
5862
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5963

6064
- name: Publish @algorandfoundation/algorand-typescript-testing
6165
uses: JS-DevTools/npm-publish@v3
62-
id: publish-puya-ts
6366
with:
6467
token: ${{ secrets.NPM_TOKEN }}
6568
package: artifacts/algo-ts-testing/package.json

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ out/
6262
.env.test.local
6363
.env.production.local
6464
.env.local
65+
66+
67+
examples/debug-out/

.idea/algorand-typescript-testing.iml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.tstoolkitrc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const config: TsToolkitConfig = {
1010
exports: {
1111
'.': 'index.ts',
1212
'./runtime-helpers': 'runtime-helpers.ts',
13-
'./test-transformer/index': 'test-transformer.ts',
13+
'./test-transformer': 'test-transformer/index.ts',
1414
},
1515
},
1616
}

examples/calculator/contract.algo.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { uint64 } from '@algorandfoundation/algorand-typescript'
2-
import { assert, Bytes, Contract, err, log, op, Txn, Uint64 } from '@algorandfoundation/algorand-typescript'
1+
import { assert, BaseContract, Bytes, err, log, op, Txn, uint64, Uint64 } from '@algorandfoundation/algorand-typescript'
32

43
const ADD = Uint64(1)
54
const SUB = Uint64(2)
@@ -13,7 +12,7 @@ function itoa(i: uint64): string {
1312
}
1413
return itoa(i / radix).concat(digits.at(i % radix).toString())
1514
}
16-
export default class MyContract extends Contract {
15+
export default class MyContract extends BaseContract {
1716
public approvalProgram(): boolean {
1817
const numArgs = Txn.numAppArgs
1918
let a: uint64, b: uint64, action: uint64

examples/calculator/contract.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ describe('Calculator', () => {
3838

3939
const [left, right, outcome] = ctx.exportLogs(application.id, 'i', 'i', 's')
4040

41-
expect(left).toBe(2n)
42-
expect(right).toBe(3n)
41+
expect(left).toEqual(Uint64(2))
42+
expect(right).toEqual(3n)
4343
expect(outcome).toBe('2 + 3 = 5')
4444
expect(result).toBe(true)
4545
})

examples/hello-world-abi/contract.spec.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { assert, TransactionType } from '@algorandfoundation/algorand-typescript'
1+
import { assert, Bytes, TransactionType } from '@algorandfoundation/algorand-typescript'
22
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
33
import { afterEach, describe, expect, it } from 'vitest'
4+
import { ABI_RETURN_VALUE_LOG_PREFIX } from '../../src/constants'
45
import HelloWorldContract from './contract.algo'
56

67
describe('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
})

examples/rollup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { puyaTsTransformer } from '../src/test-transformer'
66

77
const config: RollupOptions = {
88
input: [
9+
'examples/calculator/contract.algo.ts',
910
'examples/hello-world-abi/contract.algo.ts',
1011
'examples/hello-world/contract.algo.ts',
1112
'examples/auction/contract.algo.ts',

0 commit comments

Comments
 (0)