diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 563b29c..51d8194 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,11 @@ jobs: run: yarn - name: Run unit tests run: yarn test:unit - - name: Run integration tests - run: yarn test:integration + - name: Run integration tests [basic] + run: yarn test:integration:basic + - name: Run integration tests [internal-writes] + run: yarn test:integration:internal-writes + - name: Run integration tests [wasm] + run: yarn test:integration:wasm - name: Run regression tests run: yarn test:regression diff --git a/package.json b/package.json index 815177d..f4e39a9 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,9 @@ "yalc:publish": "yarn build && yalc publish --push", "test": "jest", "test:unit": "jest ./src/__tests__/unit", - "test:integration": "jest ./src/__tests__/integration", + "test:integration:basic": "jest ./src/__tests__/integration/basic", + "test:integration:internal-writes": "jest ./src/__tests__/integration/internal-writes", + "test:integration:wasm": "jest ./src/__tests__/integration/wasm", "test:regression": "node ./node_modules/.bin/jest ./src/__tests__/regression" }, "license": "MIT", diff --git a/src/__tests__/integration/complicated-contract.test.ts b/src/__tests__/integration/basic/complicated-contract.test.ts similarity index 91% rename from src/__tests__/integration/complicated-contract.test.ts rename to src/__tests__/integration/basic/complicated-contract.test.ts index a78cd60..25ca349 100644 --- a/src/__tests__/integration/complicated-contract.test.ts +++ b/src/__tests__/integration/basic/complicated-contract.test.ts @@ -5,7 +5,7 @@ import Arweave from 'arweave'; import { JWKInterface } from 'arweave/node/lib/wallet'; import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import { addFunds, mineBlock } from './_helpers'; +import { addFunds, mineBlock } from '../_helpers'; let arweave: Arweave; let arlocal: ArLocal; @@ -39,7 +39,7 @@ describe('Testing the SmartWeave client', () => { wallet = await arweave.wallets.generate(); await addFunds(arweave, wallet); - contractSrc = fs.readFileSync(path.join(__dirname, 'data/very-complicated-contract.js'), 'utf8'); + contractSrc = fs.readFileSync(path.join(__dirname, '../data/very-complicated-contract.js'), 'utf8'); // deploying contract using the new SDK. const contractTxId = await smartweave.createContract.deploy({ diff --git a/src/__tests__/integration/deploy-write-read.test.ts b/src/__tests__/integration/basic/deploy-write-read.test.ts similarity index 92% rename from src/__tests__/integration/deploy-write-read.test.ts rename to src/__tests__/integration/basic/deploy-write-read.test.ts index e5b2585..dc138e1 100644 --- a/src/__tests__/integration/deploy-write-read.test.ts +++ b/src/__tests__/integration/basic/deploy-write-read.test.ts @@ -5,7 +5,7 @@ import Arweave from 'arweave'; import { JWKInterface } from 'arweave/node/lib/wallet'; import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import { addFunds, mineBlock } from './_helpers'; +import { addFunds, mineBlock } from '../_helpers'; interface ExampleContractState { counter: number; @@ -50,8 +50,8 @@ describe('Testing the SmartWeave client', () => { wallet = await arweave.wallets.generate(); await addFunds(arweave, wallet); - contractSrc = fs.readFileSync(path.join(__dirname, 'data/example-contract.js'), 'utf8'); - initialState = fs.readFileSync(path.join(__dirname, 'data/example-contract-state.json'), 'utf8'); + contractSrc = fs.readFileSync(path.join(__dirname, '../data/example-contract.js'), 'utf8'); + initialState = fs.readFileSync(path.join(__dirname, '../data/example-contract-state.json'), 'utf8'); // deploying contract using the new SDK. const contractTxId = await smartweave.createContract.deploy({ diff --git a/src/__tests__/integration/file-cache.test.ts b/src/__tests__/integration/basic/file-cache.test.ts similarity index 93% rename from src/__tests__/integration/file-cache.test.ts rename to src/__tests__/integration/basic/file-cache.test.ts index 8dba3ad..b473de1 100644 --- a/src/__tests__/integration/file-cache.test.ts +++ b/src/__tests__/integration/basic/file-cache.test.ts @@ -5,8 +5,8 @@ import Arweave from 'arweave'; import { JWKInterface } from 'arweave/node/lib/wallet'; import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import { TsLogFactory } from '../../logging/node/TsLogFactory'; -import { addFunds, mineBlock } from './_helpers'; +import { TsLogFactory } from '../../../logging/node/TsLogFactory'; +import { addFunds, mineBlock } from '../_helpers'; interface ExampleContractState { counter: number; @@ -49,8 +49,8 @@ describe('Testing the SmartWeave client', () => { wallet = await arweave.wallets.generate(); await addFunds(arweave, wallet); - contractSrc = fs.readFileSync(path.join(__dirname, 'data/example-contract.js'), 'utf8'); - initialState = fs.readFileSync(path.join(__dirname, 'data/example-contract-state.json'), 'utf8'); + contractSrc = fs.readFileSync(path.join(__dirname, '../data/example-contract.js'), 'utf8'); + initialState = fs.readFileSync(path.join(__dirname, '../data/example-contract-state.json'), 'utf8'); // deploying contract using the new SDK. const contractTxId = await smartweave.createContract.deploy({ diff --git a/src/__tests__/integration/inf-loop.test.ts b/src/__tests__/integration/basic/inf-loop.test.ts similarity index 94% rename from src/__tests__/integration/inf-loop.test.ts rename to src/__tests__/integration/basic/inf-loop.test.ts index d402204..ef81359 100644 --- a/src/__tests__/integration/inf-loop.test.ts +++ b/src/__tests__/integration/basic/inf-loop.test.ts @@ -5,7 +5,7 @@ import Arweave from 'arweave'; import { JWKInterface } from 'arweave/node/lib/wallet'; import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory, timeout } from '@smartweave'; import path from 'path'; -import { addFunds, mineBlock } from './_helpers'; +import { addFunds, mineBlock } from '../_helpers'; let arweave: Arweave; let arlocal: ArLocal; @@ -40,7 +40,7 @@ describe('Testing the SmartWeave client', () => { wallet = await arweave.wallets.generate(); await addFunds(arweave, wallet); - contractSrc = fs.readFileSync(path.join(__dirname, 'data/inf-loop-contract.js'), 'utf8'); + contractSrc = fs.readFileSync(path.join(__dirname, '../data/inf-loop-contract.js'), 'utf8'); // deploying contract using the new SDK. const contractTxId = await smartweave.createContract.deploy({ diff --git a/src/__tests__/integration/knex-cache.test.ts b/src/__tests__/integration/basic/knex-cache.test.ts similarity index 95% rename from src/__tests__/integration/knex-cache.test.ts rename to src/__tests__/integration/basic/knex-cache.test.ts index b22591a..aa0c9d1 100644 --- a/src/__tests__/integration/knex-cache.test.ts +++ b/src/__tests__/integration/basic/knex-cache.test.ts @@ -5,8 +5,8 @@ import Arweave from 'arweave'; import { JWKInterface } from 'arweave/node/lib/wallet'; import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import { TsLogFactory } from '../../logging/node/TsLogFactory'; -import { addFunds, mineBlock } from './_helpers'; +import { TsLogFactory } from '../../../logging/node/TsLogFactory'; +import { addFunds, mineBlock } from '../_helpers'; import knex from 'knex'; interface ExampleContractState { @@ -60,8 +60,8 @@ describe('Testing the SmartWeave client', () => { wallet = await arweave.wallets.generate(); await addFunds(arweave, wallet); - contractSrc = fs.readFileSync(path.join(__dirname, 'data/example-contract.js'), 'utf8'); - initialState = fs.readFileSync(path.join(__dirname, 'data/example-contract-state.json'), 'utf8'); + contractSrc = fs.readFileSync(path.join(__dirname, '../data/example-contract.js'), 'utf8'); + initialState = fs.readFileSync(path.join(__dirname, '../data/example-contract-state.json'), 'utf8'); // deploying contract using the new SDK. const contractTxId1 = await smartweave.createContract.deploy({ diff --git a/src/__tests__/integration/pst-filecached.test.ts b/src/__tests__/integration/basic/pst-filecached.test.ts similarity index 93% rename from src/__tests__/integration/pst-filecached.test.ts rename to src/__tests__/integration/basic/pst-filecached.test.ts index 378744f..7e6ae88 100644 --- a/src/__tests__/integration/pst-filecached.test.ts +++ b/src/__tests__/integration/basic/pst-filecached.test.ts @@ -12,7 +12,7 @@ import { SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import { addFunds, mineBlock } from './_helpers'; +import { addFunds, mineBlock } from '../_helpers'; describe('Testing the Profit Sharing Token', () => { let contractSrc: string; @@ -52,8 +52,8 @@ describe('Testing the Profit Sharing Token', () => { await addFunds(arweave, wallet); walletAddress = await arweave.wallets.jwkToAddress(wallet); - contractSrc = fs.readFileSync(path.join(__dirname, 'data/token-pst.js'), 'utf8'); - const stateFromFile: PstState = JSON.parse(fs.readFileSync(path.join(__dirname, 'data/token-pst.json'), 'utf8')); + contractSrc = fs.readFileSync(path.join(__dirname, '../data/token-pst.js'), 'utf8'); + const stateFromFile: PstState = JSON.parse(fs.readFileSync(path.join(__dirname, '../data/token-pst.json'), 'utf8')); initialState = { ...stateFromFile, @@ -117,7 +117,7 @@ describe('Testing the Profit Sharing Token', () => { it("should properly evolve contract's source code", async () => { expect((await pst.currentState()).balances[walletAddress]).toEqual(555114); - const newSource = fs.readFileSync(path.join(__dirname, 'data/token-evolve.js'), 'utf8'); + const newSource = fs.readFileSync(path.join(__dirname, '../data/token-evolve.js'), 'utf8'); const newSrcTxId = await pst.saveNewSource(newSource); await mineBlock(arweave); diff --git a/src/__tests__/integration/pst.test.ts b/src/__tests__/integration/basic/pst.test.ts similarity index 93% rename from src/__tests__/integration/pst.test.ts rename to src/__tests__/integration/basic/pst.test.ts index 194f0c0..ab343a2 100644 --- a/src/__tests__/integration/pst.test.ts +++ b/src/__tests__/integration/basic/pst.test.ts @@ -12,7 +12,7 @@ import { SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import { addFunds, mineBlock } from './_helpers'; +import { addFunds, mineBlock } from '../_helpers'; describe('Testing the Profit Sharing Token', () => { let contractSrc: string; @@ -47,8 +47,8 @@ describe('Testing the Profit Sharing Token', () => { await addFunds(arweave, wallet); walletAddress = await arweave.wallets.jwkToAddress(wallet); - contractSrc = fs.readFileSync(path.join(__dirname, 'data/token-pst.js'), 'utf8'); - const stateFromFile: PstState = JSON.parse(fs.readFileSync(path.join(__dirname, 'data/token-pst.json'), 'utf8')); + contractSrc = fs.readFileSync(path.join(__dirname, '../data/token-pst.js'), 'utf8'); + const stateFromFile: PstState = JSON.parse(fs.readFileSync(path.join(__dirname, '../data/token-pst.json'), 'utf8')); initialState = { ...stateFromFile, @@ -111,7 +111,7 @@ describe('Testing the Profit Sharing Token', () => { it("should properly evolve contract's source code", async () => { expect((await pst.currentState()).balances[walletAddress]).toEqual(555114); - const newSource = fs.readFileSync(path.join(__dirname, 'data/token-evolve.js'), 'utf8'); + const newSource = fs.readFileSync(path.join(__dirname, '../data/token-evolve.js'), 'utf8'); const newSrcTxId = await pst.saveNewSource(newSource); await mineBlock(arweave); diff --git a/src/__tests__/integration/wasm/as-deploy-write-read.test.ts b/src/__tests__/integration/wasm/as-deploy-write-read.test.ts index 40bbf8c..f644f19 100644 --- a/src/__tests__/integration/wasm/as-deploy-write-read.test.ts +++ b/src/__tests__/integration/wasm/as-deploy-write-read.test.ts @@ -60,7 +60,7 @@ describe('Testing the SmartWeave client for AssemblyScript WASM contract', () => contract.connect(wallet); await mineBlock(arweave); - }); + }, 50000); afterAll(async () => { await arlocal.stop(); @@ -110,7 +110,7 @@ describe('Testing the SmartWeave client for AssemblyScript WASM contract', () => function: 'increment' }); - expect(result.gasUsed).toEqual(12284823); + expect(result.gasUsed).toEqual(12316793); }); it('should return stable gas results', async () => { @@ -125,7 +125,7 @@ describe('Testing the SmartWeave client for AssemblyScript WASM contract', () => } results.forEach((result) => { - expect(result.gasUsed).toEqual(12284823); + expect(result.gasUsed).toEqual(12316793); }); });