From eaf3f1585e27fa75d1e607a5560f077350c905b7 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 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/integration/routes.test.ts b/tests/integration/routes.test.ts index b1c3880..cf4c4a6 100644 --- a/tests/integration/routes.test.ts +++ b/tests/integration/routes.test.ts @@ -177,6 +177,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: Math.random().toString().slice(-4), + }, + 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', () => {