Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
chore(tests): add a test that validates bad smartweave inputs are dis…
Browse files Browse the repository at this point in the history
…regarded
  • Loading branch information
dtfiedler committed Nov 28, 2023
1 parent 0b43629 commit 69a2a6e
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/integration/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import * as path from 'path';
import * as fs from 'fs';
import { ArNSInteraction } from '../../src/types';
import { DEFAULT_EVALUATION_OPTIONS } from '../../src/constants';

const HOST = process.env.HOST ?? '127.0.0.1';
const PORT = process.env.PORT ?? 3000;
Expand Down Expand Up @@ -127,7 +128,7 @@ describe('Integration tests', () => {
expect(data).to.not.be.undefined;
const { contractTxId, state, evaluationOptions } = data;
expect(contractTxId).to.equal(id);
expect(evaluationOptions).not.to.be.undefined;
expect(evaluationOptions).to.equal(DEFAULT_EVALUATION_OPTIONS);
expect(state).to.include.keys([
'balances',
'owner',
Expand Down Expand Up @@ -177,6 +178,34 @@ describe('Integration tests', () => {
expect(contractTxId).to.equal(id);
expect(interactions).to.deep.equal(contractInteractions);
});

it('should filter out poorly formatted interactions', async () => {
// deploy the manual constructed interaction
const badInteractionTx = await arweave.createTransaction(
{
data: '',
},
walletJWK,
);
badInteractionTx.addTag('App-Name', 'SmartWeaveAction');
badInteractionTx.addTag('Contract', id);
badInteractionTx.addTag(
'input',
JSON.stringify({ function: 'evolve', value: 'bad-interaction' }),
);

await arweave.transactions.sign(badInteractionTx, walletJWK);
await arweave.transactions.post(badInteractionTx);

const { status, data } = await axios.get(
`/v1/contract/${id}/interactions`,
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, interactions } = data;
expect(contractTxId).to.equal(id);
expect(Object.keys(interactions)).not.to.contain(badInteractionTx.id);
});
});

describe('/:contractTxId/interactions/:address', () => {
Expand Down

0 comments on commit 69a2a6e

Please sign in to comment.