Skip to content

Commit

Permalink
chore: create individual tests and turn logging back to fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Apr 25, 2024
1 parent 4f5476b commit 871513a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/common/ar-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,12 @@ export class ArIOWritable extends ArIOReadable implements ArIOWriteContract {
}: {
target: string;
qty: number;
denomination: DENOMINATIONS;
denomination?: DENOMINATIONS;
}): Promise<WriteInteractionResult> {
return this.contract.writeInteraction<{
target: WalletAddress;
qty: number;
denomination: DENOMINATIONS;
denomination?: DENOMINATIONS;
}>({
functionName: AR_IO_CONTRACT_FUNCTIONS.TRANSFER,
inputs: {
Expand Down
2 changes: 1 addition & 1 deletion src/common/contracts/warp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { FailedRequestError, WriteInteractionError } from '../error.js';
import { DefaultLogger } from '../logger.js';
import { defaultWarp } from '../warp.js';

LoggerFactory.INST.logLevel('debug');
LoggerFactory.INST.logLevel('fatal');

export class WarpContract<T>
implements BaseContract<T>, ReadContract, WriteContract
Expand Down
84 changes: 42 additions & 42 deletions tests/integration/ar-io-writable.test.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
import { ArweaveSigner } from 'arbundles';
import { ArweaveSigner } from 'arbundles/node';

import { ArIO, ArIOWritable } from '../../src/common/ar-io.js';
import { WarpContract } from '../../src/common/index.js';
import { DefaultLogger } from '../../src/common/logger.js';
import { ArIOState } from '../../src/contract-state.js';
import { gatewayAddress, localCacheUrl, warp } from '../constants.js';

const writeTestCases = [
[
'joinNetwork',
{
fqdn: 'example.com',
label: 'example',
protocol: 'https',
port: 443,
qty: 20000,
properties: ''.padEnd(43, 'a'),
note: 'a note',
allowDelegatedStaking: true,
minDelegatedStake: 100,
},
],
['updateGatewaySettings', { fqdn: 'example.com' }],
['increaseDelegateStake', { target: gatewayAddress, qty: 101 }],
['decreaseDelegateStake', { target: gatewayAddress, qty: 101 }],
['increaseOperatorStake', { qty: 101 }],
['decreaseOperatorStake', { qty: 101 }],
['transfer', { target: ''.padEnd(43, 'f'), qty: 101 }],
] as const;

describe('ArIOWriteable', () => {
let signer: ArweaveSigner;
let contractTxId: string;
Expand All @@ -48,23 +25,46 @@ describe('ArIOWriteable', () => {
});
});

it.each(writeTestCases)(
'should execute write interaction with parameters: %s',
async (functionName: string, inputs: Record<string, any>) => {
const tx = await arIO[functionName]({
...inputs,
});
expect(tx).toBeDefined();
},
);
it('should successfully join network', async () => {
const { id: interactionTxId } = await arIO.joinNetwork({
fqdn: 'example.com',
label: 'example',
protocol: 'https',
port: 443,
qty: 20000,
properties: ''.padEnd(43, 'a'),
note: 'a note',
allowDelegatedStaking: true,
delegateRewardShareRatio: 10,
minDelegatedStake: 100,
autoStake: true,
});
expect(interactionTxId).toBeDefined();
});

it('should successfully increase delegate stake', async () => {
const { id: interactionTxId } = await arIO.increaseDelegateStake({
target: gatewayAddress,
qty: 101,
});
expect(interactionTxId).toBeDefined();
});

// it('should successfully submit saveObservations interaction with parameters', async () => {
// // mine blocks so we can submit a observations
// await mineBlocks({ arweave, blocks: 20 });
// const tx = await arIO.saveObservations({
// reportTxId: gatewayAddress,
// failedGateways: [gatewayAddress],
// });
// expect(tx).toBeDefined();
// });
it('should successfully decrease delegate stake', async () => {
const { id: interactionTxId } = await arIO.decreaseDelegateStake({
target: gatewayAddress,
qty: 101,
});
expect(interactionTxId).toBeDefined();
});

it('should successfully transfer tokens to another address', async () => {
const target = ''.padEnd(43, 'f');
const qty = 101;
const { id: interactionTxId } = await arIO.transfer({
target,
qty,
});
expect(interactionTxId).toBeDefined();
});
});

0 comments on commit 871513a

Please sign in to comment.