@@ -90,8 +90,19 @@ contract MerkleTreeLibTest is SoladyTest {
9090 return MerkleTreeLib.build (leafs).leaf (leafIndex);
9191 }
9292
93+ function _maybePad (bytes32 [] memory leafs ) internal returns (bytes32 [] memory ) {
94+ if (_randomChance (2 )) {
95+ if (_randomChance (2 )) {
96+ return leafs.pad ();
97+ }
98+ return leafs.pad (bytes32 (_random ()));
99+ }
100+ return leafs;
101+ }
102+
93103 function testBuildAndGetLeafProof (bytes32 [] memory leafs , uint256 leafIndex ) public {
94104 if (leafs.length == 0 ) return _testBuildAndGetRoot (leafs);
105+ leafs = _maybePad (leafs);
95106 bytes32 [] memory t = MerkleTreeLib.build (leafs);
96107 if (leafIndex < leafs.length ) {
97108 bytes32 [] memory proof = this .buildAndGetLeafProof (leafs, leafIndex);
@@ -161,12 +172,14 @@ contract MerkleTreeLibTest is SoladyTest {
161172 bool [] flags;
162173 }
163174
164- function testBuildAndGetLeafsMultiProof (bytes32 ) public {
175+ function testBuildAndGetLeafsMultiProof (bytes32 r ) public {
176+ _maybeBrutalizeMemory (r);
165177 TestMultiProofTemps memory t;
166178 t.leafs = new bytes32 [](_bound (_random (), 1 , 128 ));
167179 for (uint256 i; i < t.leafs.length ; ++ i) {
168180 t.leafs[i] = bytes32 (_random ());
169181 }
182+ t.leafs = _maybePad (t.leafs);
170183 t.leafIndices = _generateUniqueLeafIndices (t.leafs);
171184 t.tree = MerkleTreeLib.build (t.leafs);
172185 (t.proof, t.flags) = t.tree.leafsMultiProof (t.leafIndices);
0 commit comments