Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions tests/arc4/bool.algo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { Bytes } from '@algorandfoundation/algorand-typescript'
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { Bool, convertBytes } from '@algorandfoundation/algorand-typescript/arc4'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { ABI_RETURN_VALUE_LOG_PREFIX } from '../../src/constants'
import { asUint8Array } from '../../src/util'
import { getAvmResult } from '../avm-invoker'
import { createArc4TestFixture } from '../test-fixture'

describe('arc4.Bool', async () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/arc4-primitive-ops/contract.algo.ts', {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
const test = createArc4TestFixture({
path: 'tests/artifacts/arc4-primitive-ops/contract.algo.ts',
contracts: {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
},
})
const ctx = new TestExecutionContext()

beforeAll(async () => {
await localnetFixture.newScope()
})

afterEach(() => {
ctx.reset()
})
Expand Down
12 changes: 6 additions & 6 deletions tests/arc4/byte.algo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import { Bytes } from '@algorandfoundation/algorand-typescript'
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { Byte, convertBytes } from '@algorandfoundation/algorand-typescript/arc4'
import { encodingUtil } from '@algorandfoundation/puya-ts'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { ABI_RETURN_VALUE_LOG_PREFIX, MAX_UINT64 } from '../../src/constants'
import { asBigUintCls, asUint8Array } from '../../src/util'
import { getAvmResult } from '../avm-invoker'
import { createArc4TestFixture } from '../test-fixture'

const invalidBytesLengthError = 'byte string must be 1 byte long'
describe('arc4.Byte', async () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/arc4-primitive-ops/contract.algo.ts', {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
const test = createArc4TestFixture({
path: 'tests/artifacts/arc4-primitive-ops/contract.algo.ts',
contracts: {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
},
})

const ctx = new TestExecutionContext()

beforeAll(async () => {
await localnetFixture.newScope()
})
afterEach(() => {
ctx.reset()
})
Expand Down
15 changes: 7 additions & 8 deletions tests/arc4/circular-reference.algo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { algo } from '@algorandfoundation/algokit-utils'
import { methodSelector } from '@algorandfoundation/algorand-typescript/arc4'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { ApplicationSpy } from '../../src/application-spy'
import { TestExecutionContext } from '../../src/test-execution-context'
import { ContractTwo } from '../artifacts/circurlar-reference/circular-reference-2.algo'
Expand All @@ -9,13 +9,12 @@ import { createArc4TestFixture } from '../test-fixture'

describe('circular reference', () => {
const ctx = new TestExecutionContext()
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/circurlar-reference', {
ContractOne: { funding: algo(1) },
ContractTwo: { funding: algo(1) },
})

beforeAll(async () => {
await localnetFixture.newScope()
const test = createArc4TestFixture({
path: 'tests/artifacts/circurlar-reference',
contracts: {
ContractOne: { funding: algo(1) },
ContractTwo: { funding: algo(1) },
},
})

afterEach(() => {
Expand Down
13 changes: 6 additions & 7 deletions tests/arc4/emit.algo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { biguint, bytes, uint64 } from '@algorandfoundation/algorand-typescript'
import { arc4, BigUint, Bytes, emit, Uint64 } from '@algorandfoundation/algorand-typescript'
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { MAX_UINT512, MAX_UINT64 } from '../../src/constants'
import { getAvmResultLog } from '../avm-invoker'

Expand Down Expand Up @@ -41,15 +41,14 @@ class SwappedArc4 extends arc4.Struct<{
}> {}

describe('arc4.emit', async () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/arc4-primitive-ops/contract.algo.ts', {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
const test = createArc4TestFixture({
path: 'tests/artifacts/arc4-primitive-ops/contract.algo.ts',
contracts: {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
},
})
const ctx = new TestExecutionContext()

beforeAll(async () => {
await localnetFixture.newScope()
})

afterEach(() => {
ctx.reset()
})
Expand Down
17 changes: 8 additions & 9 deletions tests/arc4/method-selector.algo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { arc4, Bytes, Global, Uint64 } from '@algorandfoundation/algorand-typesc
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { DynamicArray, methodSelector } from '@algorandfoundation/algorand-typescript/arc4'
import { encodingUtil } from '@algorandfoundation/puya-ts'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { toBytes } from '../../src/impl/encoded-types/encoded-types'
import { encodeAddress } from '../../src/impl/reference'
import { AnotherStruct, MyStruct, SignaturesContract } from '../artifacts/arc4-abi-method/contract.algo'
Expand All @@ -15,17 +15,16 @@ const _FUNDED_ACCOUNT_SPENDING = Uint64(1234)

describe('methodSelector', async () => {
const ctx = new TestExecutionContext()
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/arc4-abi-method/contract.algo.ts', {
SignaturesContract: {
deployParams: { createParams: { extraProgramPages: undefined, method: 'create' } },
funding: new AlgoAmount({ microAlgos: Global.minBalance + _FUNDED_ACCOUNT_SPENDING }),
const test = createArc4TestFixture({
path: 'tests/artifacts/arc4-abi-method/contract.algo.ts',
contracts: {
SignaturesContract: {
deployParams: { createParams: { extraProgramPages: undefined, method: 'create' } },
funding: new AlgoAmount({ microAlgos: Global.minBalance + _FUNDED_ACCOUNT_SPENDING }),
},
},
})

beforeAll(async () => {
await localnetFixture.newScope()
})

afterEach(() => {
ctx.reset()
})
Expand Down
17 changes: 8 additions & 9 deletions tests/arc4/resource-encoding.algo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { algo } from '@algorandfoundation/algokit-utils'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { TestExecutionContext } from '../../src/test-execution-context'
import { createArc4TestFixture } from '../test-fixture'

describe('resource encoding', () => {
const ctx = new TestExecutionContext()
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/resource-encoding/contract.algo.ts', {
ByIndex: {},
ByValue: {},
C2C: { funding: algo(1) },
})

beforeAll(async () => {
await localnetFixture.newScope()
const test = createArc4TestFixture({
path: 'tests/artifacts/resource-encoding/contract.algo.ts',
contracts: {
ByIndex: {},
ByValue: {},
C2C: { funding: algo(1) },
},
})

afterEach(() => {
Expand Down
12 changes: 6 additions & 6 deletions tests/arc4/str.algo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { Bytes } from '@algorandfoundation/algorand-typescript'
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { convertBytes, Str } from '@algorandfoundation/algorand-typescript/arc4'
import { encodingUtil } from '@algorandfoundation/puya-ts'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { ABI_RETURN_VALUE_LOG_PREFIX, MAX_LOG_SIZE } from '../../src/constants'
import { asUint8Array } from '../../src/util'
import { getAvmResult } from '../avm-invoker'
import { createArc4TestFixture } from '../test-fixture'

describe('arc4.Str', async () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/arc4-primitive-ops/contract.algo.ts', {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
const test = createArc4TestFixture({
path: 'tests/artifacts/arc4-primitive-ops/contract.algo.ts',
contracts: {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
},
})
const ctx = new TestExecutionContext()

beforeAll(async () => {
await localnetFixture.newScope()
})
afterEach(() => {
ctx.reset()
})
Expand Down
12 changes: 6 additions & 6 deletions tests/arc4/ufixednxm.algo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import { Bytes } from '@algorandfoundation/algorand-typescript'
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { convertBytes, UFixed } from '@algorandfoundation/algorand-typescript/arc4'
import { encodingUtil } from '@algorandfoundation/puya-ts'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { ABI_RETURN_VALUE_LOG_PREFIX } from '../../src/constants'
import { asBigUint, asUint8Array } from '../../src/util'
import { getAvmResult } from '../avm-invoker'
import { createArc4TestFixture } from '../test-fixture'

const invalidBytesLengthError = (length: number) => `byte string must correspond to a ufixed${length}`
describe('arc4.UFixed', async () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/arc4-primitive-ops/contract.algo.ts', {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
const test = createArc4TestFixture({
path: 'tests/artifacts/arc4-primitive-ops/contract.algo.ts',
contracts: {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
},
})
const ctx = new TestExecutionContext()

beforeAll(async () => {
await localnetFixture.newScope()
})
afterEach(() => {
ctx.reset()
})
Expand Down
12 changes: 6 additions & 6 deletions tests/arc4/uintn.algo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-te
import type { BitSize } from '@algorandfoundation/algorand-typescript/arc4'
import { convertBytes, Uint, Uint16, Uint256, Uint32, Uint8 } from '@algorandfoundation/algorand-typescript/arc4'
import { encodingUtil } from '@algorandfoundation/puya-ts'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { ABI_RETURN_VALUE_LOG_PREFIX, MAX_UINT512, MAX_UINT64 } from '../../src/constants'
import { asBigUintCls, asUint8Array } from '../../src/util'
import { getAvmResult } from '../avm-invoker'
import { createArc4TestFixture } from '../test-fixture'

const invalidBytesLengthError = (length: number) => `byte string must correspond to a uint${length}`
describe('arc4.Uint', async () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/arc4-primitive-ops/contract.algo.ts', {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
const test = createArc4TestFixture({
path: 'tests/artifacts/arc4-primitive-ops/contract.algo.ts',
contracts: {
Arc4PrimitiveOpsContract: { deployParams: { createParams: { extraProgramPages: undefined } } },
},
})
const ctx = new TestExecutionContext()

beforeAll(async () => {
await localnetFixture.newScope()
})
afterEach(() => {
ctx.reset()
})
Expand Down
13 changes: 7 additions & 6 deletions tests/avm12.algo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { algos } from '@algorandfoundation/algokit-utils'
import { ApplicationSpy, TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import { Avm12Contract, ContractV0, ContractV1 } from './artifacts/avm12/contract.algo'
import { createArc4TestFixture } from './test-fixture'

describe('avm12', () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/avm12/contract.algo.ts', {
Avm12Contract: { funding: algos(1) },
const test = createArc4TestFixture({
path: 'tests/artifacts/avm12/contract.algo.ts',
contracts: {
Avm12Contract: { funding: algos(1) },
},
})

const ctx = new TestExecutionContext()
beforeAll(async () => {
await localnetFixture.newScope()
})

afterEach(() => {
ctx.reset()
})
Expand Down
12 changes: 4 additions & 8 deletions tests/crypto-op-codes.algo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import js_sha3 from 'js-sha3'
import js_sha512 from 'js-sha512'
import nacl from 'tweetnacl'
import type { Mock } from 'vitest'
import { afterEach, beforeAll, describe, expect, vi } from 'vitest'
import { afterEach, describe, expect, vi } from 'vitest'
import { TestExecutionContext } from '../src'
import { LOGIC_DATA_PREFIX, MAX_BYTES_SIZE, PROGRAM_TAG } from '../src/constants'
import { BytesCls, Uint64Cls } from '../src/impl/primitives'
Expand Down Expand Up @@ -35,13 +35,9 @@ vi.mock('../src/impl/crypto', async (importOriginal) => {
})

describe('crypto op codes', async () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/crypto-ops/contract.algo.ts', { CryptoOpsContract: {} })
const test = createArc4TestFixture({ path: 'tests/artifacts/crypto-ops/contract.algo.ts', contracts: { CryptoOpsContract: {} } })
const ctx = new TestExecutionContext()

beforeAll(async () => {
await localnetFixture.newScope()
})

afterEach(() => {
ctx.reset()
})
Expand Down Expand Up @@ -125,15 +121,15 @@ describe('crypto op codes', async () => {
})

describe('ed25519verify', async () => {
test('should return true for valid signature', async ({ appFactoryCryptoOpsContract }) => {
test('should return true for valid signature', async ({ appFactoryCryptoOpsContract, localnet }) => {
const app = await appFactoryCryptoOpsContract.deploy({})
const approval = app.result.compiledApproval!
const appCallTxn = ctx.any.txn.applicationCall({
approvalProgram: Bytes(approval.compiledBase64ToBytes),
})

const message = Bytes('Test message for ed25519 verification')
const account = await localnetFixture.context.generateAccount({
const account = await localnet.context.generateAccount({
initialFunds: AlgoAmount.MicroAlgos(INITIAL_BALANCE_MICRO_ALGOS + 100_000),
})

Expand Down
13 changes: 6 additions & 7 deletions tests/global-state-arc4-values.algo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ import { Bytes, Uint64 } from '@algorandfoundation/algorand-typescript'
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import type { ARC4Encoded } from '@algorandfoundation/algorand-typescript/arc4'
import { Address, Bool, Byte, DynamicBytes, Str, Uint } from '@algorandfoundation/algorand-typescript/arc4'
import { afterEach, beforeAll, describe, expect } from 'vitest'
import { afterEach, describe, expect } from 'vitest'
import type { DeliberateAny, FunctionKeys } from '../src/typescript-helpers'
import { asUint8Array } from '../src/util'
import { GlobalStateContract } from './artifacts/state-ops/contract.algo'
import { getAvmResult } from './avm-invoker'
import { createArc4TestFixture } from './test-fixture'

describe('ARC4 AppGlobal values', async () => {
const [test, localnetFixture] = createArc4TestFixture('tests/artifacts/state-ops/contract.algo.ts', {
GlobalStateContract: {},
const test = createArc4TestFixture({
path: 'tests/artifacts/state-ops/contract.algo.ts',
contracts: {
GlobalStateContract: {},
},
})
const ctx = new TestExecutionContext()

beforeAll(async () => {
await localnetFixture.newScope()
})

afterEach(() => {
ctx.reset()
})
Expand Down
Loading