Skip to content

Commit 3e612c2

Browse files
authored
test: use algokit-polytest go-algorand transaction generator (#494)
1 parent 162642f commit 3e612c2

19 files changed

+4183
-642515
lines changed

.github/workflows/pr.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ permissions:
88
contents: read
99

1010
jobs:
11-
setup-polytest:
11+
build-and-test:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout source code
1515
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
1618

1719
- name: Setup Node.js
1820
uses: actions/setup-node@v4
@@ -28,14 +30,9 @@ jobs:
2830
- name: Validate polytest algod_client tests
2931
run: npm run polytest:validate-algod
3032

31-
build-and-test:
32-
needs: setup-polytest
33-
runs-on: ubuntu-latest
34-
steps:
35-
- name: Checkout source code
36-
uses: actions/checkout@v4
37-
with:
38-
fetch-depth: 0
33+
- name: Generate transact polytest files
34+
working-directory: packages/transact/
35+
run: npm run polytest:generate
3936

4037
- name: Run CI
4138
uses: ./.github/actions/ci

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,5 @@ venv/
6868
ENV/
6969

7070
.polytest*/
71-
.algokit*/
71+
polytest_resources/
72+
.algokit*/

packages/common/src/codecs/composite/map.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import type { EncodingFormat } from '../types'
44
/**
55
* Map codec - handles Maps with any key type (including Uint8Array, bigint, number)
66
* Depending on the encoding format, the map is encoded differently:
7-
* - json: Only supports string keys and is represented as an object when encoding.
8-
* An exception is thrown upon encountering a non-string key.
7+
* - json: Supports string and bigint keys. The map is represented as an object when encoding.
8+
* Bigint keys are converted to/from strings (e.g., 1n becomes "1").
9+
* An exception is thrown upon encountering an unsupported key type.
910
* - msgpack: Preserves key types and is represented as a Map when encoding.
1011
*/
1112
export class MapCodec<K, V, KEncoded = K, VEncoded = V> extends Codec<Map<K, V>, Map<KEncoded, VEncoded> | Record<string, VEncoded>> {
@@ -28,7 +29,7 @@ export class MapCodec<K, V, KEncoded = K, VEncoded = V> extends Codec<Map<K, V>,
2829
if (format === 'msgpack') {
2930
return true
3031
}
31-
if (this.keyType !== 'string') {
32+
if (this.keyType !== 'string' && this.keyType !== 'bigint') {
3233
throw new Error(`Map key of type '${this.keyType}' is not supported in ${format} format`)
3334
}
3435
}
@@ -68,7 +69,11 @@ export class MapCodec<K, V, KEncoded = K, VEncoded = V> extends Codec<Map<K, V>,
6869
}
6970

7071
for (const [encodedKey, encodedValue] of entries) {
71-
const key = this.keyCodec.decode(encodedKey as KEncoded, format)
72+
let keyToDecode = encodedKey as KEncoded
73+
if (format === 'json' && this.keyType === 'bigint' && typeof encodedKey === 'string') {
74+
keyToDecode = BigInt(encodedKey) as KEncoded
75+
}
76+
const key = this.keyCodec.decode(keyToDecode, format)
7277
const val = this.valueCodec.decode(encodedValue, format)
7378
result.set(key, val)
7479
}

packages/transact/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"audit": "better-npm-audit audit",
2323
"format": "prettier --config ../../.prettierrc.cjs --ignore-path ../../.prettierignore --write .",
2424
"pre-commit": "run-s check-types lint:fix audit format test",
25-
"polytest:generate": "polytest --config test_configs/transact.jsonc --git https://github.com/joe-p/algokit-polytest#main generate -t vitest",
26-
"polytest:run": "polytest --config test_configs/transact.jsonc --git https://github.com/joe-p/algokit-polytest#main run --no-parse -t vitest"
25+
"polytest:generate": "polytest --config test_configs/transact.jsonc --git https://github.com/joe-p/algokit-polytest#feat/data_factory generate -t vitest",
26+
"polytest:run": "polytest --config test_configs/transact.jsonc --git https://github.com/joe-p/algokit-polytest#feat/data_factory run --no-parse -t vitest"
2727
},
2828
"dependencies": {},
2929
"peerDependencies": {},

packages/transact/tests/app_call.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import {
99
assertDecodeWithPrefix,
1010
assertDecodeWithoutPrefix,
1111
assertEncode,
12-
assertEncodeWithAuthAddress,
1312
assertEncodeWithSignature,
1413
assertEncodedTransactionType,
1514
assertExample,
16-
assertMultisigExample,
1715
assertTransactionId,
1816
} from './transaction_asserts'
1917

@@ -35,10 +33,6 @@ describe('App Call', () => {
3533
await assertExample(label, testData)
3634
})
3735

38-
test('multisig example', async () => {
39-
await assertMultisigExample(label, testData)
40-
})
41-
4236
test('get transaction id', () => {
4337
assertTransactionId(label, testData)
4438
})
@@ -59,12 +53,8 @@ describe('App Call', () => {
5953
assertDecodeWithPrefix(label, testData)
6054
})
6155

62-
test('encode with auth address', async () => {
63-
await assertEncodeWithAuthAddress(label, testData)
64-
})
65-
66-
test('encode with signature', () => {
67-
assertEncodeWithSignature(label, testData)
56+
test('encode with signature', async () => {
57+
await assertEncodeWithSignature(label, testData)
6858
})
6959

7060
test('encode', () => {

packages/transact/tests/asset_config.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import {
77
assertDecodeWithPrefix,
88
assertDecodeWithoutPrefix,
99
assertEncode,
10-
assertEncodeWithAuthAddress,
1110
assertEncodeWithSignature,
1211
assertEncodedTransactionType,
1312
assertExample,
14-
assertMultisigExample,
1513
assertTransactionId,
1614
} from './transaction_asserts'
1715
import { Address, ALGORAND_ZERO_ADDRESS_STRING } from '@algorandfoundation/algokit-common'
@@ -33,10 +31,6 @@ describe('AssetConfig', () => {
3331
await assertExample(label, testData)
3432
})
3533

36-
test('multisig example', async () => {
37-
await assertMultisigExample(label, testData)
38-
})
39-
4034
test('get transaction id', () => {
4135
assertTransactionId(label, testData)
4236
})
@@ -57,12 +51,8 @@ describe('AssetConfig', () => {
5751
assertDecodeWithPrefix(label, testData)
5852
})
5953

60-
test('encode with auth address', async () => {
61-
await assertEncodeWithAuthAddress(label, testData)
62-
})
63-
64-
test('encode with signature', () => {
65-
assertEncodeWithSignature(label, testData)
54+
test('encode with signature', async () => {
55+
await assertEncodeWithSignature(label, testData)
6656
})
6757

6858
test('encode', () => {

packages/transact/tests/asset_freeze.test.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
assertDecodeWithPrefix,
99
assertDecodeWithoutPrefix,
1010
assertEncode,
11-
assertEncodeWithAuthAddress,
1211
assertEncodeWithSignature,
1312
assertEncodedTransactionType,
1413
assertExample,
@@ -51,12 +50,8 @@ describe('Asset Freeze', () => {
5150
assertDecodeWithPrefix(label, testData)
5251
})
5352

54-
test('encode with auth address', async () => {
55-
await assertEncodeWithAuthAddress(label, testData)
56-
})
57-
58-
test('encode with signature', () => {
59-
assertEncodeWithSignature(label, testData)
53+
test('encode with signature', async () => {
54+
await assertEncodeWithSignature(label, testData)
6055
})
6156

6257
test('encode', () => {

packages/transact/tests/asset_transfer.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import {
88
assertDecodeWithPrefix,
99
assertDecodeWithoutPrefix,
1010
assertEncode,
11-
assertEncodeWithAuthAddress,
1211
assertEncodeWithSignature,
1312
assertEncodedTransactionType,
1413
assertExample,
15-
assertMultisigExample,
1614
assertTransactionId,
1715
} from './transaction_asserts'
1816

@@ -31,10 +29,6 @@ describe('AssetTransfer', () => {
3129
await assertExample(label, testData)
3230
})
3331

34-
test('multisig example', async () => {
35-
await assertMultisigExample(label, testData)
36-
})
37-
3832
test('get transaction id', () => {
3933
assertTransactionId(label, testData)
4034
})
@@ -55,12 +49,8 @@ describe('AssetTransfer', () => {
5549
assertDecodeWithPrefix(label, testData)
5650
})
5751

58-
test('encode with auth address', async () => {
59-
await assertEncodeWithAuthAddress(label, testData)
60-
})
61-
62-
test('encode with signature', () => {
63-
assertEncodeWithSignature(label, testData)
52+
test('encode with signature', async () => {
53+
await assertEncodeWithSignature(label, testData)
6454
})
6555

6656
test('encode', () => {

0 commit comments

Comments
 (0)