Skip to content

Commit

Permalink
Merge pull request #18 from OffchainLabs/fixed-array-tests
Browse files Browse the repository at this point in the history
Fixed array tests
  • Loading branch information
rachel-bousfield authored Sep 6, 2023
2 parents 41f7392 + 94a3baa commit 60d71ca
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/mocks/SdkStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ contract SdkStorage {
bytes bytesLong;
string chars;
Maps maps;
Arrays arrays;

struct Struct {
uint16 num;
Expand All @@ -31,6 +32,18 @@ contract SdkStorage {
mapping(string => Struct) structs;
}

struct Arrays {
string[4] strings;
uint8 spacer;
uint24[5] packed;
uint8 trail;
address[2] spill;
uint8[2][4] matrix;
int96[4][] vector;
int96[][4] vectors;
Struct[3] structs;
}

function populate() external {
flag = true;
owner = address(0x70);
Expand Down Expand Up @@ -90,6 +103,39 @@ contract SdkStorage {
for (uint256 i = 0; i < 4; i++) {
structs.push(sub);
}

arrays.strings[2] = "L2 is for you!";

for (uint256 i = 0; i < 5; i++) {
arrays.packed[i] = uint24(i);
}

for (uint256 i = 0; i < 2; i++) {
arrays.spill[i] = address(uint160(i));
}

for (uint256 i = 0; i < 4; i++) {
arrays.matrix[i][0] = uint8(i);
arrays.matrix[i][1] = arrays.matrix[i][0] + 1;
}

for (uint256 w = 0; w < 3; w++) {
int96[4] memory array;
for (int256 i = 0; i < 4; i++) {
array[uint256(i)] = int96(i);
}
arrays.vector.push(array);
}

for (uint256 w = 0; w < 4; w++) {
for (int96 i = 0; i < 4; i++) {
arrays.vectors[w].push(i);
}
}

for (uint256 i = 0; i < 3; i++) {
arrays.structs[i] = sub;
}
}

function remove() external {
Expand Down Expand Up @@ -121,5 +167,10 @@ contract SdkStorage {
}

structs.pop();

delete arrays.matrix;
delete arrays.vector;
delete arrays.vectors;
delete arrays.structs;
}
}

0 comments on commit 60d71ca

Please sign in to comment.