Commit 76745bd8 authored by Joshua Gutow's avatar Joshua Gutow

op-chain-ops: Fix flaky TestCode

If getting an empty code value in the state DB, geth returns `nil`,
not an empty array. This is funcationally equivalent if you are checking
the length, but not the same if you expect to get the same object out
that you put in. This now checks for this special case & prevents
the test from flaking.

This can be tested by running `go test ./state -count=10 -run=TestCode` in
the op-chain-ops folder. Without this change the test will fail, with this
change it will now pass.
parent dc01f9bb
...@@ -52,7 +52,11 @@ func TestCode(t *testing.T) { ...@@ -52,7 +52,11 @@ func TestCode(t *testing.T) {
db.SetCode(addr, code) db.SetCode(addr, code)
post := db.GetCode(addr) post := db.GetCode(addr)
require.Equal(t, post, code) if len(code) == 0 {
require.Nil(t, post)
} else {
require.Equal(t, post, code)
}
size := db.GetCodeSize(addr) size := db.GetCodeSize(addr)
require.Equal(t, size, len(code)) require.Equal(t, size, len(code))
......
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