Tests for denominations in array sizes

This commit is contained in:
Kamil Śliwak 2023-02-24 19:54:50 +01:00
parent fc7cd54849
commit 66fcd542bc
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,25 @@
contract C {
uint[2 wei] a;
uint[2 gwei] b;
uint[2 ether] c;
uint[2 seconds] d;
uint[2 minutes] e;
uint[2 hours] f;
uint[2 days] g;
uint[2 weeks] h;
function lengths() public returns (uint, uint, uint, uint, uint, uint, uint, uint) {
return (
a.length,
b.length,
c.length,
d.length,
e.length,
f.length,
g.length,
h.length
);
}
}
// ----
// lengths() -> 2, 2000000000, 2000000000000000000, 2, 120, 7200, 172800, 1209600

View File

@ -0,0 +1,12 @@
contract C {
uint[42 wei] a;
uint[42 gwei] b;
uint[42 ether] c;
uint[42 seconds] d;
uint[42 minutes] e;
uint[42 hours] f;
uint[42 days] g;
uint[42 weeks] h;
}
// ----
// Warning 7325: (58-72): Type uint256[42000000000000000000] covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.