Skip to content

Commit

Permalink
Merge pull request #735 from permaweb/jfrain99/add-duplicate-tags-test
Browse files Browse the repository at this point in the history
fix(mu): handle duplicate from-process tags on transactions #660
  • Loading branch information
jfrain99 authored May 24, 2024
2 parents 5d061a3 + 8d4d6d3 commit 7343fc7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions servers/mu/src/domain/lib/build-tx.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ async function buildAndSign ({ processId, tags, anchor }) {
assert.equal(tags.find((tag) =>
tag.name === 'From-Process'
).value, 'process-123')
assert.equal(tags.filter((tag) =>
tag.name === 'From-Process'
).length, 1)

return {
id: 'id-1',
Expand Down Expand Up @@ -65,4 +68,33 @@ describe('buildTx', () => {
assert.equal(result.tx.processId, 'id-1')
assert.deepStrictEqual(result.tagAssignments, [{ Processes: ['p1', 'p2'], Message: 'id-1' }])
})

test('build and sign a tx from a cached msg with duplicate tags', async () => {
const buildTx = buildTxWith({
buildAndSign,
logger,
locateProcess,
fetchSchedulerProcess,
isWallet
})

const result = await buildTx({
cachedMsg: {
msg: {
Target: 'id-1',
Tags: [
{ name: 'Assignments', value: ['p1', 'p2'] },
{ name: 'From-Process', value: 'Process1' },
{ name: 'From-Process', value: 'Process2' }
],
Anchor: 'anchor-1',
Data: 'data-1'
},
fromProcessId: 'process-123'
}
}).toPromise()

assert.equal(result.tx.processId, 'id-1')
assert.deepStrictEqual(result.tagAssignments, [{ Processes: ['p1', 'p2'], Message: 'id-1' }])
})
})

0 comments on commit 7343fc7

Please sign in to comment.