Extracting more end-to-end tests.

This commit is contained in:
Christian Parpart
2019-07-08 16:04:52 +02:00
parent 019ec63f63
commit a9a56bc6dd
26 changed files with 452 additions and 641 deletions
@@ -0,0 +1,49 @@
contract test {
struct topStruct {
nestedStruct nstr;
uint topValue;
mapping (uint => uint) topMapping;
}
uint toDelete;
topStruct str;
struct nestedStruct {
uint nestedValue;
mapping (uint => bool) nestedMapping;
}
constructor() public {
toDelete = 5;
str.topValue = 1;
str.topMapping[0] = 1;
str.topMapping[1] = 2;
str.nstr.nestedValue = 2;
str.nstr.nestedMapping[0] = true;
str.nstr.nestedMapping[1] = false;
delete str;
delete toDelete;
}
function getToDelete() public returns (uint res){
res = toDelete;
}
function getTopValue() public returns(uint topValue){
topValue = str.topValue;
}
function getNestedValue() public returns(uint nestedValue){
nestedValue = str.nstr.nestedValue;
}
function getTopMapping(uint index) public returns(uint ret) {
ret = str.topMapping[index];
}
function getNestedMapping(uint index) public returns(bool ret) {
return str.nstr.nestedMapping[index];
}
}
// ----
// getToDelete() -> 0
// getTopValue() -> 0
// getNestedValue() -> 0
// #mapping values should be the same#
// getTopMapping(uint256): 0 -> 1
// getTopMapping(uint256): 1 -> 2
// getNestedMapping(uint256): 0 -> true
// getNestedMapping(uint256): 1 -> false
@@ -0,0 +1,24 @@
contract test {
struct s2 {
uint32 z;
mapping(uint8 => s2) recursive;
}
s2 data;
function check() public returns (bool ok) {
return data.z == 2 &&
data.recursive[0].z == 3 &&
data.recursive[0].recursive[1].z == 0 &&
data.recursive[0].recursive[0].z == 1;
}
function set() public {
data.z = 2;
mapping(uint8 => s2) storage map = data.recursive;
s2 storage inner = map[0];
inner.z = 3;
inner.recursive[0].z = inner.recursive[1].z + 1;
}
}
// ----
// check() -> false
// set() ->
// check() -> true
@@ -0,0 +1,33 @@
contract test {
struct s1 {
uint8 x;
bool y;
}
struct s2 {
uint32 z;
s1 s1data;
mapping(uint8 => s2) recursive;
}
s2 data;
function check() public returns (bool ok) {
return data.z == 1 && data.s1data.x == 2 &&
data.s1data.y == true &&
data.recursive[3].recursive[4].z == 5 &&
data.recursive[4].recursive[3].z == 6 &&
data.recursive[0].s1data.y == false &&
data.recursive[4].z == 9;
}
function set() public {
data.z = 1;
data.s1data.x = 2;
data.s1data.y = true;
data.recursive[3].recursive[4].z = 5;
data.recursive[4].recursive[3].z = 6;
data.recursive[0].s1data.y = false;
data.recursive[4].z = 9;
}
}
// ----
// check() -> false
// set() ->
// check() -> true