Skip to content

Commit

Permalink
fix(tests): reconfigure test structure
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Aug 20, 2024
1 parent 27a5dc2 commit 1872a26
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 44 deletions.
47 changes: 25 additions & 22 deletions tests/e2e/cjs/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { describe, it, before } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
/**
* Ensure that npm link has been ran prior to running these tests
* (simply running npm run test:integration will ensure npm link is ran)
Expand All @@ -16,8 +17,14 @@ const {
AoANTRegistryWriteable,
} = require('@ar.io/sdk');

const testWalletJSON = require('../test-wallet.json');
const testWalletJSON = fs.readFileSync('../test-wallet.json', {
encoding: 'utf-8',
});
const testWallet = JSON.parse(testWalletJSON);
const signers = [
new ArweaveSigner(testWallet),
createAoSigner(new ArweaveSigner(testWallet)),
];

const io = IO.init({
processId: ioDevnetProcessId,
Expand Down Expand Up @@ -278,6 +285,14 @@ describe('IO', async () => {
});
assert.ok(tokenCost);
});

it('should be able to create IOWriteable with valid signers', async () => {
for (const signer of signers) {
const io = IO.init({ signer });

assert(io instanceof IOWriteable);
}
});
});

describe('ANTRegistry', async () => {
Expand All @@ -289,22 +304,19 @@ describe('ANTRegistry', async () => {
assert(Array.isArray(affiliatedAnts.Owned));
assert(Array.isArray(affiliatedAnts.Controlled));
});
});

describe('Signing', async () => {
const signers = [
new ArweaveSigner(testWallet),
createAoSigner(new ArweaveSigner(testWallet)),
];

it('Should be able to sign on the IO contract with all ContractSigner types', async () => {
it('should be able to create AoANTRegistryWriteable with valid signers', async () => {
for (const signer of signers) {
const io = IO.init({ signer });

assert(io instanceof IOWriteable);
const registry = ANTRegistry.init({
signer,
});
assert(registry instanceof AoANTRegistryWriteable);
}
});
it('Should be able to sign on ANTs with all ContractSigner types', async () => {
});

describe('ANT', async () => {
it('should be able to create ANTWriteable with valid signers', async () => {
for (const signer of signers) {
const ant = ANT.init({
processId: 'aWI_dq1JH7facsulLuas1X3l5dkKuWtixcZDYMw9mpg',
Expand All @@ -314,13 +326,4 @@ describe('Signing', async () => {
assert(ant instanceof AoANTWriteable);
}
});

it('Should be able to sign on ANTRegistry with all ContractSigner types', async () => {
for (const signer of signers) {
const registry = ANTRegistry.init({
signer,
});
assert(registry instanceof AoANTRegistryWriteable);
}
});
});
50 changes: 28 additions & 22 deletions tests/e2e/esm/index.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import {
ANT,
ANTRegistry,
AoANTRegistryWriteable,
AoANTWriteable,
ArweaveSigner,
IO,
IOWriteable,
createAoSigner,
ioDevnetProcessId,
} from '@ar.io/sdk';
import { strict as assert } from 'node:assert';
import fs from 'node:fs';
import { describe, it } from 'node:test';

import testWalletJSON from '../test-wallet.json';
const testWalletJSON = fs.readFileSync('../test-wallet.json', {
encoding: 'utf-8',
});

const testWallet = JSON.parse(testWalletJSON);
const signers = [
new ArweaveSigner(testWallet),
createAoSigner(new ArweaveSigner(testWallet)),
];

/**
* Ensure that npm link has been ran prior to running these tests
Expand Down Expand Up @@ -278,6 +288,14 @@ describe('IO', async () => {
});
assert.ok(tokenCost);
});

it('should be able to create IOWriteable with valid signers', async () => {
for (const signer of signers) {
const io = IO.init({ signer });

assert(io instanceof IOWriteable);
}
});
});

describe('ANTRegistry', async () => {
Expand All @@ -289,22 +307,19 @@ describe('ANTRegistry', async () => {
assert(Array.isArray(affiliatedAnts.Owned));
assert(Array.isArray(affiliatedAnts.Controlled));
});
});

describe('Signing', async () => {
const signers = [
new ArweaveSigner(testWallet),
createAoSigner(new ArweaveSigner(testWallet)),
];

it('Should be able to sign on the IO contract with all ContractSigner types', async () => {
it('should be able to create AoANTRegistryWriteable with valid signers', async () => {
for (const signer of signers) {
const io = IO.init({ signer });

assert(io instanceof IOWriteable);
const registry = ANTRegistry.init({
signer,
});
assert(registry instanceof AoANTRegistryWriteable);
}
});
it('Should be able to sign on ANTs with all ContractSigner types', async () => {
});

describe('ANT', async () => {
it('should be able to create ANTWriteable with valid signers', async () => {
for (const signer of signers) {
const ant = ANT.init({
processId: 'aWI_dq1JH7facsulLuas1X3l5dkKuWtixcZDYMw9mpg',
Expand All @@ -314,13 +329,4 @@ describe('Signing', async () => {
assert(ant instanceof AoANTWriteable);
}
});

it('Should be able to sign on ANTRegistry with all ContractSigner types', async () => {
for (const signer of signers) {
const registry = ANTRegistry.init({
signer,
});
assert(registry instanceof AoANTRegistryWriteable);
}
});
});

0 comments on commit 1872a26

Please sign in to comment.