mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for salted create.
This commit is contained in:
parent
2fa586beac
commit
790c6d2cae
@ -0,0 +1,23 @@
|
||||
contract B
|
||||
{
|
||||
}
|
||||
|
||||
contract A {
|
||||
function different_salt() public returns (bool) {
|
||||
B x = new B{salt: "abc"}();
|
||||
B y = new B{salt: "abcef"}();
|
||||
return x != y;
|
||||
}
|
||||
function same_salt() public returns (bool) {
|
||||
B x = new B{salt: "xyz"}();
|
||||
try new B{salt: "xyz"}() {} catch {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
// different_salt() -> true
|
||||
// same_salt() -> true
|
@ -0,0 +1,23 @@
|
||||
contract B
|
||||
{
|
||||
uint x;
|
||||
function getBalance() public view returns (uint) {
|
||||
return address(this).balance * 1000 + x;
|
||||
}
|
||||
constructor(uint _x) public payable {
|
||||
x = _x;
|
||||
}
|
||||
}
|
||||
|
||||
contract A {
|
||||
function f() public payable returns (uint, uint, uint) {
|
||||
B x = new B{salt: "abc", value: 3}(7);
|
||||
B y = new B{value: 3}{salt: "abc"}(8);
|
||||
B z = new B{value: 3, salt: "abc"}(9);
|
||||
return (x.getBalance(), y.getBalance(), z.getBalance());
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
// f(), 10 ether -> 3007, 3008, 3009
|
Loading…
Reference in New Issue
Block a user