Update docs

This commit is contained in:
github-actions
2024-10-21 14:27:36 +00:00
parent 63bb51f17d
commit edf6031131
435 changed files with 42062 additions and 23945 deletions

View File

@ -1,90 +1,101 @@
require('@openzeppelin/test-helpers');
const { ethers } = require('hardhat');
const { expect } = require('chai');
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
const AuthorityUtils = artifacts.require('$AuthorityUtils');
const NotAuthorityMock = artifacts.require('NotAuthorityMock');
const AuthorityNoDelayMock = artifacts.require('AuthorityNoDelayMock');
const AuthorityDelayMock = artifacts.require('AuthorityDelayMock');
const AuthorityNoResponse = artifacts.require('AuthorityNoResponse');
async function fixture() {
const [user, other] = await ethers.getSigners();
contract('AuthorityUtils', function (accounts) {
const [user, other] = accounts;
const mock = await ethers.deployContract('$AuthorityUtils');
const notAuthorityMock = await ethers.deployContract('NotAuthorityMock');
const authorityNoDelayMock = await ethers.deployContract('AuthorityNoDelayMock');
const authorityDelayMock = await ethers.deployContract('AuthorityDelayMock');
const authorityNoResponse = await ethers.deployContract('AuthorityNoResponse');
return {
user,
other,
mock,
notAuthorityMock,
authorityNoDelayMock,
authorityDelayMock,
authorityNoResponse,
};
}
describe('AuthorityUtils', function () {
beforeEach(async function () {
this.mock = await AuthorityUtils.new();
Object.assign(this, await loadFixture(fixture));
});
describe('canCallWithDelay', function () {
describe('when authority does not have a canCall function', function () {
beforeEach(async function () {
this.authority = await NotAuthorityMock.new();
this.authority = this.notAuthorityMock;
});
it('returns (immediate = 0, delay = 0)', async function () {
const { immediate, delay } = await this.mock.$canCallWithDelay(
this.authority.address,
user,
other,
this.authority,
this.user,
this.other,
'0x12345678',
);
expect(immediate).to.equal(false);
expect(delay).to.be.bignumber.equal('0');
expect(immediate).to.be.false;
expect(delay).to.equal(0n);
});
});
describe('when authority has no delay', function () {
beforeEach(async function () {
this.authority = await AuthorityNoDelayMock.new();
this.authority = this.authorityNoDelayMock;
this.immediate = true;
await this.authority._setImmediate(this.immediate);
});
it('returns (immediate, delay = 0)', async function () {
const { immediate, delay } = await this.mock.$canCallWithDelay(
this.authority.address,
user,
other,
this.authority,
this.user,
this.other,
'0x12345678',
);
expect(immediate).to.equal(this.immediate);
expect(delay).to.be.bignumber.equal('0');
expect(delay).to.equal(0n);
});
});
describe('when authority replies with a delay', function () {
beforeEach(async function () {
this.authority = await AuthorityDelayMock.new();
this.immediate = true;
this.delay = web3.utils.toBN(42);
await this.authority._setImmediate(this.immediate);
await this.authority._setDelay(this.delay);
this.authority = this.authorityDelayMock;
});
it('returns (immediate, delay)', async function () {
const { immediate, delay } = await this.mock.$canCallWithDelay(
this.authority.address,
user,
other,
'0x12345678',
);
expect(immediate).to.equal(this.immediate);
expect(delay).to.be.bignumber.equal(this.delay);
});
for (const immediate of [true, false]) {
for (const delay of [0n, 42n]) {
it(`returns (immediate=${immediate}, delay=${delay})`, async function () {
await this.authority._setImmediate(immediate);
await this.authority._setDelay(delay);
const result = await this.mock.$canCallWithDelay(this.authority, this.user, this.other, '0x12345678');
expect(result.immediate).to.equal(immediate);
expect(result.delay).to.equal(delay);
});
}
}
});
describe('when authority replies with empty data', function () {
beforeEach(async function () {
this.authority = await AuthorityNoResponse.new();
this.authority = this.authorityNoResponse;
});
it('returns (immediate = 0, delay = 0)', async function () {
const { immediate, delay } = await this.mock.$canCallWithDelay(
this.authority.address,
user,
other,
this.authority,
this.user,
this.other,
'0x12345678',
);
expect(immediate).to.equal(false);
expect(delay).to.be.bignumber.equal('0');
expect(immediate).to.be.false;
expect(delay).to.equal(0n);
});
});
});