Add utilities for CrossChain messaging (#3183)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
const { expectEvent } = require('@openzeppelin/test-helpers');
|
||||
const { expect } = require('chai');
|
||||
const { expectRevertCustomError } = require('../../helpers/customError');
|
||||
|
||||
const Bytes32DequeMock = artifacts.require('Bytes32DequeMock');
|
||||
|
||||
@ -10,18 +10,6 @@ async function getContent (deque) {
|
||||
return values;
|
||||
}
|
||||
|
||||
/** Revert handler that supports custom errors. */
|
||||
async function expectRevert (promise, reason) {
|
||||
try {
|
||||
await promise;
|
||||
expect.fail('Expected promise to throw but it didn\'t');
|
||||
} catch (error) {
|
||||
if (reason) {
|
||||
expect(error.message).to.include(reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contract('DoubleEndedQueue', function (accounts) {
|
||||
const bytesA = '0xdeadbeef'.padEnd(66, '0');
|
||||
const bytesB = '0x0123456789'.padEnd(66, '0');
|
||||
@ -39,10 +27,10 @@ contract('DoubleEndedQueue', function (accounts) {
|
||||
});
|
||||
|
||||
it('reverts on accesses', async function () {
|
||||
await expectRevert(this.deque.popBack(), 'Empty()');
|
||||
await expectRevert(this.deque.popFront(), 'Empty()');
|
||||
await expectRevert(this.deque.back(), 'Empty()');
|
||||
await expectRevert(this.deque.front(), 'Empty()');
|
||||
await expectRevertCustomError(this.deque.popBack(), 'Empty()');
|
||||
await expectRevertCustomError(this.deque.popFront(), 'Empty()');
|
||||
await expectRevertCustomError(this.deque.back(), 'Empty()');
|
||||
await expectRevertCustomError(this.deque.front(), 'Empty()');
|
||||
});
|
||||
});
|
||||
|
||||
@ -63,7 +51,7 @@ contract('DoubleEndedQueue', function (accounts) {
|
||||
});
|
||||
|
||||
it('out of bounds access', async function () {
|
||||
await expectRevert(this.deque.at(this.content.length), 'OutOfBounds()');
|
||||
await expectRevertCustomError(this.deque.at(this.content.length), 'OutOfBounds()');
|
||||
});
|
||||
|
||||
describe('push', function () {
|
||||
|
||||
Reference in New Issue
Block a user