Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusaaguiar committed Dec 20, 2024
1 parent 33ce5d3 commit d36f847
Show file tree
Hide file tree
Showing 10 changed files with 359 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/cmdlineTests/storage_layout_specified_location/in.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.27;

contract A layout at 42 {
uint x;
uint y;
int8 z;
bool b;
address addr;
uint[2] array;
}
16 changes: 16 additions & 0 deletions test/cmdlineTests/storage_layout_specified_location/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"fileA": {
"urls": ["storage_layout_specified_location/in.sol"]
}
},
"settings": {
"outputSelection": {
"fileA": {
"A": [ "storageLayout" ],
"": [ "storageLayout" ]
}
}
}
}
93 changes: 93 additions & 0 deletions test/cmdlineTests/storage_layout_specified_location/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"contracts": {
"fileA": {
"A": {
"storageLayout": {
"storage": [
{
"astId": 4,
"contract": "fileA:A",
"label": "x",
"offset": 0,
"slot": "42",
"type": "t_uint256"
},
{
"astId": 6,
"contract": "fileA:A",
"label": "y",
"offset": 0,
"slot": "43",
"type": "t_uint256"
},
{
"astId": 8,
"contract": "fileA:A",
"label": "z",
"offset": 0,
"slot": "44",
"type": "t_int8"
},
{
"astId": 10,
"contract": "fileA:A",
"label": "b",
"offset": 1,
"slot": "44",
"type": "t_bool"
},
{
"astId": 12,
"contract": "fileA:A",
"label": "addr",
"offset": 2,
"slot": "44",
"type": "t_address"
},
{
"astId": 16,
"contract": "fileA:A",
"label": "array",
"offset": 0,
"slot": "45",
"type": "t_array(t_uint256)2_storage"
}
],
"types": {
"t_address": {
"encoding": "inplace",
"label": "address",
"numberOfBytes": "20"
},
"t_array(t_uint256)2_storage": {
"base": "t_uint256",
"encoding": "inplace",
"label": "uint256[2]",
"numberOfBytes": "64"
},
"t_bool": {
"encoding": "inplace",
"label": "bool",
"numberOfBytes": "1"
},
"t_int8": {
"encoding": "inplace",
"label": "int8",
"numberOfBytes": "1"
},
"t_uint256": {
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
}
}
}
}
}
},
"sources": {
"fileA": {
"id": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.27;

contract A {
uint x;
uint y;
int8 z;
}

contract C layout at 42 {
bool b;
address addr;
uint[2] array;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"fileA": {
"urls": ["storage_layout_specified_location_inheritance/in.sol"]
}
},
"settings": {
"outputSelection": {
"fileA": {
"A": [ "storageLayout" ],
"": [ "storageLayout" ]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"contracts": {
"fileA": {
"A": {
"storageLayout": {
"storage": [
{
"astId": 3,
"contract": "fileA:A",
"label": "x",
"offset": 0,
"slot": "0",
"type": "t_uint256"
},
{
"astId": 5,
"contract": "fileA:A",
"label": "y",
"offset": 0,
"slot": "1",
"type": "t_uint256"
},
{
"astId": 7,
"contract": "fileA:A",
"label": "z",
"offset": 0,
"slot": "2",
"type": "t_int8"
}
],
"types": {
"t_int8": {
"encoding": "inplace",
"label": "int8",
"numberOfBytes": "1"
},
"t_uint256": {
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
}
}
}
}
}
},
"sources": {
"fileA": {
"id": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
contract A {
uint32 x;
int y;
bool b;
address a;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contract B {
bool b;
address a;
uint x;
int32 y;
int64 z;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"language": "Solidity",
"sources": {
"fileA": {
"urls": ["storage_layout_specified_location_two_contracts/contractA.sol"]
},
"fileB": {
"urls": ["storage_layout_specified_location_two_contracts/contractB.sol"]
}
},
"settings": {
"outputSelection": {
"fileA": {
"A": [ "storageLayout" ],
"": [ "storageLayout" ]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"contracts": {
"fileA": {
"A": {
"storageLayout": {
"storage": [
{
"astId": 2,
"contract": "fileA:A",
"label": "x",
"offset": 0,
"slot": "0",
"type": "t_uint32"
},
{
"astId": 4,
"contract": "fileA:A",
"label": "y",
"offset": 0,
"slot": "1",
"type": "t_int256"
},
{
"astId": 6,
"contract": "fileA:A",
"label": "b",
"offset": 0,
"slot": "2",
"type": "t_bool"
},
{
"astId": 8,
"contract": "fileA:A",
"label": "a",
"offset": 1,
"slot": "2",
"type": "t_address"
}
],
"types": {
"t_address": {
"encoding": "inplace",
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"encoding": "inplace",
"label": "bool",
"numberOfBytes": "1"
},
"t_int256": {
"encoding": "inplace",
"label": "int256",
"numberOfBytes": "32"
},
"t_uint32": {
"encoding": "inplace",
"label": "uint32",
"numberOfBytes": "4"
}
}
}
}
}
},
"errors": [
{
"component": "general",
"errorCode": "1878",
"formattedMessage": "Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.
--> fileA

",
"message": "SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.",
"severity": "warning",
"sourceLocation": {
"end": -1,
"file": "fileA",
"start": -1
},
"type": "Warning"
},
{
"component": "general",
"errorCode": "1878",
"formattedMessage": "Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.
--> fileB

",
"message": "SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.",
"severity": "warning",
"sourceLocation": {
"end": -1,
"file": "fileB",
"start": -1
},
"type": "Warning"
},
{
"component": "general",
"errorCode": "3420",
"formattedMessage": "Warning: Source file does not specify required compiler version!
--> fileA

",
"message": "Source file does not specify required compiler version!",
"severity": "warning",
"sourceLocation": {
"end": -1,
"file": "fileA",
"start": -1
},
"type": "Warning"
}
],
"sources": {
"fileA": {
"id": 0
},
"fileB": {
"id": 1
}
}
}

0 comments on commit d36f847

Please sign in to comment.