|
1 | 1 | import tape from 'tape'
|
2 |
| -import { Address, BN, MAX_INTEGER } from 'ethereumjs-util' |
| 2 | +import { Account, Address, BN, MAX_INTEGER } from 'ethereumjs-util' |
| 3 | +import { Block } from '@ethereumjs/block' |
3 | 4 | import Common from '@ethereumjs/common'
|
4 | 5 | import { Transaction } from '@ethereumjs/tx'
|
5 | 6 | import VM from '../../lib'
|
@@ -144,6 +145,48 @@ tape('should clear storage cache after every transaction', async (t) => {
|
144 | 145 | t.end()
|
145 | 146 | })
|
146 | 147 |
|
| 148 | +tape('should be possible to disable the block gas limit validation', async (t) => { |
| 149 | + const vm = new VM() |
| 150 | + |
| 151 | + const privateKey = Buffer.from( |
| 152 | + 'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', |
| 153 | + 'hex' |
| 154 | + ) |
| 155 | + const address = Address.fromPrivateKey(privateKey) |
| 156 | + const initialBalance = new BN(10).pow(new BN(18)) |
| 157 | + |
| 158 | + const account = await vm.stateManager.getAccount(address) |
| 159 | + await vm.stateManager.putAccount( |
| 160 | + address, |
| 161 | + Account.fromAccountData({ ...account, balance: initialBalance }) |
| 162 | + ) |
| 163 | + |
| 164 | + const transferCost = 21000 |
| 165 | + |
| 166 | + const unsignedTx = Transaction.fromTxData({ |
| 167 | + to: address, |
| 168 | + gasLimit: transferCost, |
| 169 | + gasPrice: 1, |
| 170 | + nonce: 0, |
| 171 | + }) |
| 172 | + |
| 173 | + const tx = unsignedTx.sign(privateKey) |
| 174 | + |
| 175 | + const block = Block.fromBlockData({ |
| 176 | + header: { gasLimit: transferCost - 1 }, |
| 177 | + }) |
| 178 | + |
| 179 | + const result = await vm.runTx({ |
| 180 | + tx, |
| 181 | + block, |
| 182 | + skipBlockGasLimitValidation: true, |
| 183 | + }) |
| 184 | + |
| 185 | + t.equals(result.execResult.exceptionError, undefined) |
| 186 | + |
| 187 | + t.end() |
| 188 | +}) |
| 189 | + |
147 | 190 | // The following test tries to verify that running a tx
|
148 | 191 | // would work, even when stateManager is not using a cache.
|
149 | 192 | // It fails at the moment, and has been therefore commented.
|
|
0 commit comments