refactor: integration tests structure refactor
This commit is contained in:
8
.github/workflows/tests.yml
vendored
8
.github/workflows/tests.yml
vendored
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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({
|
||||
@@ -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({
|
||||
@@ -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({
|
||||
@@ -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({
|
||||
@@ -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({
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user