fix: make gas estimation test reproducible (#890)

Closes: #536

Solution: Use a fixed test account.

The source of non-deterministic is tx's intrinsic gas is different according to different number of zeros in input data,
so to make sure the gas number is reproducible, and the randomly generated test address is included in that.
This commit is contained in:
yihuang authored and GitHub committed 2022-01-07 14:04:16 +01:00
1 parent e6c9b7723b
commit 5e15c64d02
1 file changed
+5 -2
+5 -2
View File
@@ -72,9 +72,12 @@ type KeeperTestSuite struct {
func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
checkTx := false
// account key
priv, err := ethsecp256k1.GenerateKey()
// account key, use a constant account to keep unit test deterministic.
ecdsaPriv, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
require.NoError(t, err)
priv := &ethsecp256k1.PrivKey{
Key: crypto.FromECDSA(ecdsaPriv),
}
suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes())
suite.signer = tests.NewSigner(priv)