tests/: minor refactoring to enable Ethereum tests

This commit is contained in:
Trung Nguyen 2018-11-30 17:24:50 -05:00
parent 8c4aea54d1
commit a916458aff
No known key found for this signature in database
GPG Key ID: 4636434ED9505EB7
2 changed files with 22 additions and 2 deletions

View File

@ -20,13 +20,16 @@ import "math/big"
var (
TargetGasLimit = GenesisGasLimit // The artificial target
)
const (
// the followings are modified by Quorum and purposely moved from `const` section
// so to faclitate the execution of Ethereum Tests
// @see tests/init_test.go#TestMain
GasLimitBoundDivisor uint64 = 4096 // The bound divisor of the gas limit, used in update calculations.
MinGasLimit uint64 = 700000000 // Minimum the gas limit may ever be.
GenesisGasLimit uint64 = 800000000 // Gas limit of the Genesis block.
)
const (
MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis.
ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction.
SloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added.

View File

@ -261,3 +261,20 @@ func runTestFunc(runTest interface{}, t *testing.T, name string, m reflect.Value
m.MapIndex(reflect.ValueOf(key)),
})
}
func TestMain(m *testing.M) {
backupMinGasLimit := params.MinGasLimit
backupGasLimitBoundDivisor := params.GasLimitBoundDivisor
backupGenesisGasLimit := params.GenesisGasLimit
defer func() {
params.GasLimitBoundDivisor = backupGasLimitBoundDivisor
params.MinGasLimit = backupMinGasLimit
params.GenesisGasLimit = backupGenesisGasLimit
}()
params.GasLimitBoundDivisor = 1024
params.MinGasLimit = 5000
params.GenesisGasLimit = 4712388
retCode := m.Run()
os.Exit(retCode)
}