Commit f0f963bd authored by Mark Tyneway's avatar Mark Tyneway

state-surgery: fix flakey tests

Sometimes `require.Equal` flakes on the comparison
of `big.Int`.

https://github.com/ethereum-optimism/optimism/blob/b31d35b67755479645dd150e7cc8c6710f0b4a56/op-node/rollup/derive/fuzz_parsers_test.go#L42Co-authored-by: default avatarJoshua Gutow <jgutow@optimism.io>
parent 8323407f
...@@ -28,7 +28,7 @@ func TestAddBalance(t *testing.T) { ...@@ -28,7 +28,7 @@ func TestAddBalance(t *testing.T) {
account := db.GetAccount(addr) account := db.GetAccount(addr)
require.NotNil(t, account) require.NotNil(t, account)
require.Equal(t, account.Balance, value) require.True(t, BigEqual(account.Balance, value))
} }
} }
...@@ -61,3 +61,11 @@ func TestCode(t *testing.T) { ...@@ -61,3 +61,11 @@ func TestCode(t *testing.T) {
require.Equal(t, codeHash, common.BytesToHash(crypto.Keccak256(code))) require.Equal(t, codeHash, common.BytesToHash(crypto.Keccak256(code)))
} }
} }
func BigEqual(a, b *big.Int) bool {
if a == nil || b == nil {
return a == b
} else {
return a.Cmp(b) == 0
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment