Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Fixed array tests #18

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}