From c7fb8e339d3156f18b2113a6f6ea0c0ad9b43164 Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Mon, 27 Nov 2023 15:29:31 -0800 Subject: [PATCH] chore(tests): add a test that validates bad smartweave inputs are disregarded --- tests/integration/routes.test.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/integration/routes.test.ts b/tests/integration/routes.test.ts index b1c3880..53c6c00 100644 --- a/tests/integration/routes.test.ts +++ b/tests/integration/routes.test.ts @@ -21,10 +21,12 @@ 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'; const HOST = process.env.HOST ?? '127.0.0.1'; const PORT = process.env.PORT ?? 3000; @@ -177,6 +179,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'); + const transaction = new Transaction({ + tags: [smartweaveTag, contractTag, badInputTag], + }); + // deploy the manual constructed interaction + const badInteractionTx = await arweave.transactions.post(transaction); + 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.data.id, + ); + }); }); describe('/:contractTxId/interactions/:address', () => {