diff --git a/test/integration/compiler.ts b/test/integration/compiler.ts index 218670e9bd..f809064618 100644 --- a/test/integration/compiler.ts +++ b/test/integration/compiler.ts @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { readFile } from 'fs/promises'; import { compilerUrl, ignoreVersion } from '.'; +import inclAci from './contracts/Includes.json'; import { CompilerBase, CompilerHttpNode, CompilerCli, CompilerError, getFileSystem, Encoded, } from '../../src'; @@ -30,15 +31,13 @@ function testCompiler(compiler: CompilerBase): void { it('compiles and generates aci by path', async () => { const { bytecode, aci } = await compiler.compile(inclSourceCodePath); expect(bytecode).to.equal(inclBytecode); - expect(aci).to.have.length(6); - expect(aci[aci.length - 1]).to.have.property('contract'); + expect(aci).to.eql(inclAci); }); it('compiles and generates aci by source code', async () => { const { bytecode, aci } = await compiler.compileBySourceCode(inclSourceCode, inclFileSystem); expect(bytecode).to.equal(inclBytecode); - expect(aci).to.have.length(6); - expect(aci[aci.length - 1]).to.have.property('contract'); + expect(aci).to.eql(inclAci); }); it('throws clear exception if compile broken contract', async () => { diff --git a/test/integration/contract-aci.ts b/test/integration/contract-aci.ts index 2f1e7191b6..39cce23c55 100644 --- a/test/integration/contract-aci.ts +++ b/test/integration/contract-aci.ts @@ -23,6 +23,7 @@ import { } from '../utils'; import { Aci } from '../../src/contract/compiler/Base'; import { ContractCallObject } from '../../src/contract/Contract'; +import includesAci from './contracts/Includes.json'; const identityContractSourceCode = ` contract Identity = @@ -207,23 +208,8 @@ describe('Contract instance', () => { it('compiles contract by sourceCodePath', async () => { const ctr = await aeSdk.initializeContract({ - aci: [{ - contract: { - functions: [{ - arguments: [{ name: 'x', type: 'int' }], - name: 'increment', - payable: false, - returns: 'int', - stateful: false, - }, - ], - kind: 'contract_main', - name: 'Increment', - payable: false, - typedefs: [], - }, - }], - sourceCodePath: './test/integration/contracts/Increment.aes', + aci: includesAci, + sourceCodePath: './test/integration/contracts/Includes.aes', }); expect(ctr.$options.bytecode).to.equal(undefined); expect(await ctr.$compile()).to.satisfy((b: string) => b.startsWith('cb_')); diff --git a/test/integration/contracts/Includes.json b/test/integration/contracts/Includes.json new file mode 100644 index 0000000000..564b1c35e0 --- /dev/null +++ b/test/integration/contracts/Includes.json @@ -0,0 +1,31 @@ +[{ + "namespace": { "name": "ListInternal", "typedefs": [] } +}, { + "namespace": { "name": "List", "typedefs": [] } +}, { + "namespace": { "name": "String", "typedefs": [] } +}, { + "namespace": { "name": "Sublibrary", "typedefs": [] } +}, { + "namespace": { "name": "Library", "typedefs": [] } +}, { + "contract": { + "functions": [{ + "arguments": [{ "name": "x", "type": "int" }], + "name": "test", + "payable": false, + "returns": "int", + "stateful": false + }, { + "arguments": [{ "name": "x", "type": "string" }], + "name": "getLength", + "payable": false, + "returns": "int", + "stateful": false + }], + "kind": "contract_main", + "name": "Includes", + "payable": false, + "typedefs": [] + } +}] diff --git a/tsconfig.tests.json b/tsconfig.tests.json index 46a28a8afa..237876c2d3 100644 --- a/tsconfig.tests.json +++ b/tsconfig.tests.json @@ -2,6 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "emitDeclarationOnly": false, + "resolveJsonModule": true, "noEmit": true }, "include": [