Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: avoid using ctxMgr for stubbing Account, Application, Asset, and log functions #69

Merged
merged 1 commit into from
Jan 21, 2025

refactor: avoid using ctxMgr for stubbing Account, Application, Asset…

41cdd7e
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

refactor: avoid using ctxMgr for stubbing Account, Application, Asset, and log functions #69

refactor: avoid using ctxMgr for stubbing Account, Application, Asset…
41cdd7e
Select commit
Loading
Failed to load commit list.
GitHub Actions / Test results succeeded Jan 21, 2025 in 0s

181 passed, 0 failed and 0 skipped

Tests passed successfully

✔️ test-results.xml

181 tests were completed in 161s with 181 passed, 0 failed and 0 skipped.

Test suite Passed Failed Skipped Time
src/util/arc4-signature-parser.spec.ts 39✔️ 28ms
src/util/base-32.spec.ts 6✔️ 9ms
tests/approvals.spec.ts 55✔️ 128ms
tests/check-version.spec.ts 1✔️ 1s
tests/expected-output.spec.ts 23✔️ 21ms
tests/onchain/abi-decorators.spec.ts 4✔️ 18s
tests/onchain/accounts.spec.ts 1✔️ 16s
tests/onchain/arc-28-events.spec.ts 2✔️ 15s
tests/onchain/arc4-types.spec.ts 6✔️ 41s
tests/onchain/assert-match.spec.ts 1✔️ 14s
tests/onchain/biguint-expressions.spec.ts 1✔️ 14s
tests/onchain/boolean-conversions.spec.ts 1✔️ 13s
tests/onchain/box-enum-contract.spec.ts 1✔️ 14s
tests/onchain/box-proxies.spec.ts 1✔️ 14s
tests/onchain/byte-expressions.spec.ts 1✔️ 14s
tests/onchain/extract-bytes.spec.ts 1✔️ 14s
tests/onchain/implicit-create.spec.ts 5✔️ 18s
tests/onchain/inheritance.spec.ts 2✔️ 24s
tests/onchain/multi-inheritance.spec.ts 7✔️ 25s
tests/onchain/precompiled.spec.ts 4✔️ 18s
tests/onchain/prefix-postfix-operators.spec.ts 1✔️ 14s
tests/onchain/primitives.spec.ts 5✔️ 47s
tests/onchain/property-ordering.spec.ts 1✔️ 12s
tests/onchain/shadowed-variables.spec.ts 1✔️ 14s
tests/onchain/state-totals.spec.ts 7✔️ 20s
tests/onchain/super-calls.spec.ts 4✔️ 17s

✔️ src/util/arc4-signature-parser.spec.ts

src/util/arc4-signature-parser.spec.ts
  ✔️ arc4 signature parser > can parse valid types > byte parses
  ✔️ arc4 signature parser > can parse valid types > byte[] parses
  ✔️ arc4 signature parser > can parse valid types > byte[5] parses
  ✔️ arc4 signature parser > can parse valid types > bool parses
  ✔️ arc4 signature parser > can parse valid types > bool[] parses
  ✔️ arc4 signature parser > can parse valid types > bool[12] parses
  ✔️ arc4 signature parser > can parse valid types > uint8 parses
  ✔️ arc4 signature parser > can parse valid types > uint8[] parses
  ✔️ arc4 signature parser > can parse valid types > uint8[12] parses
  ✔️ arc4 signature parser > can parse valid types > uint16 parses
  ✔️ arc4 signature parser > can parse valid types > uint16[] parses
  ✔️ arc4 signature parser > can parse valid types > uint16[12] parses
  ✔️ arc4 signature parser > can parse valid types > uint32 parses
  ✔️ arc4 signature parser > can parse valid types > uint32[] parses
  ✔️ arc4 signature parser > can parse valid types > uint32[12] parses
  ✔️ arc4 signature parser > can parse valid types > uint64 parses
  ✔️ arc4 signature parser > can parse valid types > uint64[] parses
  ✔️ arc4 signature parser > can parse valid types > uint64[12] parses
  ✔️ arc4 signature parser > can parse valid types > uint128 parses
  ✔️ arc4 signature parser > can parse valid types > uint128[] parses
  ✔️ arc4 signature parser > can parse valid types > uint128[12] parses
  ✔️ arc4 signature parser > can parse valid types > uint256 parses
  ✔️ arc4 signature parser > can parse valid types > uint256[] parses
  ✔️ arc4 signature parser > can parse valid types > uint256[12] parses
  ✔️ arc4 signature parser > can parse valid types > string parses
  ✔️ arc4 signature parser > can parse valid types > string[] parses
  ✔️ arc4 signature parser > can parse valid types > string[12] parses
  ✔️ arc4 signature parser > can parse valid types > byte[][][] parses
  ✔️ arc4 signature parser > can parse valid types > byte[2][2][2] parses
  ✔️ arc4 signature parser > can parse valid types > (bool) parses
  ✔️ arc4 signature parser > can parse valid types > (bool,string,uint8,(uint16,string[]),bool[])[1][] parses
  ✔️ arc4 signature parser > errors on invalid types > float returns error Expecting string 'uint', got 'floa...'
  ✔️ arc4 signature parser > errors on invalid types > uint2 returns error n must be between 8 and 512, and a multiple of 8
  ✔️ arc4 signature parser > errors on invalid types > (uint8,uint2) returns error n must be between 8 and 512, and a multiple of 8
  ✔️ arc4 signature parser > errors on invalid types > uint8[ returns error Expecting character ']', but got end of input.
  ✔️ arc4 signature parser > errors on invalid types > uint8] returns error Expecting ',', '[', or ')', but got ]
  ✔️ arc4 signature parser > errors on invalid types > uint8,uint8 returns error Signature contained more than one type. Wrap multiple types in parentheses to declare a tuple type
  ✔️ arc4 signature parser > errors on invalid types > (uint8 returns error Tuple has not been closed
  ✔️ arc4 signature parser > errors on invalid types > (uint8,bool)) returns error Char ')' has no matching opening '('

✔️ src/util/base-32.spec.ts

src/util/base-32.spec.ts
  ✔️ base-32 encoding > Zero address should be AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ
  ✔️ base-32 encoding > encode and decode should return same value > Uint8Array[]
  ✔️ base-32 encoding > encode and decode should return same value > Uint8Array[ 1 ]
  ✔️ base-32 encoding > encode and decode should return same value > Uint8Array[ 1, 2, 3, 4, 5, 6, 7, 8 ]
  ✔️ base-32 encoding > encode and decode should return same value > Uint8Array[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
  ✔️ base-32 encoding > encode and decode should return same value > Uint8Array[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]

✔️ tests/approvals.spec.ts

tests/approvals.spec.ts
  ✔️ Approvals > There should be no general error logs
  ✔️ Approvals > 'tests/approvals/while-loops.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/uint64-expressions.al…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/switch-statements.alg…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/super-calls.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/strings.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/state-totals.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/shadowed-variables.al…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/reserve-scratch.algo.…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/property-ordering.alg…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/prefix-postfix-operat…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/precompiled-apps.algo…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/precompiled-factory.a…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/pre-approved-sale.alg…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/object-destructuring.…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/numeric-literal-expre…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/non-arc4.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/named-types.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/multi-inheritance.alg…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/logic-sig.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/local-state.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/jsdoc.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/itxn.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/intrinsic-calls.algo.…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/inheritance-a.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/inheritance-b.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/implicit-create.algo.…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/global-state.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/for-of-loops.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/for-loops.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/extract-bytes.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/ensure-budget.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/do-loops.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/destructuring-iterato…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/destructured-params.a…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/conditional-expressio…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/casting.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/call-expressions.algo…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/byte-expressions.algo…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/box-proxies.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/box-enum-contract.alg…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/boolean-expressions.a…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/boolean-conversions.a…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/biguint-expressions.a…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/avm11.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/assert-match.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/array-literals.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/array-destructuring.a…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/arc4-types.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/arc4-struct.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/arc4-encode-decode.al…' > compiles without errors
  ✔️ Approvals > 'tests/approvals/arc-28-events.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/accounts.algo.ts' > compiles without errors
  ✔️ Approvals > 'tests/approvals/abi-decorators.algo.ts' > compiles without errors
  ✔️ Approvals > There should be no differences to committed changes

✔️ tests/check-version.spec.ts

tests/check-version.spec.ts
  ✔️ The puya version available for testing > must match the target version

✔️ tests/expected-output.spec.ts

tests/expected-output.spec.ts
  ✔️ Expected output > 'tests/expected-output/uint64-expressi…' > has expected output
  ✔️ Expected output > 'tests/expected-output/prefix-postfix-…' > has expected output
  ✔️ Expected output > 'tests/expected-output/object-destruct…' > has expected output
  ✔️ Expected output > 'tests/expected-output/numeric-literal…' > has expected output
  ✔️ Expected output > 'tests/expected-output/null-values.alg…' > has expected output
  ✔️ Expected output > 'tests/expected-output/not-supported.a…' > has expected output
  ✔️ Expected output > 'tests/expected-output/mutating-tuples…' > has expected output
  ✔️ Expected output > 'tests/expected-output/multi-inheritan…' > has expected output
  ✔️ Expected output > 'tests/expected-output/logic-sig.algo.…' > has expected output
  ✔️ Expected output > 'tests/expected-output/invalid-array-u…' > has expected output
  ✔️ Expected output > 'tests/expected-output/global-state.al…' > has expected output
  ✔️ Expected output > 'tests/expected-output/extract-bytes.a…' > has expected output
  ✔️ Expected output > 'tests/expected-output/dynamic-imports…' > has expected output
  ✔️ Expected output > 'tests/expected-output/conditional-exp…' > has expected output
  ✔️ Expected output > 'tests/expected-output/cant-create.alg…' > has expected output
  ✔️ Expected output > 'tests/expected-output/byte-expression…' > has expected output
  ✔️ Expected output > 'tests/expected-output/biguint-express…' > has expected output
  ✔️ Expected output > 'tests/expected-output/array-literals.…' > has expected output
  ✔️ Expected output > 'tests/expected-output/array-destructu…' > has expected output
  ✔️ Expected output > 'tests/expected-output/arc4-types.algo…' > has expected output
  ✔️ Expected output > 'tests/expected-output/arc4-struct.alg…' > has expected output
  ✔️ Expected output > 'tests/expected-output/arc28-events.al…' > has expected output
  ✔️ Expected output > 'tests/expected-output/abi-decorators.…' > has expected output

✔️ tests/onchain/abi-decorators.spec.ts

tests/onchain/abi-decorators.spec.ts
  ✔️ abi-decorators > can be created
  ✔️ abi-decorators > methods can be called
  ✔️ abi-decorators > overloaded methods can be called
  ✔️ abi-decorators > overrided methods work as expected

✔️ tests/onchain/accounts.spec.ts

tests/onchain/accounts.spec.ts
  ✔️ accounts > returns account data

✔️ tests/onchain/arc-28-events.spec.ts

tests/onchain/arc-28-events.spec.ts
  ✔️ arc 28 events > It works with struct types
  ✔️ arc 28 events > It works with dynamic bytes

✔️ tests/onchain/arc4-types.spec.ts

tests/onchain/arc4-types.spec.ts
  ✔️ arc4-types > runs
  ✔️ arc4-struct > testVectorCreationAndEquality
  ✔️ arc4-struct > add vectors
  ✔️ arc4-struct > implicit casting and spreading
  ✔️ arc4-encode-decode > encoding
  ✔️ arc4-encode-decode > decoding

✔️ tests/onchain/assert-match.spec.ts

tests/onchain/assert-match.spec.ts
  ✔️ assert match > it can be called

✔️ tests/onchain/biguint-expressions.spec.ts

tests/onchain/biguint-expressions.spec.ts
  ✔️ biguint expressions > should run

✔️ tests/onchain/boolean-conversions.spec.ts

tests/onchain/boolean-conversions.spec.ts
  ✔️ boolean conversions match > it can be called

✔️ tests/onchain/box-enum-contract.spec.ts

tests/onchain/box-enum-contract.spec.ts
  ✔️ box-enum-contract > can store and load enums

✔️ tests/onchain/box-proxies.spec.ts

tests/onchain/box-proxies.spec.ts
  ✔️ BoxProxies > Should run

✔️ tests/onchain/byte-expressions.spec.ts

tests/onchain/byte-expressions.spec.ts
  ✔️ byte expressions > runs

✔️ tests/onchain/extract-bytes.spec.ts

tests/onchain/extract-bytes.spec.ts
  ✔️ Extract bytes contract > runs

✔️ tests/onchain/implicit-create.spec.ts

tests/onchain/implicit-create.spec.ts
  ✔️ implicit-create > NoBare can be created
  ✔️ implicit-create > NoNoOp can be created
  ✔️ implicit-create > ExplicitBareCreateFromBase can be created
  ✔️ implicit-create > ExplicitAbiCreateFromBase can't be created with bare
  ✔️ implicit-create > ExplicitAbiCreateFromBase can be created with abi

✔️ tests/onchain/inheritance.spec.ts

tests/onchain/inheritance.spec.ts
  ✔️ inheritance > non arc4 > Simple contract can be created
  ✔️ inheritance > arc4 > ARC4 contract can be created

✔️ tests/onchain/multi-inheritance.spec.ts

tests/onchain/multi-inheritance.spec.ts
  ✔️ multi-inheritance > CommonBase has all state
  ✔️ multi-inheritance > BaseOne has all state
  ✔️ multi-inheritance > BaseTwo has all state
  ✔️ multi-inheritance > Multibase has all state
  ✔️ multi-inheritance > Multibase methods can all be called
  ✔️ multi-inheritance > MRO is depth first
  ✔️ multi-inheritance > super.class(...) can be used to target a specific base type

✔️ tests/onchain/precompiled.spec.ts

tests/onchain/precompiled.spec.ts
  ✔️ precompiled > Hello contract can be deployed
  ✔️ precompiled > HelloTemplate contract can be deployed
  ✔️ precompiled > HelloTemplateCustomPrefix contract can be deployed
  ✔️ precompiled > LargeProgram contract can be deployed

✔️ tests/onchain/prefix-postfix-operators.spec.ts

tests/onchain/prefix-postfix-operators.spec.ts
  ✔️ prefix postfix operators > it runs

✔️ tests/onchain/primitives.spec.ts

tests/onchain/primitives.spec.ts
  ✔️ primitives > uint64 > can be created
  ✔️ primitives > biguint > can be created
  ✔️ primitives > bytes > can be created
  ✔️ primitives > strings > can be joined
  ✔️ primitives > strings > can be interpolated

✔️ tests/onchain/property-ordering.spec.ts

tests/onchain/property-ordering.spec.ts
  ✔️ Property ordering > it runs

✔️ tests/onchain/shadowed-variables.spec.ts

tests/onchain/shadowed-variables.spec.ts
  ✔️ Shadowed variables > Should create and run

✔️ tests/onchain/state-totals.spec.ts

tests/onchain/state-totals.spec.ts
  ✔️ State totals > BaseWithState has correct totals
  ✔️ State totals > BaseWithState runs
  ✔️ State totals > SubClassWithState has correct totals
  ✔️ State totals > SubClassWithState runs
  ✔️ State totals > SubClassWithExplicitTotals has correct totals
  ✔️ State totals > ExtendsSubWithTotals has correct totals
  ✔️ State totals > ExtendsSubWithTotals runs

✔️ tests/onchain/super-calls.spec.ts

tests/onchain/super-calls.spec.ts
  ✔️ super calls > super contract runs
  ✔️ super calls > sub contract runs
  ✔️ super calls > sub sub contract runs
  ✔️ super calls > sub sub contract runs