Created
September 29, 2016 12:17
-
-
Save silasdavis/b8a2ed236b31ead70bf2a674b9811923 to your computer and use it in GitHub Desktop.
Libraries call fails, e-pm 212
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## | |
# LibReturnTest | |
jobs: | |
- name: ReturnerLib | |
job: | |
deploy: | |
contract: LibReturnerTest.sol | |
instance: Returner | |
wait: true | |
- name: ReturnerTest | |
job: | |
deploy: | |
contract: LibReturnerTest.sol | |
instance: ReturnerTest | |
libraries: Returner:$ReturnerLib | |
wait: true | |
- name: insert | |
job: | |
call: | |
destination: $ReturnerTest | |
data: insert | |
wait: true | |
- name: assertReturn | |
job: | |
assert: | |
key: $insert | |
relation: eq | |
val: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library Returner { | |
// Struct definitions used in Jan's Mappings library | |
struct B32AddressMap { | |
mapping (bytes32 => AddressElement) rows; | |
} | |
struct AddressElement { | |
address value; | |
} | |
// Does not return | |
// Insert function definition used in Jan's Mappings library | |
function insert(B32AddressMap storage _map, bytes32 _key, address _value) returns (uint) | |
{ | |
// Here is the line that freaks out: | |
_map.rows[_key].value = _value; | |
return 1; | |
} | |
} | |
contract ReturnerTest { | |
bytes32 constant KEY = "key"; | |
bytes32 constant LOCAL_KEY = "local_key"; | |
Returner.B32AddressMap b32AMap; | |
// Does not return | |
function insert() returns (uint) { | |
// Done locally within this contract the following is fine: | |
b32AMap.rows[LOCAL_KEY].value = msg.sender; | |
// Done via a library call the execution fails: | |
return Returner.insert(b32AMap, KEY, msg.sender); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment