Skip to content

Commit

Permalink
add blob tests, fix test.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Oct 20, 2023
1 parent 0ab41fd commit f6a8632
Show file tree
Hide file tree
Showing 10 changed files with 1,337 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ jobs:
"examples/tuple_types",
"examples/update",
"examples/vanilla_js",
"property_tests/tests/blob",
"property_tests/tests/int",
"property_tests/tests/int8",
"property_tests/tests/int16",
Expand Down Expand Up @@ -209,10 +210,14 @@ jobs:
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
run: npm link azle
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && contains(github.head_ref, 'release--') }}
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }}
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
run: AZLE_NUM_PROPTEST_RUNS=10 npm test
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && contains(github.head_ref, 'release--') }}
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
run: AZLE_NUM_PROPTEST_RUNS=100 npm test
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }}
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
Expand Down
6 changes: 6 additions & 0 deletions property_tests/arbitraries/candid/constructed/blob_arb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import fc from 'fast-check';

export const BlobArb = fc.tuple(
fc.uint8Array(),
fc.oneof(fc.constant('blob'), fc.constant('Vec(nat8)'))
);
6 changes: 5 additions & 1 deletion property_tests/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import fc from 'fast-check';
import { TestSample, createCanisterArb } from './arbitraries/canister_arb';
import { writeFileSync } from 'fs';
import { existsSync, mkdirSync, writeFileSync } from 'fs';
import { execSync } from 'child_process';
import { runTests } from '../test';

export function runPropTests(testArb: fc.Arbitrary<TestSample>) {
fc.assert(
fc.asyncProperty(createCanisterArb(testArb), async (canister) => {
if (!existsSync('src')) {
mkdirSync('src');
}

writeFileSync('src/index.ts', canister.sourceCode);

execSync(`dfx canister uninstall-code canister || true`, {
Expand Down
16 changes: 16 additions & 0 deletions property_tests/tests/blob/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"canisters": {
"canister": {
"type": "custom",
"main": "src/index.ts",
"candid": "src/index.did",
"build": "npx azle canister",
"wasm": ".azle/canister/canister.wasm",
"gzip": true,
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
}
}
}
}
Loading

0 comments on commit f6a8632

Please sign in to comment.