Skip to content

Commit

Permalink
test: tests for OldCWIA proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
0xthedance committed Jan 17, 2025
1 parent b62a46c commit 23548db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
15 changes: 10 additions & 5 deletions tests/functional/data/contracts/ethereum/local/OldCWIA.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@
},
{
"inputs": [
{
"internalType": "address",
"name": "implementation",
"type": "address"
},
{
"internalType": "bytes",
"name": "data",
Expand Down Expand Up @@ -348,7 +353,7 @@
],
"contractName": "Template",
"deploymentBytecode": {
"bytecode": "0x60806040525f805460ff19166001179055348015601a575f5ffd5b50610669806100285f395ff3fe608060405234801561000f575f5ffd5b506004361061004a575f3560e01c8063332b3e641461004e578063ba414fa61461007e578063ce57ed7b1461009f578063fa7626d4146100b2575b5f5ffd5b61006161005c366004610490565b6100be565b6040516001600160a01b0390911681526020015b60405180910390f35b5f5461008f90610100900460ff1681565b6040519015158152602001610075565b6100616100ad366004610490565b610143565b5f5461008f9060ff1681565b5f6100fe3084848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061018392505050565b6040516001600160a01b03821681529091507f783540fb4221a3238720dc7038937d0d79982bcf895274aa6ad179f82cf0d53c9060200160405180910390a192915050565b5f6100fe3084848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061034092505050565b5f5f825160026101939190610512565b90505f6101a1826043610512565b90505f6101af600b8361052b565b90505f5f6040519050613d6160f01b81528260f01b60028201526680600b3d3981f360c81b600482015264363d3d376160d81b600b8201528460f01b601082015268603836393d3d3d366160b81b60128201528460f01b601b82015262013d7360e81b601d8201528760601b60208201526e5af43d82803e903d91603657fd5bf360881b6034820152600285610245919061052b565b9450845f610254836043610512565b90506020890193505b602082106102955783518152610274602082610512565b9050610281602085610512565b935061028e60208361052b565b915061025d565b5f60016102a384602061052b565b6102af90610100610621565b6102b9919061052b565b1990508085511682528260206102cf919061052b565b6102d99083610512565b91508760f01b825286845ff098506001600160a01b0389166103325760405162461bcd60e51b815260206004820152600d60248201526c18dc99585d194819985a5b1959609a1b60448201526064015b60405180910390fd5b505050505050505092915050565b80515f9081610350826038610512565b90505f61035e600b8361052b565b604051613d6160f01b815260f082901b60028201526680600b3d3981f360c81b600482015269363d3d373d3d3d363d7360b01b600b820152606088901b60158201526e5af43d82803e903d91602b57fd5bf360881b60298201529091505f90816103c9826038610512565b90506020880192505b6020861061040a57825181526103e9602082610512565b90506103f6602084610512565b925061040360208761052b565b95506103d2565b5f600161041888602061052b565b61042490610100610621565b61042e919061052b565b19905080845116825285835ff097506001600160a01b0388166104835760405162461bcd60e51b815260206004820152600d60248201526c18dc99585d194819985a5b1959609a1b6044820152606401610329565b5050505050505092915050565b5f5f602083850312156104a1575f5ffd5b823567ffffffffffffffff8111156104b7575f5ffd5b8301601f810185136104c7575f5ffd5b803567ffffffffffffffff8111156104dd575f5ffd5b8560208284010111156104ee575f5ffd5b6020919091019590945092505050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610525576105256104fe565b92915050565b81810381811115610525576105256104fe565b6001815b60018411156105795780850481111561055d5761055d6104fe565b600184161561056b57908102905b60019390931c928002610542565b935093915050565b5f8261058f57506001610525565b8161059b57505f610525565b81600181146105b157600281146105bb576105d7565b6001915050610525565b60ff8411156105cc576105cc6104fe565b50506001821b610525565b5060208310610133831016604e8410600b84101617156105fa575081810a610525565b6106065f19848461053e565b805f1904821115610619576106196104fe565b029392505050565b5f61062c8383610581565b939250505056fea2646970667358221220cb5bb3c3a6888cbff08b06e22489530072b67ef62743eb6ffdf63db6316064f664736f6c634300081c0033"
"bytecode": "0x60806040525f805460ff19166001179055348015601a575f5ffd5b50610721806100285f395ff3fe608060405234801561000f575f5ffd5b506004361061004a575f3560e01c80639a32d86c1461004e578063ba414fa61461007e578063ce57ed7b1461009f578063fa7626d4146100b2575b5f5ffd5b61006161005c36600461051b565b6100be565b6040516001600160a01b0390911681526020015b60405180910390f35b5f5461008f90610100900460ff1681565b6040519015158152602001610075565b6100616100ad366004610577565b610144565b5f5461008f9060ff1681565b5f6100fe8484848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506101c992505050565b6040516001600160a01b03821681529091507f783540fb4221a3238720dc7038937d0d79982bcf895274aa6ad179f82cf0d53c9060200160405180910390a19392505050565b5f6101843084848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061038692505050565b6040516001600160a01b03821681529091507f783540fb4221a3238720dc7038937d0d79982bcf895274aa6ad179f82cf0d53c9060200160405180910390a192915050565b5f5f825160026101d991906105ca565b90505f6101e78260436105ca565b90505f6101f5600b836105e3565b90505f5f6040519050613d6160f01b81528260f01b60028201526680600b3d3981f360c81b600482015264363d3d376160d81b600b8201528460f01b601082015268603836393d3d3d366160b81b60128201528460f01b601b82015262013d7360e81b601d8201528760601b60208201526e5af43d82803e903d91603657fd5bf360881b603482015260028561028b91906105e3565b9450845f61029a8360436105ca565b90506020890193505b602082106102db57835181526102ba6020826105ca565b90506102c76020856105ca565b93506102d46020836105e3565b91506102a3565b5f60016102e98460206105e3565b6102f5906101006106d9565b6102ff91906105e3565b19905080855116825282602061031591906105e3565b61031f90836105ca565b91508760f01b825286845ff098506001600160a01b0389166103785760405162461bcd60e51b815260206004820152600d60248201526c18dc99585d194819985a5b1959609a1b60448201526064015b60405180910390fd5b505050505050505092915050565b80515f90816103968260386105ca565b90505f6103a4600b836105e3565b604051613d6160f01b815260f082901b60028201526680600b3d3981f360c81b600482015269363d3d373d3d3d363d7360b01b600b820152606088901b60158201526e5af43d82803e903d91602b57fd5bf360881b60298201529091505f908161040f8260386105ca565b90506020880192505b60208610610450578251815261042f6020826105ca565b905061043c6020846105ca565b92506104496020876105e3565b9550610418565b5f600161045e8860206105e3565b61046a906101006106d9565b61047491906105e3565b19905080845116825285835ff097506001600160a01b0388166104c95760405162461bcd60e51b815260206004820152600d60248201526c18dc99585d194819985a5b1959609a1b604482015260640161036f565b5050505050505092915050565b5f5f83601f8401126104e6575f5ffd5b50813567ffffffffffffffff8111156104fd575f5ffd5b602083019150836020828501011115610514575f5ffd5b9250929050565b5f5f5f6040848603121561052d575f5ffd5b83356001600160a01b0381168114610543575f5ffd5b9250602084013567ffffffffffffffff81111561055e575f5ffd5b61056a868287016104d6565b9497909650939450505050565b5f5f60208385031215610588575f5ffd5b823567ffffffffffffffff81111561059e575f5ffd5b6105aa858286016104d6565b90969095509350505050565b634e487b7160e01b5f52601160045260245ffd5b808201808211156105dd576105dd6105b6565b92915050565b818103818111156105dd576105dd6105b6565b6001815b600184111561063157808504811115610615576106156105b6565b600184161561062357908102905b60019390931c9280026105fa565b935093915050565b5f82610647575060016105dd565b8161065357505f6105dd565b816001811461066957600281146106735761068f565b60019150506105dd565b60ff841115610684576106846105b6565b50506001821b6105dd565b5060208310610133831016604e8410600b84101617156106b2575081810a6105dd565b6106be5f1984846105f6565b805f19048211156106d1576106d16105b6565b029392505050565b5f6106e48383610639565b939250505056fea2646970667358221220394404610e65ce641681188db9b7f35580c7ee2d9b0db66bc00db27f8efd777e64736f6c634300081c0033"
},
"devdoc": {
"kind": "dev",
Expand All @@ -358,14 +363,14 @@
"methodIdentifiers": {
"IS_TEST()": "0xfa7626d4",
"clone1(bytes)": "0xce57ed7b",
"clone2(bytes)": "0x332b3e64",
"clone2(address,bytes)": "0x9a32d86c",
"failed()": "0xba414fa6"
},
"runtimeBytecode": {
"bytecode": "0x608060405234801561000f575f5ffd5b506004361061004a575f3560e01c8063332b3e641461004e578063ba414fa61461007e578063ce57ed7b1461009f578063fa7626d4146100b2575b5f5ffd5b61006161005c366004610490565b6100be565b6040516001600160a01b0390911681526020015b60405180910390f35b5f5461008f90610100900460ff1681565b6040519015158152602001610075565b6100616100ad366004610490565b610143565b5f5461008f9060ff1681565b5f6100fe3084848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061018392505050565b6040516001600160a01b03821681529091507f783540fb4221a3238720dc7038937d0d79982bcf895274aa6ad179f82cf0d53c9060200160405180910390a192915050565b5f6100fe3084848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061034092505050565b5f5f825160026101939190610512565b90505f6101a1826043610512565b90505f6101af600b8361052b565b90505f5f6040519050613d6160f01b81528260f01b60028201526680600b3d3981f360c81b600482015264363d3d376160d81b600b8201528460f01b601082015268603836393d3d3d366160b81b60128201528460f01b601b82015262013d7360e81b601d8201528760601b60208201526e5af43d82803e903d91603657fd5bf360881b6034820152600285610245919061052b565b9450845f610254836043610512565b90506020890193505b602082106102955783518152610274602082610512565b9050610281602085610512565b935061028e60208361052b565b915061025d565b5f60016102a384602061052b565b6102af90610100610621565b6102b9919061052b565b1990508085511682528260206102cf919061052b565b6102d99083610512565b91508760f01b825286845ff098506001600160a01b0389166103325760405162461bcd60e51b815260206004820152600d60248201526c18dc99585d194819985a5b1959609a1b60448201526064015b60405180910390fd5b505050505050505092915050565b80515f9081610350826038610512565b90505f61035e600b8361052b565b604051613d6160f01b815260f082901b60028201526680600b3d3981f360c81b600482015269363d3d373d3d3d363d7360b01b600b820152606088901b60158201526e5af43d82803e903d91602b57fd5bf360881b60298201529091505f90816103c9826038610512565b90506020880192505b6020861061040a57825181526103e9602082610512565b90506103f6602084610512565b925061040360208761052b565b95506103d2565b5f600161041888602061052b565b61042490610100610621565b61042e919061052b565b19905080845116825285835ff097506001600160a01b0388166104835760405162461bcd60e51b815260206004820152600d60248201526c18dc99585d194819985a5b1959609a1b6044820152606401610329565b5050505050505092915050565b5f5f602083850312156104a1575f5ffd5b823567ffffffffffffffff8111156104b7575f5ffd5b8301601f810185136104c7575f5ffd5b803567ffffffffffffffff8111156104dd575f5ffd5b8560208284010111156104ee575f5ffd5b6020919091019590945092505050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610525576105256104fe565b92915050565b81810381811115610525576105256104fe565b6001815b60018411156105795780850481111561055d5761055d6104fe565b600184161561056b57908102905b60019390931c928002610542565b935093915050565b5f8261058f57506001610525565b8161059b57505f610525565b81600181146105b157600281146105bb576105d7565b6001915050610525565b60ff8411156105cc576105cc6104fe565b50506001821b610525565b5060208310610133831016604e8410600b84101617156105fa575081810a610525565b6106065f19848461053e565b805f1904821115610619576106196104fe565b029392505050565b5f61062c8383610581565b939250505056fea2646970667358221220cb5bb3c3a6888cbff08b06e22489530072b67ef62743eb6ffdf63db6316064f664736f6c634300081c0033"
"bytecode": "0x608060405234801561000f575f5ffd5b506004361061004a575f3560e01c80639a32d86c1461004e578063ba414fa61461007e578063ce57ed7b1461009f578063fa7626d4146100b2575b5f5ffd5b61006161005c36600461051b565b6100be565b6040516001600160a01b0390911681526020015b60405180910390f35b5f5461008f90610100900460ff1681565b6040519015158152602001610075565b6100616100ad366004610577565b610144565b5f5461008f9060ff1681565b5f6100fe8484848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506101c992505050565b6040516001600160a01b03821681529091507f783540fb4221a3238720dc7038937d0d79982bcf895274aa6ad179f82cf0d53c9060200160405180910390a19392505050565b5f6101843084848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061038692505050565b6040516001600160a01b03821681529091507f783540fb4221a3238720dc7038937d0d79982bcf895274aa6ad179f82cf0d53c9060200160405180910390a192915050565b5f5f825160026101d991906105ca565b90505f6101e78260436105ca565b90505f6101f5600b836105e3565b90505f5f6040519050613d6160f01b81528260f01b60028201526680600b3d3981f360c81b600482015264363d3d376160d81b600b8201528460f01b601082015268603836393d3d3d366160b81b60128201528460f01b601b82015262013d7360e81b601d8201528760601b60208201526e5af43d82803e903d91603657fd5bf360881b603482015260028561028b91906105e3565b9450845f61029a8360436105ca565b90506020890193505b602082106102db57835181526102ba6020826105ca565b90506102c76020856105ca565b93506102d46020836105e3565b91506102a3565b5f60016102e98460206105e3565b6102f5906101006106d9565b6102ff91906105e3565b19905080855116825282602061031591906105e3565b61031f90836105ca565b91508760f01b825286845ff098506001600160a01b0389166103785760405162461bcd60e51b815260206004820152600d60248201526c18dc99585d194819985a5b1959609a1b60448201526064015b60405180910390fd5b505050505050505092915050565b80515f90816103968260386105ca565b90505f6103a4600b836105e3565b604051613d6160f01b815260f082901b60028201526680600b3d3981f360c81b600482015269363d3d373d3d3d363d7360b01b600b820152606088901b60158201526e5af43d82803e903d91602b57fd5bf360881b60298201529091505f908161040f8260386105ca565b90506020880192505b60208610610450578251815261042f6020826105ca565b905061043c6020846105ca565b92506104496020876105e3565b9550610418565b5f600161045e8860206105e3565b61046a906101006106d9565b61047491906105e3565b19905080845116825285835ff097506001600160a01b0388166104c95760405162461bcd60e51b815260206004820152600d60248201526c18dc99585d194819985a5b1959609a1b604482015260640161036f565b5050505050505092915050565b5f5f83601f8401126104e6575f5ffd5b50813567ffffffffffffffff8111156104fd575f5ffd5b602083019150836020828501011115610514575f5ffd5b9250929050565b5f5f5f6040848603121561052d575f5ffd5b83356001600160a01b0381168114610543575f5ffd5b9250602084013567ffffffffffffffff81111561055e575f5ffd5b61056a868287016104d6565b9497909650939450505050565b5f5f60208385031215610588575f5ffd5b823567ffffffffffffffff81111561059e575f5ffd5b6105aa858286016104d6565b90969095509350505050565b634e487b7160e01b5f52601160045260245ffd5b808201808211156105dd576105dd6105b6565b92915050565b818103818111156105dd576105dd6105b6565b6001815b600184111561063157808504811115610615576106156105b6565b600184161561062357908102905b60019390931c9280026105fa565b935093915050565b5f82610647575060016105dd565b8161065357505f6105dd565b816001811461066957600281146106735761068f565b60019150506105dd565b60ff841115610684576106846105b6565b50506001821b6105dd565b5060208310610133831016604e8410600b84101617156106b2575081810a6105dd565b6106be5f1984846105f6565b805f19048211156106d1576106d16105b6565b029392505050565b5f6106e48383610639565b939250505056fea2646970667358221220394404610e65ce641681188db9b7f35580c7ee2d9b0db66bc00db27f8efd777e64736f6c634300081c0033"
},
"sourceId": "OldCWIA.sol",
"sourcemap": "29372:564:0:-:0;;;1601:26;;;-1:-1:-1;;1601:26:0;1623:4;1601:26;;;29372:564;;;;;;;;;;;;;;;;",
"sourceId": "tests/functional/data/sources/OldCWIA.sol",
"sourcemap": "29372:589:0:-:0;;;1601:26;;;-1:-1:-1;;1601:26:0;1623:4;1601:26;;;29372:589;;;;;;;;;;;;;;;;",
"userdoc": {
"kind": "user",
"methods": {},
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/data/sources/OldCWIA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,8 @@ contract Template is ClonesWithImmutableArgs, ClonesWithCallData {
emit Cloned(address(clonedGreeter));
}

function clone2(bytes calldata data) external returns (Template clonedGreeter) {
clonedGreeter = Template(ClonesWithCallData.cloneWithCallDataProvision(address(this), data));
function clone2(address implementation, bytes calldata data) external returns (Template clonedGreeter) {
clonedGreeter = Template(ClonesWithCallData.cloneWithCallDataProvision(implementation, data));
emit Cloned(address(clonedGreeter));
}
}
Expand Down
7 changes: 5 additions & 2 deletions tests/functional/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ def test_OldCWIA(get_contract_type, owner, ethereum, target):
_type = get_contract_type("OldCWIA")
contract = ContractContainer(_type)
contract_instance = owner.deploy(contract)
clones_proxy = contract_instance.clone1(0, sender=owner)
clones_proxy = contract_instance.clone2(target, 0, sender=owner)
print(clones_proxy, "clones_proxy ")
proxy_address = to_checksum_address("0x" + (clones_proxy.logs[0]["data"].hex())[-40:])
print("proxy address", proxy_address)
actual = ethereum.get_proxy_info(proxy_address)
print("actual", actual)
assert actual is not None
assert actual.type == ProxyType.Standard
assert actual.type == ProxyType.OldCWIA
assert actual.target == target


Expand Down

0 comments on commit 23548db

Please sign in to comment.