Skip to content
This repository was 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 3d8fa53
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/integration/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ import { arweave, createLocalWallet, warp } from './setup.test';
import {
JWKInterface,
LexicographicalInteractionsSorter,
Tag,
} from 'warp-contracts';
import * as path from 'path';
import * as fs from 'fs';
import { ArNSInteraction } from '../../src/types';
import Transaction from 'arweave/node/lib/transaction';
import { ArweaveSigner } from 'warp-contracts-plugin-deploy';

const HOST = process.env.HOST ?? '127.0.0.1';
const PORT = process.env.PORT ?? 3000;
Expand Down Expand Up @@ -177,6 +180,30 @@ describe('Integration tests', () => {
expect(contractTxId).to.equal(id);
expect(interactions).to.deep.equal(contractInteractions);
});

it('should filter out poorly formatted interactions', async () => {
const badInputTag = new Tag(
'input',
JSON.stringify({ function: 'evolve', value: 'bad-interaction' }),
);
const contractTag = new Tag('Contract', id);
const smartweaveTag = new Tag('App-Name', 'SmartWeaveAction');
// deploy the manual constructed interaction
const badInteractionTx = await arweave.createTransaction(
{
tags: [smartweaveTag, contractTag, badInputTag],
},
walletJWK,
);
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 3d8fa53

Please sign in to comment.