Skip to content

Commit

Permalink
fix(ant): add signer to ant test
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 20, 2024
1 parent c7f8eee commit 4581b8d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export type ArIOSigner = ArweaveSigner | ArconnectSigner;
export type ContractConfiguration = {
signer?: ArIOSigner; // TODO: optionally allow JWK in place of signer
} & (
| {
| {
contract?: SmartWeaveContract<unknown>;
}
| {
| {
contractTxId: string;
}
);
);

export function isContractConfiguration<T>(
config: ContractConfiguration,
Expand Down
32 changes: 23 additions & 9 deletions tests/ant.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import { ArweaveSigner } from 'arbundles';
import Arweave from 'arweave';

import { ANT } from '../src/common/ant';
import { RemoteContract } from '../src/common/contracts/remote-contract';
import { ANTState } from '../src/contract-state';

const arweave = Arweave.init({
host: 'arweave.net',
protocol: 'https',
port: 443,
});
const sortKey =
'000001383961,0000000000000,13987aba2d71b6229989690c15d2838a4deef0a90c3fc9e4d7227ed17e35d0bd';
const blockHeight = 1383961;
describe('ANT contract apis', () => {
const ant = new ANT({
contract: new RemoteContract<ANTState>({
url: process.env.REMOTE_CACHE_URL || 'http://localhost:3000',
contractTxId: 'UC2zwawQoTnh0TNd9mYLQS4wObBBeaOU5LPQTNETqA4',
}),
});
let ant: ANT;

const sortKey =
'000001383961,0000000000000,13987aba2d71b6229989690c15d2838a4deef0a90c3fc9e4d7227ed17e35d0bd';
const blockHeight = 1383961;
beforeAll(async () => {
const jwk = await arweave.wallets.generate();
const signer = new ArweaveSigner(jwk);
ant = new ANT({
signer,
contract: new RemoteContract<ANTState>({
url: process.env.REMOTE_CACHE_URL || 'http://localhost:3000',
contractTxId: 'UC2zwawQoTnh0TNd9mYLQS4wObBBeaOU5LPQTNETqA4',
}),
});
});

it.each([[{ sortKey }], [{ blockHeight }]])(
`should get contract state with evaluation options: ${JSON.stringify('%s')}`,
Expand Down
11 changes: 6 additions & 5 deletions tests/ar-io.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { ARNS_DEVNET_REGISTRY_TX } from '../src/constants.js';
import { ArIOState } from '../src/contract-state.js';
import { SmartWeaveSortKey } from '../src/utils/smartweave.js';

const arweave = Arweave.init({
host: 'arweave.net',
protocol: 'https',
port: 443,
});
const gatewayAddress = '1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo';
const domain = 'ar-io';
const evaluateToBlockHeight = 1377100;
Expand All @@ -16,16 +21,12 @@ const evaluateToSortKey = new SmartWeaveSortKey(
describe('ArIO Client', () => {
let arIO: ArIO;
beforeAll(async () => {
const arweave = Arweave.init({
host: 'arweave.net',
protocol: 'https',
port: 443,
});
const jwk = await arweave.wallets.generate();
const signer = new ArweaveSigner(jwk);
arIO = new ArIO({
contract: new RemoteContract<ArIOState>({
contractTxId: ARNS_DEVNET_REGISTRY_TX,
url: 'https://localhost:3000',
}),
signer,
});
Expand Down

0 comments on commit 4581b8d

Please sign in to comment.