test_tx_selfdestruct_balance_bug()¶
Documentation for tests/paris/security/test_selfdestruct_balance_bug.py::test_tx_selfdestruct_balance_bug@[email protected].
Generate fixtures for these test cases for Constantinople with:
Constantinople only:
fill -v tests/paris/security/test_selfdestruct_balance_bug.py::test_tx_selfdestruct_balance_bug --fork=Constantinople --evm-bin=/path/to/evm-tool-dev-version
For all forks up to and including Constantinople:
fill -v tests/paris/security/test_selfdestruct_balance_bug.py::test_tx_selfdestruct_balance_bug --until=Constantinople
Test that the vulnerability is not present by checking the balance of the
0xaa contract after executing specific transactions:
-
Start with contract
0xaawhich has initial balance of 3 wei.0xaacontract code simply performs a self-destruct to itself. -
Send a transaction (tx 1) to invoke caller contract
0xcc(which has a balance of 1 wei), which in turn invokes0xaawith a 1 wei call. -
Store the balance of
0xaaafter the first transaction is processed.0xaaself-destructed. Expected outcome: 0 wei. -
Send another transaction (tx 2) to call 0xaa with 5 wei.
-
Store the balance of
0xaaafter the second transaction is processed. No self-destruct. Expected outcome: 5 wei. -
Verify that:
- Call within tx 1 is successful, i.e
0xaaself-destructed. - The balances of
0xaaafter each tx are correct. - During tx 2, code in
0xaadoes not execute, hence self-destruct mechanism does not trigger.
- Call within tx 1 is successful, i.e
TODO: EOF - This test could be parametrized for EOFCREATE
Source code in tests/paris/security/test_selfdestruct_balance_bug.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |