Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utilities for CrossChain messaging #3183

Merged
merged 42 commits into from Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
07aa7b9
move ICompoundTimelock to a vendor/compound
Amxx Feb 10, 2022
f6e286b
add CrossChainEnabled and support for some chains
Amxx Feb 10, 2022
36d479a
add missing dependencies
Amxx Feb 10, 2022
23b82b7
web3js and ethers testing + lint
Amxx Feb 10, 2022
b98fae5
testing AccessControlCrossChain
Amxx Feb 14, 2022
3ee00b6
fix lint
Amxx Feb 14, 2022
670f597
don't run slither on the mocks
Amxx Feb 14, 2022
5ed8f33
refactor testing
Amxx Feb 14, 2022
5eaab89
add CrossChainEnabledPolygonChild
Amxx Feb 16, 2022
03294aa
add polygon child testing
Amxx Feb 16, 2022
80ec9e2
rename params for clarity
Amxx Feb 22, 2022
9faf612
add CrossChain documentation
Amxx Feb 24, 2022
0f6e613
Merge branch 'master' into feature/crosschain
Amxx Feb 24, 2022
4928727
fix spelling
Amxx Feb 24, 2022
27c18a5
remove ethers.js version of crosschain testing
Amxx Feb 24, 2022
be3543a
remove ethers/waffle dependencies
Amxx Feb 24, 2022
3b3cd58
add link to optimism bridges deployments
Amxx Feb 25, 2022
2313a06
Merge branch 'master' into feature/crosschain
frangio Mar 22, 2022
d9f6513
reset lockfile
frangio Mar 22, 2022
147528b
Apply suggestions from code review
Amxx Mar 23, 2022
4ebb13d
wording
Amxx Mar 23, 2022
2260e5a
Merge remote-tracking branch 'Amxx/feature/crosschain' into feature/c…
Amxx Mar 23, 2022
e73d815
fix lint
Amxx Mar 23, 2022
b300b6b
check custom error
Amxx Mar 23, 2022
5e1dfa2
add reverts to crossChainSender if call is not crosschain
Amxx Mar 24, 2022
ab77189
add custom error check
Amxx Mar 24, 2022
b2a4418
bump required solidity version
Amxx Mar 24, 2022
afb52f1
fix inconsistency in tests
Amxx Mar 25, 2022
6ac95cd
improve custom error detection
Amxx Mar 25, 2022
345a9b0
expect rewrite
Amxx Mar 25, 2022
bc2b083
sometimes the linter is not really smart
Amxx Mar 25, 2022
69cdf15
revert to simpler error detection
Amxx Mar 25, 2022
41cd634
add changelog entry
frangio Mar 28, 2022
1d4c86d
add customError helper
Amxx Mar 29, 2022
19752c8
Merge branch 'master' into feature/crosschain
Amxx Mar 29, 2022
1252614
add PR link in changelog entry
Amxx Mar 29, 2022
10acf59
print full revert string if customError detection fails
Amxx Mar 29, 2022
c1f0793
use bridge address instead of inbox for arbitrumL1
Amxx Mar 29, 2022
5ea8297
remove console.error
frangio Mar 29, 2022
04f4629
avoid mutating a dependency
frangio Mar 29, 2022
b0e9cdb
refactor crosschain helper to avoid global state
frangio Mar 29, 2022
cc2dd04
fix custom error tests when optimizations are on
frangio Mar 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/crosschain/CrossChainEnabled.test.js
@@ -1,8 +1,8 @@
const { expect } = require('chai');
const { expectRevert } = require('@openzeppelin/test-helpers');
const CrossChainHelper = require('../helpers/crosschain');

/** Revert handler that supports custom errors. */
async function expectRevert (promise, reason) {
expectRevert.customError = async function (promise, reason) {
try {
await promise;
expect.fail('Expected promise to throw but it didn\'t');
Expand All @@ -11,7 +11,7 @@ async function expectRevert (promise, reason) {
expect(error.message).to.include(reason);
}
}
}
};

function randomAddress () {
return web3.utils.toChecksumAddress(web3.utils.randomHex(20));
Expand All @@ -25,14 +25,14 @@ const CrossChainEnabledPolygonChildMock = artifacts.require('CrossChainEnabledPo

function shouldBehaveLikeReceiver (sender = randomAddress()) {
it('should reject same-chain calls', async function () {
await expectRevert(
await expectRevert.customError(
this.receiver.crossChainRestricted(),
'NotCrossChainCall()',
);
});

it('should restrict to cross-chain call from a invalid sender', async function () {
await expectRevert(
await expectRevert.customError(
CrossChainHelper.call(sender, this.receiver, 'crossChainOwnerRestricted()'),
`InvalidCrossChainSender("${sender}", "${await this.receiver.owner()}")`,
);
Expand Down
17 changes: 8 additions & 9 deletions test/utils/structs/DoubleEndedQueue.test.js
@@ -1,5 +1,4 @@
const { expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');

const Bytes32DequeMock = artifacts.require('Bytes32DequeMock');

Expand All @@ -11,7 +10,7 @@ async function getContent (deque) {
}

/** Revert handler that supports custom errors. */
async function expectRevert (promise, reason) {
expectRevert.customError = async function (promise, reason) {
Amxx marked this conversation as resolved.
Show resolved Hide resolved
try {
await promise;
expect.fail('Expected promise to throw but it didn\'t');
Expand All @@ -20,7 +19,7 @@ async function expectRevert (promise, reason) {
expect(error.message).to.include(reason);
}
}
}
};

contract('DoubleEndedQueue', function (accounts) {
const bytesA = '0xdeadbeef'.padEnd(66, '0');
Expand All @@ -39,10 +38,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 expectRevert.customError(this.deque.popBack(), 'Empty()');
await expectRevert.customError(this.deque.popFront(), 'Empty()');
await expectRevert.customError(this.deque.back(), 'Empty()');
await expectRevert.customError(this.deque.front(), 'Empty()');
});
});

Expand All @@ -63,7 +62,7 @@ contract('DoubleEndedQueue', function (accounts) {
});

it('out of bounds access', async function () {
await expectRevert(this.deque.at(this.content.length), 'OutOfBounds()');
await expectRevert.customError(this.deque.at(this.content.length), 'OutOfBounds()');
});

describe('push', function () {
Expand Down