Created
April 7, 2018 03:54
-
-
Save ismaelbej/ed863c494fc713c3f9c05e147390bcd2 to your computer and use it in GitHub Desktop.
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
const Tx = artifacts.require("./Parser/Tx.sol"); | |
const Simple = artifacts.require("./Simple.sol"); | |
module.exports = function(deployer) { | |
deployer.deploy(Tx); | |
deployer.link(Tx, Simple); | |
deployer.deploy(Simple); | |
}; |
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
pragma solidity ^0.4.2; | |
contract Migrations { | |
address public owner; | |
uint public last_completed_migration; | |
modifier restricted() { | |
if (msg.sender == owner) _; | |
} | |
function Migrations() public { | |
owner = msg.sender; | |
} | |
function setCompleted(uint completed) public restricted { | |
last_completed_migration = completed; | |
} | |
function upgrade(address new_address) public restricted { | |
Migrations upgraded = Migrations(new_address); | |
upgraded.setCompleted(last_completed_migration); | |
} | |
} |
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
pragma solidity ^0.4.18; | |
import "./Parser/Tx.sol"; | |
contract Simple { | |
function flip32Bytes(uint a) public returns (uint) { | |
return Tx.flip32Bytes(a); | |
} | |
} |
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
pragma solidity ^0.4.2; | |
import "truffle/Assert.sol"; | |
import "truffle/DeployedAddresses.sol"; | |
import "../contracts/Simple.sol"; | |
contract TestSimple { | |
function testSimple() public { | |
Simple simple = Simple(DeployedAddresses.Simple()); | |
uint expected = simple.flip32Bytes(0); | |
Assert.equal(0, expected, "Should match"); | |
} | |
} |
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
module.exports = { | |
networks: { | |
development: { | |
host: "127.0.0.1", | |
port: 8545, | |
network_id: "*" // Match any network id | |
} | |
} | |
}; |
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
pragma solidity ^0.4.19; | |
library Tx { | |
function flip32Bytes(uint _input) internal pure returns (uint) { | |
uint result; | |
assembly { | |
let pos := mload(0x40) | |
for { let i := 0 } lt(i, 32) { i := add(i, 1) } { | |
mstore8(add(pos, i), byte(sub(31, i), _input)) | |
} | |
result := mload(pos) | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment