Commit 352a1056 authored by Will Cory's avatar Will Cory

test: Better tests

parent ff577455
...@@ -565,24 +565,26 @@ describe('CrossChainMessenger', () => { ...@@ -565,24 +565,26 @@ describe('CrossChainMessenger', () => {
}) })
describe('when the transaction sent more than one message', () => { describe('when the transaction sent more than one message', () => {
it('should not throw an error', async () => { it('should be able to get second message by passing in an idex', async () => {
const messages = [...Array(2)].map(() => { const messages = [...Array(2)].map(() => {
return DUMMY_MESSAGE return DUMMY_MESSAGE
}) })
const tx = await l1Messenger.triggerSentMessageEvents(messages) const tx = await l1Messenger.triggerSentMessageEvents(messages)
await expect( const foundCrossChainMessages =
messenger.toCrossChainMessage(tx) await messenger.getMessagesByTransaction(tx)
).not.to.be.rejectedWith('expected 1 message, got 2') expect(await messenger.toCrossChainMessage(tx, 1)).to.deep.eq(
foundCrossChainMessages[1]
)
}) })
}) })
describe('when the transaction sent no messages', () => { describe('when the transaction sent no messages', () => {
it('should not throw an error', async () => { it('should throw an out of bounds error', async () => {
const tx = await l1Messenger.triggerSentMessageEvents([]) const tx = await l1Messenger.triggerSentMessageEvents([])
await expect( await expect(messenger.toCrossChainMessage(tx)).to.be.rejectedWith(
messenger.toCrossChainMessage(tx) `withdrawal index 0 out of bounds. There are 0 withdrawals`
).not.to.be.rejectedWith('expected 1 message, got 0') )
}) })
}) })
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment