Add HasNoEther
This commit is contained in:
13
test/helpers/ForceEther.sol
Normal file
13
test/helpers/ForceEther.sol
Normal file
@ -0,0 +1,13 @@
|
||||
pragma solidity ^0.4.8;
|
||||
|
||||
// @title Force Ether into a contract.
|
||||
// @notice even
|
||||
// if the contract is not payable.
|
||||
// @notice To use, construct the contract with the target as argument.
|
||||
// @author Remco Bloemen <remco@neufund.org>
|
||||
contract ForceEther {
|
||||
function ForceEther(address target) payable {
|
||||
// Selfdestruct transfers all Ether to the arget address
|
||||
selfdestruct(target);
|
||||
}
|
||||
}
|
||||
17
test/helpers/HasNoEtherTest.sol
Normal file
17
test/helpers/HasNoEtherTest.sol
Normal file
@ -0,0 +1,17 @@
|
||||
pragma solidity ^0.4.8;
|
||||
|
||||
import "../../contracts/ownership/HasNoEther.sol";
|
||||
|
||||
contract HasNoEtherTest is HasNoEther {
|
||||
|
||||
// Constructor with explicit payable — should still fail
|
||||
function HasNoEtherTest() payable {
|
||||
|
||||
}
|
||||
|
||||
// Default function with explicit payable — should still fail
|
||||
function() external payable {
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
12
test/helpers/expectThrow.js
Normal file
12
test/helpers/expectThrow.js
Normal file
@ -0,0 +1,12 @@
|
||||
export default async promise => {
|
||||
try {
|
||||
await promise;
|
||||
} catch (error) {
|
||||
// TODO: Check jump destination to destinguish between a throw
|
||||
// and an actual invalid jump.
|
||||
const invalidJump = error.message.search('invalid JUMP') >= 0;
|
||||
assert(invalidJump, "Expected throw, got '" + error + "' instead");
|
||||
return;
|
||||
}
|
||||
assert.fail('Expected throw not received');
|
||||
};
|
||||
4
test/helpers/toPromise.js
Normal file
4
test/helpers/toPromise.js
Normal file
@ -0,0 +1,4 @@
|
||||
export default func =>
|
||||
(...args) =>
|
||||
new Promise((accept, reject) =>
|
||||
func(...args, (error, data) => error ? reject(error) : accept(data)));
|
||||
Reference in New Issue
Block a user