Skip to content

Commit

Permalink
fix(test): update test to use ArweaveTransactionID class
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Feb 14, 2024
1 parent 7483246 commit f6c4f8b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/ArNSRemoteCache.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArIO } from '../src/common/ArIO.js';
import { ArNSRemoteCache } from '../src/common/ContractStateProviders/ArNSRemoteCache.js';
import { BadRequest } from '../src/common/error.js';
import { ArweaveTransactionID } from '../src/types.js';

describe('ArIO Client', () => {
const remoteCacheProvider = new ArNSRemoteCache({});
Expand All @@ -16,17 +16,22 @@ describe('ArIO Client', () => {

const stubGetContractState = jest.fn();
remoteProvider.getContractState = stubGetContractState;
const contractTxId = ''.padEnd(43, 'a');
const contractTxId = new ArweaveTransactionID(''.padEnd(43, 'a'));
await client.getContractState({ contractTxId });
expect(stubGetContractState).toHaveBeenCalledWith({ contractTxId });
});

it('should call remote state provider and throw on bad contract id', async () => {
const contractTxId = ''.padEnd(42, 'a');
const result = await arioClient
.getContractState({ contractTxId })
.catch((e) => e);
it('should throw on bad contract id', async () => {
let result;
try {
const contractTxId = new ArweaveTransactionID(''.padEnd(42, 'a'));
result = await arioClient
.getContractState({ contractTxId })
.catch((e) => e);
} catch (error) {
result = error;
}

expect(result).toBeInstanceOf(BadRequest);
expect(result).toBeInstanceOf(Error);
});
});

0 comments on commit f6c4f8b

Please sign in to comment.