mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 13:48:08 +00:00
integration: add create2 test case with duplicate salt (#188)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
This is a development pre-release.
|
||||
|
||||
Supported `polkadot-sdk` rev: `274a781e8ca1a9432c7ec87593bd93214abbff50`
|
||||
|
||||
### Added
|
||||
- Support for the `coinbase` opcode.
|
||||
|
||||
|
||||
Generated
+360
-360
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -72,7 +72,7 @@ assert_fs = "1.1.2"
|
||||
# polkadot-sdk and friends
|
||||
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
|
||||
scale-info = { version = "2.11.6", default-features = false }
|
||||
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "2d53238a186ac1161ca9998471694eb1833efb1d" }
|
||||
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "274a781e8ca1a9432c7ec87593bd93214abbff50" }
|
||||
|
||||
# llvm
|
||||
[workspace.dependencies.inkwell]
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8;
|
||||
|
||||
/* runner.json
|
||||
{
|
||||
"differential": true,
|
||||
"actions": [
|
||||
{
|
||||
"Upload": {
|
||||
"code": {
|
||||
"Solidity": {
|
||||
"contract": "CreateA"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Instantiate": {
|
||||
"code": {
|
||||
"Solidity": {
|
||||
"contract": "CreateB"
|
||||
}
|
||||
},
|
||||
"value": 100000
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
contract CreateA {
|
||||
constructor() payable {}
|
||||
}
|
||||
|
||||
contract CreateB {
|
||||
constructor() payable {
|
||||
bytes32 salt = hex"ff";
|
||||
|
||||
try new CreateA{salt: salt}() returns (CreateA) {} catch {
|
||||
revert("the first instantiation should succeed");
|
||||
}
|
||||
|
||||
try new CreateA{salt: salt}() returns (CreateA) {} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
revert("the second instantiation should have failed");
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ test_spec!(gas_left, "GasLeft", "GasLeft.sol");
|
||||
test_spec!(gas_limit, "GasLimit", "GasLimit.sol");
|
||||
test_spec!(base_fee, "BaseFee", "BaseFee.sol");
|
||||
test_spec!(coinbase, "Coinbase", "Coinbase.sol");
|
||||
test_spec!(create2, "CreateB", "Create2.sol");
|
||||
|
||||
fn instantiate(path: &str, contract: &str) -> Vec<SpecsAction> {
|
||||
vec![Instantiate {
|
||||
@@ -433,33 +434,3 @@ fn ext_code_size() {
|
||||
}
|
||||
.run();
|
||||
}
|
||||
|
||||
/*
|
||||
// These test were implement for the mock-runtime and need to be ported yet.
|
||||
|
||||
#[test]
|
||||
fn create2_failure() {
|
||||
let mut state = State::default();
|
||||
let contract_a = Contract::create_a();
|
||||
state.upload_code(&contract_a.pvm_runtime);
|
||||
|
||||
let contract = Contract::create_b();
|
||||
let (state, output) = state
|
||||
.transaction()
|
||||
.with_default_account(&contract.pvm_runtime)
|
||||
.calldata(contract.calldata.clone())
|
||||
.call();
|
||||
|
||||
assert_eq!(output.flags, ReturnFlags::Success);
|
||||
|
||||
// The address already exists, which should cause the contract to revert
|
||||
|
||||
let (_, output) = state
|
||||
.transaction()
|
||||
.with_default_account(&contract.pvm_runtime)
|
||||
.calldata(contract.calldata)
|
||||
.call();
|
||||
|
||||
assert_eq!(output.flags, ReturnFlags::Revert);
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user