Skip to content

Commit

Permalink
fix(tests): use test-wallet fixture in tests instead of generating an…
Browse files Browse the repository at this point in the history
…ew each time
  • Loading branch information
atticusofsparta committed Aug 19, 2024
1 parent 0d7f210 commit 27a5dc2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 78 deletions.
23 changes: 13 additions & 10 deletions tests/e2e/cjs/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ const {
ANT,
createAoSigner,
ArweaveSigner,
IOWriteable,
AoANTWriteable,
AoANTRegistryWriteable,
} = require('@ar.io/sdk');
const Arweave = require('arweave');

const arweave = Arweave.init({});
const testWalletJSON = require('../test-wallet.json');
const testWallet = JSON.parse(testWalletJSON);

const io = IO.init({
processId: ioDevnetProcessId,
});
Expand Down Expand Up @@ -288,17 +292,16 @@ describe('ANTRegistry', async () => {
});

describe('Signing', async () => {
let signers = [];
before(async () => {
const jwk = await arweave.wallets.generate();
signers = [new ArweaveSigner(jwk), createAoSigner(new ArweaveSigner(jwk))];
});
const signers = [
new ArweaveSigner(testWallet),
createAoSigner(new ArweaveSigner(testWallet)),
];

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

assert(io);
assert(io instanceof IOWriteable);
}
});
it('Should be able to sign on ANTs with all ContractSigner types', async () => {
Expand All @@ -308,7 +311,7 @@ describe('Signing', async () => {
signer,
});

assert(ant);
assert(ant instanceof AoANTWriteable);
}
});

Expand All @@ -317,7 +320,7 @@ describe('Signing', async () => {
const registry = ANTRegistry.init({
signer,
});
assert(registry);
assert(registry instanceof AoANTRegistryWriteable);
}
});
});
24 changes: 13 additions & 11 deletions tests/e2e/esm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import {
createAoSigner,
ioDevnetProcessId,
} from '@ar.io/sdk';
import Arweave from 'arweave';
import { strict as assert } from 'node:assert';
import { before, describe, it } from 'node:test';
import { describe, it } from 'node:test';

import testWalletJSON from '../test-wallet.json';

const testWallet = JSON.parse(testWalletJSON);

/**
* Ensure that npm link has been ran prior to running these tests
Expand All @@ -18,7 +21,7 @@ import { before, describe, it } from 'node:test';
const io = IO.init({
processId: ioDevnetProcessId,
});
const arweave = Arweave.init({});

describe('IO', async () => {
it('should be able to get the process information', async () => {
const epoch = await io.getInfo();
Expand Down Expand Up @@ -289,17 +292,16 @@ describe('ANTRegistry', async () => {
});

describe('Signing', async () => {
let signers = [];
before(async () => {
const jwk = await arweave.wallets.generate();
signers = [new ArweaveSigner(jwk), createAoSigner(new ArweaveSigner(jwk))];
});
const signers = [
new ArweaveSigner(testWallet),
createAoSigner(new ArweaveSigner(testWallet)),
];

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

assert(io);
assert(io instanceof IOWriteable);
}
});
it('Should be able to sign on ANTs with all ContractSigner types', async () => {
Expand All @@ -309,7 +311,7 @@ describe('Signing', async () => {
signer,
});

assert(ant);
assert(ant instanceof AoANTWriteable);
}
});

Expand All @@ -318,7 +320,7 @@ describe('Signing', async () => {
const registry = ANTRegistry.init({
signer,
});
assert(registry);
assert(registry instanceof AoANTRegistryWriteable);
}
});
});
11 changes: 11 additions & 0 deletions tests/e2e/test-wallet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"kty": "RSA",
"n": "s-Whr7NsoyY0x5nFZDAXIzLymEQvK-9ZW_-cH7TKfnxJn24Z9KndUl8fuE_7QRP2VUmlcTM-YjeS7maw68CZrk_2VKbxnN1Gcvj1SqfuvdnZ0aDgD-FQVEpnOWtAToAEZrV-mwiXBHGEIr8_ntmw4TZJwXmNjVUEhA4rVekKDGHD2k-mooc1wliNG-WMS5e-6Qbor_WNbI0G7HI1WJ46qgMZr4aK2OV1WkwL7Z-5xtSUKLJJJ9Uw1BJvjxaOPo3Eu6zJGxnTGMt3xKSD4ZnJV5H16W9609OTURLezVoIQ8VxmF5W_2sawueAp3g2x4dAwaBIhrfQVjn-Fq7bpTKF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ilUwIkP8FHqeAE5WBeV0CfIpxE7Q_7qgaDJT3ycp9KaFzjWzBPEFeejcLF3dtrrDeBZwKZDPiN44ISsrrMDktBHrn-GjjVBZ6badkYP4Adh7shkYCxWZ30rcZ9p3fsZx1Qi4-qx9jES_56Zht72mmyCeHLB9uwzABbuc8_8WoX2TT_onTMUX-0GqHwaXgDs3zOMJjuaw9UPRgnbPBib5itF5Vr-ZawH4SJ5AMDDka4L2uL62F7-yDuEe7pntG4VQ",
"qi": "PYzb643Ko2kHMwP7z44xAoldwzvKfKy-5rKjifzpJ-oX3Nsec99goV5JfDXDDmZhJmfqX93L9znEIFmA17dwzwJ6Gho2ReqDacze-SQNyKywuE77b5XXvCx-lVx1DWS0DTR7ykUkf8K6Pl6JKHNpc0FAeK8olk0PdqVf-TvXE8NjHc1vDsxwK2woiUkizyd-Xn054U1Abe_sy7_gwFFCNo7nUFJxk6AG4v4yinbxn8dAmAATh37sPnB3U4Ac4yNfFYSqf6HZzCMyt2UlPZsLKLZP2OtHoYaHWJWoZjfyChbaEleXTvaDIGzrgrnsOH5fsCvGie1zZAs1X7DhvCiTTQ"
}
57 changes: 0 additions & 57 deletions tests/utils.ts

This file was deleted.

0 comments on commit 27a5dc2

Please sign in to comment.