Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
test: add normal/try catch revert testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
RetricSu committed Oct 26, 2022
1 parent 0ce56e5 commit a19085d
Show file tree
Hide file tree
Showing 12 changed files with 786 additions and 0 deletions.
22 changes: 22 additions & 0 deletions polyjuice-tests/src/test_cases/evm-contracts/revert/DebugAAA.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"inputs": [],
"name": "state",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "test",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6080604052600160005534801561001557600080fd5b5060d2806100246000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063c19d93fb146037578063f8a8fd6d146051575b600080fd5b603d6059565b604051604891906079565b60405180910390f35b6057605f565b005b60005481565b6002600081905550600080fd5b6073816092565b82525050565b6000602082019050608c6000830184606c565b92915050565b600081905091905056fea26469706673582212207f187a1dc8b41345e0ae6e00525cf19576699f1a3e53e6941c835e95a6fea52864736f6c63430008060033
31 changes: 31 additions & 0 deletions polyjuice-tests/src/test_cases/evm-contracts/revert/DebugAAA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "DebugAAA",
"sourceName": "contracts/try.sol",
"abi": [
{
"inputs": [],
"name": "state",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "test",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x6080604052600160005534801561001557600080fd5b5060d2806100246000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063c19d93fb146037578063f8a8fd6d146051575b600080fd5b603d6059565b604051604891906079565b60405180910390f35b6057605f565b005b60005481565b6002600081905550600080fd5b6073816092565b82525050565b6000602082019050608c6000830184606c565b92915050565b600081905091905056fea26469706673582212207f187a1dc8b41345e0ae6e00525cf19576699f1a3e53e6941c835e95a6fea52864736f6c63430008060033",
"deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c8063c19d93fb146037578063f8a8fd6d146051575b600080fd5b603d6059565b604051604891906079565b60405180910390f35b6057605f565b005b60005481565b6002600081905550600080fd5b6073816092565b82525050565b6000602082019050608c6000830184606c565b92915050565b600081905091905056fea26469706673582212207f187a1dc8b41345e0ae6e00525cf19576699f1a3e53e6941c835e95a6fea52864736f6c63430008060033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6080604052600160005534801561001557600080fd5b50610225806100256000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630c55699c1461003b578063bb29998e14610059575b600080fd5b610043610089565b604051610050919061016a565b60405180910390f35b610073600480360381019061006e919061012e565b61008f565b604051610080919061016a565b60405180910390f35b60005481565b600060036000819055508173ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156100e157600080fd5b505af19250505080156100f2575060015b61010757600260008190555060099050610114565b6004600081905550600890505b919050565b600081359050610128816101d8565b92915050565b600060208284031215610144576101436101d3565b5b600061015284828501610119565b91505092915050565b610164816101c9565b82525050565b600060208201905061017f600083018461015b565b92915050565b6000610190826101a9565b9050919050565b60006101a282610185565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b6101e181610197565b81146101ec57600080fd5b5056fea2646970667358221220506dbf7607ada20e8d557f3db634bf28cc9fe28ca1dc78db7fdfc7200697876064736f6c63430008060033
43 changes: 43 additions & 0 deletions polyjuice-tests/src/test_cases/evm-contracts/revert/DebugBBB.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "DebugBBB",
"sourceName": "contracts/try.sol",
"abi": [
{
"inputs": [
{
"internalType": "contract DebugAAA",
"name": "a",
"type": "address"
}
],
"name": "test",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "x",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x6080604052600160005534801561001557600080fd5b50610225806100256000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630c55699c1461003b578063bb29998e14610059575b600080fd5b610043610089565b604051610050919061016a565b60405180910390f35b610073600480360381019061006e919061012e565b61008f565b604051610080919061016a565b60405180910390f35b60005481565b600060036000819055508173ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156100e157600080fd5b505af19250505080156100f2575060015b61010757600260008190555060099050610114565b6004600081905550600890505b919050565b600081359050610128816101d8565b92915050565b600060208284031215610144576101436101d3565b5b600061015284828501610119565b91505092915050565b610164816101c9565b82525050565b600060208201905061017f600083018461015b565b92915050565b6000610190826101a9565b9050919050565b60006101a282610185565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b6101e181610197565b81146101ec57600080fd5b5056fea2646970667358221220506dbf7607ada20e8d557f3db634bf28cc9fe28ca1dc78db7fdfc7200697876064736f6c63430008060033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80630c55699c1461003b578063bb29998e14610059575b600080fd5b610043610089565b604051610050919061016a565b60405180910390f35b610073600480360381019061006e919061012e565b61008f565b604051610080919061016a565b60405180910390f35b60005481565b600060036000819055508173ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156100e157600080fd5b505af19250505080156100f2575060015b61010757600260008190555060099050610114565b6004600081905550600890505b919050565b600081359050610128816101d8565b92915050565b600060208284031215610144576101436101d3565b5b600061015284828501610119565b91505092915050565b610164816101c9565b82525050565b600060208201905061017f600083018461015b565b92915050565b6000610190826101a9565b9050919050565b60006101a282610185565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b6101e181610197565b81146101ec57600080fd5b5056fea2646970667358221220506dbf7607ada20e8d557f3db634bf28cc9fe28ca1dc78db7fdfc7200697876064736f6c63430008060033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6080604052600160005534801561001557600080fd5b5061034a806100256000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80632b6d0ceb1461003b578063a56dfe4a1461006b575b600080fd5b61005560048036038101906100509190610185565b610089565b604051610062919061022b565b60405180910390f35b610073610140565b604051610080919061022b565b60405180910390f35b600060036000819055508273ffffffffffffffffffffffffffffffffffffffff1663bb29998e836040518263ffffffff1660e01b81526004016100cc9190610210565b602060405180830381600087803b1580156100e657600080fd5b505af192505050801561011757506040513d601f19601f8201168201806040525081019061011491906101c5565b60015b61012c5760026000819055506009905061013a565b506004600081905550600890505b92915050565b60005481565b600081359050610155816102cf565b92915050565b60008135905061016a816102e6565b92915050565b60008151905061017f816102fd565b92915050565b6000806040838503121561019c5761019b6102ca565b5b60006101aa8582860161015b565b92505060206101bb85828601610146565b9150509250929050565b6000602082840312156101db576101da6102ca565b5b60006101e984828501610170565b91505092915050565b6101fb816102a6565b82525050565b61020a8161029c565b82525050565b600060208201905061022560008301846101f2565b92915050565b60006020820190506102406000830184610201565b92915050565b60006102518261027c565b9050919050565b600061026382610246565b9050919050565b600061027582610246565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102b1826102b8565b9050919050565b60006102c38261027c565b9050919050565b600080fd5b6102d881610258565b81146102e357600080fd5b50565b6102ef8161026a565b81146102fa57600080fd5b50565b6103068161029c565b811461031157600080fd5b5056fea2646970667358221220726e359d1b6a32ae1926ffe27d6c5f541e2a2f7c67e4be0985b3897255c1f66964736f6c63430008060033
48 changes: 48 additions & 0 deletions polyjuice-tests/src/test_cases/evm-contracts/revert/DebugCCC.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "DebugCCC",
"sourceName": "contracts/try.sol",
"abi": [
{
"inputs": [
{
"internalType": "contract DebugBBB",
"name": "b",
"type": "address"
},
{
"internalType": "contract DebugAAA",
"name": "a",
"type": "address"
}
],
"name": "test",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "y",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x6080604052600160005534801561001557600080fd5b5061034a806100256000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80632b6d0ceb1461003b578063a56dfe4a1461006b575b600080fd5b61005560048036038101906100509190610185565b610089565b604051610062919061022b565b60405180910390f35b610073610140565b604051610080919061022b565b60405180910390f35b600060036000819055508273ffffffffffffffffffffffffffffffffffffffff1663bb29998e836040518263ffffffff1660e01b81526004016100cc9190610210565b602060405180830381600087803b1580156100e657600080fd5b505af192505050801561011757506040513d601f19601f8201168201806040525081019061011491906101c5565b60015b61012c5760026000819055506009905061013a565b506004600081905550600890505b92915050565b60005481565b600081359050610155816102cf565b92915050565b60008135905061016a816102e6565b92915050565b60008151905061017f816102fd565b92915050565b6000806040838503121561019c5761019b6102ca565b5b60006101aa8582860161015b565b92505060206101bb85828601610146565b9150509250929050565b6000602082840312156101db576101da6102ca565b5b60006101e984828501610170565b91505092915050565b6101fb816102a6565b82525050565b61020a8161029c565b82525050565b600060208201905061022560008301846101f2565b92915050565b60006020820190506102406000830184610201565b92915050565b60006102518261027c565b9050919050565b600061026382610246565b9050919050565b600061027582610246565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102b1826102b8565b9050919050565b60006102c38261027c565b9050919050565b600080fd5b6102d881610258565b81146102e357600080fd5b50565b6102ef8161026a565b81146102fa57600080fd5b50565b6103068161029c565b811461031157600080fd5b5056fea2646970667358221220726e359d1b6a32ae1926ffe27d6c5f541e2a2f7c67e4be0985b3897255c1f66964736f6c63430008060033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80632b6d0ceb1461003b578063a56dfe4a1461006b575b600080fd5b61005560048036038101906100509190610185565b610089565b604051610062919061022b565b60405180910390f35b610073610140565b604051610080919061022b565b60405180910390f35b600060036000819055508273ffffffffffffffffffffffffffffffffffffffff1663bb29998e836040518263ffffffff1660e01b81526004016100cc9190610210565b602060405180830381600087803b1580156100e657600080fd5b505af192505050801561011757506040513d601f19601f8201168201806040525081019061011491906101c5565b60015b61012c5760026000819055506009905061013a565b506004600081905550600890505b92915050565b60005481565b600081359050610155816102cf565b92915050565b60008135905061016a816102e6565b92915050565b60008151905061017f816102fd565b92915050565b6000806040838503121561019c5761019b6102ca565b5b60006101aa8582860161015b565b92505060206101bb85828601610146565b9150509250929050565b6000602082840312156101db576101da6102ca565b5b60006101e984828501610170565b91505092915050565b6101fb816102a6565b82525050565b61020a8161029c565b82525050565b600060208201905061022560008301846101f2565b92915050565b60006020820190506102406000830184610201565b92915050565b60006102518261027c565b9050919050565b600061026382610246565b9050919050565b600061027582610246565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102b1826102b8565b9050919050565b60006102c38261027c565b9050919050565b600080fd5b6102d881610258565b81146102e357600080fd5b50565b6102ef8161026a565b81146102fa57600080fd5b50565b6103068161029c565b811461031157600080fd5b5056fea2646970667358221220726e359d1b6a32ae1926ffe27d6c5f541e2a2f7c67e4be0985b3897255c1f66964736f6c63430008060033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6080604052600160005534801561001557600080fd5b5061020e806100256000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063bb29998e1461003b578063c5d7802e1461006b575b600080fd5b61005560048036038101906100509190610117565b610089565b6040516100629190610153565b60405180910390f35b6100736100fc565b6040516100809190610153565b60405180910390f35b600060036000819055508173ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156100db57600080fd5b505af11580156100ef573d6000803e3d6000fd5b5050505060099050919050565b60005481565b600081359050610111816101c1565b92915050565b60006020828403121561012d5761012c6101bc565b5b600061013b84828501610102565b91505092915050565b61014d816101b2565b82525050565b60006020820190506101686000830184610144565b92915050565b600061017982610192565b9050919050565b600061018b8261016e565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b6101ca81610180565b81146101d557600080fd5b5056fea264697066735822122079981b1b914c901eca3fcc81c3b54f1e8789ea7aa017042c3217cdf0c7d8108064736f6c63430008060033
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "NormalRevert",
"sourceName": "contracts/try.sol",
"abi": [
{
"inputs": [
{
"internalType": "contract DebugAAA",
"name": "a",
"type": "address"
}
],
"name": "test",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "z",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x6080604052600160005534801561001557600080fd5b5061020e806100256000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063bb29998e1461003b578063c5d7802e1461006b575b600080fd5b61005560048036038101906100509190610117565b610089565b6040516100629190610153565b60405180910390f35b6100736100fc565b6040516100809190610153565b60405180910390f35b600060036000819055508173ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156100db57600080fd5b505af11580156100ef573d6000803e3d6000fd5b5050505060099050919050565b60005481565b600081359050610111816101c1565b92915050565b60006020828403121561012d5761012c6101bc565b5b600061013b84828501610102565b91505092915050565b61014d816101b2565b82525050565b60006020820190506101686000830184610144565b92915050565b600061017982610192565b9050919050565b600061018b8261016e565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b6101ca81610180565b81146101d557600080fd5b5056fea264697066735822122079981b1b914c901eca3fcc81c3b54f1e8789ea7aa017042c3217cdf0c7d8108064736f6c63430008060033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063bb29998e1461003b578063c5d7802e1461006b575b600080fd5b61005560048036038101906100509190610117565b610089565b6040516100629190610153565b60405180910390f35b6100736100fc565b6040516100809190610153565b60405180910390f35b600060036000819055508173ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156100db57600080fd5b505af11580156100ef573d6000803e3d6000fd5b5050505060099050919050565b60005481565b600081359050610111816101c1565b92915050565b60006020828403121561012d5761012c6101bc565b5b600061013b84828501610102565b91505092915050565b61014d816101b2565b82525050565b60006020820190506101686000830184610144565b92915050565b600061017982610192565b9050919050565b600061018b8261016e565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b6101ca81610180565b81146101d557600080fd5b5056fea264697066735822122079981b1b914c901eca3fcc81c3b54f1e8789ea7aa017042c3217cdf0c7d8108064736f6c63430008060033",
"linkReferences": {},
"deployedLinkReferences": {}
}
50 changes: 50 additions & 0 deletions polyjuice-tests/src/test_cases/evm-contracts/revert/contracts.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
pragma solidity ^0.8.4;

contract DebugAAA {
uint public state = 1;

function test() external {
state = 2;
revert();
}
}

contract DebugBBB {
uint public x = 1;

function test(DebugAAA a) external returns (uint) {
x = 3;
try a.test() {
x = 4;
return 8;
} catch {
x = 2;
return 9;
}
}
}

contract DebugCCC {
uint public y = 1;

function test(DebugBBB b, DebugAAA a) external returns (uint) {
y = 3;
try b.test(a) {
y = 4;
return 8;
} catch {
y = 2;
return 9;
}
}
}

contract NormalRevert {
uint public z = 1;

function test(DebugAAA a) external returns (uint) {
z = 3;
a.test();
return 9;
}
}
1 change: 1 addition & 0 deletions polyjuice-tests/src/test_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub(crate) mod contract_call_contract;
pub(crate) mod contract_create_contract;
pub(crate) mod create2;
pub(crate) mod delegatecall;
pub(crate) mod revert;
pub(crate) mod erc20;
pub(crate) mod fallback_function;
pub(crate) mod get_block_info;
Expand Down
Loading

0 comments on commit a19085d

Please sign in to comment.