fix: gas estimates in test (#1650)

This commit is contained in:
André Medeiros 2019-06-04 13:12:43 -04:00 committed by GitHub
parent 6d844d72e5
commit 312c631f86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -316,7 +316,14 @@ class ContractDeployer {
next();
},
function estimateCorrectGas(next) {
if (contract.gas === 'auto' || !contract.gas) {
if (contract._skipGasEstimations) {
// This is Ganache's gas limit. We subtract 1 so we don't reach the limit.
//
// We do this because Ganache's gas estimates are wrong (contract creation
// has a base cost of 53k, not 21k, so it sometimes results in out of gas
// errors.)
contract.gas = 6721975 - 1;
} else if (contract.gas === 'auto' || !contract.gas) {
return self.blockchain.estimateDeployContractGas(deployObject, (err, gasValue) => {
if (err) {
return next(err);

View File

@ -36,6 +36,7 @@ class DeployManager {
this.events.setCommandHandler('deploy:contracts:test', (cb) => {
self.fatalErrors = true;
self.deployOnlyOnConfig = true;
self.skipGasEstimations = true;
self.deployContracts(cb);
});
}
@ -70,6 +71,7 @@ class DeployManager {
callback = result;
}
contract._gasLimit = self.gasLimit;
contract._skipGasEstimations = self.skipGasEstimations;
self.events.request('deploy:contract', contract, (err) => {
if (err) {
contract.error = err.message || err;