Skip to content

Commit

Permalink
fix(tests): update client instantiation test to check read vs write c…
Browse files Browse the repository at this point in the history
…lients
  • Loading branch information
Atticus committed Apr 10, 2024
1 parent ad9bc56 commit 059653c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/contract-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { WalletAddress } from './common.js';
// Gateways

export const CONTRACT_FUNCTIONS = {
GATEWAY: 'getGateway',
GATEWAYS: 'getGateways',
GATEWAY: 'gateway',
GATEWAYS: 'gateways',
PRESCRIBED_OBSERVERS: 'prescribedObservers',
DELEGATE_STAKE: 'delegateStake',
DECREASE_DELEGATE_STAKE: 'decreaseDelegateStake',
Expand Down
24 changes: 15 additions & 9 deletions tests/integration/ar-io.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArweaveSigner } from 'arbundles';

import { ArIO } from '../../src/common/ar-io.js';
import { ArIO, ArIOReadable, ArIOWritable } from '../../src/common/ar-io.js';
import { RemoteContract } from '../../src/common/contracts/remote-contract.js';
import { WarpContract } from '../../src/common/index.js';
import { DefaultLogger } from '../../src/common/logger.js';
Expand Down Expand Up @@ -31,19 +31,25 @@ describe('ArIO Client', () => {
}),
});

it('should create a custom ArIO client', () => {
expect(arIO).toBeInstanceOf(ArIO);
});

it('should connect and return a valid instance', async () => {
const client = ArIO.init({
it('should connect and return a valid instances of read and write clients', async () => {
const readClient = ArIO.init({
contract: new RemoteContract<ArIOState>({
contractTxId,
cacheUrl: localCacheUrl,
}),
});
expect(client).toBeDefined();
expect(client).toBeInstanceOf(ArIO);
const writeClient = ArIO.init({
signer,
contract: new WarpContract<ArIOState>({
cacheUrl: localCacheUrl,
contractTxId,
logger: new DefaultLogger({ level: 'none' }),
}),
});
expect(readClient).toBeDefined();
expect(readClient).toBeInstanceOf(ArIOReadable);
expect(writeClient).toBeDefined();
expect(writeClient).toBeInstanceOf(ArIOWritable);
});

it('should should return undefined for non existent gateway', async () => {
Expand Down

0 comments on commit 059653c

Please sign in to comment.