watcher-ts/packages/solidity-mapper/test/contracts/TestFixedArrays.sol
Ashwin Phatak b243025ca8
Test cases in solidity-mapper for contract, fixed-size byte arrays and enum types (#26)
* Add tests for getStorageInfo and getEventNameTopics.

* Lint solidity-mapper package code.

* Add test for contract type.

* Add test for fixed size byte arrays.

* Add test for Enum types.

* Add tests for variables packed together and using single slot.

* Fix comments in test contracts.

Co-authored-by: nikugogoi <95nikass@gmail.com>
2021-06-02 11:23:33 +05:30

33 lines
1.0 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
contract TestFixedArrays {
// Fixed size array variable will use 5 consecutive slots as size of 1 element is 32 bytes.
uint[5] uintArray;
// Fixed size array variable will use 10 consecutive slots as size of 1 element is 32 bytes.
int[10] intArray;
// Fixed size array variable will use 1 slot as size of one element is 1 byte.
int8[2] int8Array;
// Fixed size array variable will use the next consecutive slot as it is of array type.
// https://docs.soliditylang.org/en/v0.7.4/internals/layout_in_storage.html#layout-of-state-variables-in-storage
uint128[5] uint128Array;
// Set varaible uintArray.
function setUintArray(uint[5] calldata value) external {
uintArray = value;
}
// Set varaible int8Array.
function setInt8Array(int8[2] calldata value) external {
int8Array = value;
}
// Set varaible uint128Array.
function setUint128Array(uint128[5] calldata value) external {
uint128Array = value;
}
}