Add variants of Array.sort for address[] and bytes32[] (#4883)

Co-authored-by: Ernesto García <ernestognw@gmail.com>
This commit is contained in:
Hadrien Croubois
2024-02-12 17:34:07 +01:00
committed by GitHub
parent 72c0da9ae0
commit f8b1ddf591
12 changed files with 265 additions and 118 deletions

View File

@ -8,13 +8,7 @@ async function fixture() {
/** Rebuild the content of the deque as a JS array. */
const getContent = () =>
mock.$length(0).then(length =>
Promise.all(
Array(Number(length))
.fill()
.map((_, i) => mock.$at(0, i)),
),
);
mock.$length(0).then(length => Promise.all(Array.from({ length: Number(length) }, (_, i) => mock.$at(0, i))));
return { mock, getContent };
}

View File

@ -2,7 +2,7 @@ const { ethers } = require('hardhat');
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
const { mapValues } = require('../../helpers/iterate');
const { randomArray, generators } = require('../../helpers/random');
const { generators } = require('../../helpers/random');
const { TYPES, formatType } = require('../../../scripts/generate/templates/EnumerableMap.opts');
const { shouldBehaveLikeMap } = require('./EnumerableMap.behavior');
@ -17,8 +17,8 @@ async function fixture() {
name,
{
keyType,
keys: randomArray(generators[keyType]),
values: randomArray(generators[valueType]),
keys: Array.from({ length: 3 }, generators[keyType]),
values: Array.from({ length: 3 }, generators[valueType]),
zeroValue: generators[valueType].zero,
methods: mapValues(
{

View File

@ -2,7 +2,7 @@ const { ethers } = require('hardhat');
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
const { mapValues } = require('../../helpers/iterate');
const { randomArray, generators } = require('../../helpers/random');
const { generators } = require('../../helpers/random');
const { TYPES } = require('../../../scripts/generate/templates/EnumerableSet.opts');
const { shouldBehaveLikeSet } = require('./EnumerableSet.behavior');
@ -23,7 +23,7 @@ async function fixture() {
TYPES.map(({ name, type }) => [
type,
{
values: randomArray(generators[type]),
values: Array.from({ length: 3 }, generators[type]),
methods: getMethods(mock, {
add: `$add(uint256,${type})`,
remove: `$remove(uint256,${type})`,