Skip to content

Commit

Permalink
fix(test warp-contract): use beforeAll to read env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 27, 2024
1 parent d39391c commit 95cc019
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ lib
**/*.mjs
examples
jest.config.ts
jest.integration.config.ts
File renamed without changes.
2 changes: 1 addition & 1 deletion jest.integration.config.cjs → jest.integration.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
globalTeardown: './tests/integration/jest.teardown.ts',
clearMocks: true,
moduleFileExtensions: ['ts', 'js', 'mjs'],
testMatch: ['**/src/**/*.test.ts', '**/tests/**/*.test.ts'],
testMatch: ['**/tests/**/*.test.ts'],
collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts', 'tests/**/*.ts'],
testEnvironment: 'node',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"format": "prettier --check .",
"format:fix": "prettier --write .",
"test": "yarn clean && jest .",
"test:integration": "docker compose up -d && yarn test --config=jest.integration.config.cjs && docker compose down",
"test:integration": "docker compose up -d && yarn test --config=jest.integration.config.ts && docker compose down",
"prepare": "husky install",
"example:mjs": "yarn build:esm && node examples/node/index.mjs",
"example:cjs": "yarn build:cjs && node examples/node/index.cjs",
Expand Down
25 changes: 15 additions & 10 deletions tests/integration/warp-contract.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { ArweaveSigner } from 'arbundles';
import { Transaction, WarpFactory, defaultCacheOptions } from 'warp-contracts';
import { Transaction } from 'warp-contracts';

import { WarpContract } from '../../src/common/contracts/warp-contract';
import { WriteInteractionError } from '../../src/common/error';
import { ANTState } from '../../src/contract-state';
import { arweave, localCacheUrl } from '../constants';

const contractTxId = process.env.DEPLOYED_ANT_CONTRACT_TX_ID!;
import { arweave, localCacheUrl, warp } from '../constants';

describe('warp-contract client', () => {
const signer = new ArweaveSigner(JSON.parse(process.env.PRIMARY_WALLET_JWK!));
const contract: WarpContract<ANTState> = new WarpContract<ANTState>({
cacheUrl: localCacheUrl,
contractTxId,
warp: WarpFactory.forMainnet(defaultCacheOptions, true, arweave),
arweave,
let signer: ArweaveSigner;
let contractTxId: string;
let contract: WarpContract<ANTState>;

beforeAll(() => {
contractTxId = process.env.DEPLOYED_ANT_CONTRACT_TX_ID!;
signer = new ArweaveSigner(JSON.parse(process.env.PRIMARY_WALLET_JWK!));
contract = new WarpContract<ANTState>({
cacheUrl: localCacheUrl,
contractTxId,
warp,
});
});

it('should connect and return a valid instance', async () => {
expect(contract.connect(signer)).toBeDefined();
expect(contract).toBeInstanceOf(WarpContract);
Expand Down

0 comments on commit 95cc019

Please sign in to comment.