mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 15:46:43 +00:00
* add KeccakCodeHash and CodeSize to StateAccount * update StateAccount marshalling logic * change emptyCodeHash to poseidon(nil) * purge StateAccount.hash * fix/disable failing tests * change keccak and poseidon hash order in StateAccount * fix lint * update l2trace account wrapper * update eth_getProof response type * fix eth_getProof response type * goimports * update the codehash computation * update the codehash test cases * go mod tidy * fix tests * use keccak instead of poseidon * update trace codehash field name * upgrade zktrie to 4.2 * trigger ci * update state account marshalling according to spec * improve generatorStats estimation * add comment * upgrade zktrie to 4.3 * go mod tidy * misc fixes * fix TestDump * fix snap sync tests * handle err in the codehash * fix tests in snapshot/generate_test.go * remove prevhash from state journal * add state_account_marshalling_test.go * goimports * add more tests --------- Co-authored-by: Ho Vei <noelwei@gmail.com> Co-authored-by: Haichen Shen <shenhaichen@gmail.com>
42 lines
944 B
Go
42 lines
944 B
Go
package poseidon
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestPoseidonCodeHash(t *testing.T) {
|
|
// nil
|
|
got := fmt.Sprintf("%s", CodeHash(nil))
|
|
want := "0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864"
|
|
|
|
if got != want {
|
|
t.Errorf("got %q, wanted %q", got, want)
|
|
}
|
|
|
|
// single byte
|
|
got = fmt.Sprintf("%s", CodeHash([]byte{0}))
|
|
want = "0x29f94b67ee4e78b2bb08da025f9943c1201a7af025a27600c2dd0a2e71c7cf8b"
|
|
|
|
if got != want {
|
|
t.Errorf("got %q, wanted %q", got, want)
|
|
}
|
|
|
|
got = fmt.Sprintf("%s", CodeHash([]byte{1}))
|
|
want = "0x246d3c06960643350a3e2d587fa16315c381635eb5ac1ac4501e195423dbf78e"
|
|
|
|
if got != want {
|
|
t.Errorf("got %q, wanted %q", got, want)
|
|
}
|
|
|
|
// 32 bytes
|
|
bytes := make([]byte, 32)
|
|
for i := range bytes {
|
|
bytes[i] = 1
|
|
}
|
|
got = fmt.Sprintf("%s", CodeHash(bytes))
|
|
want = "0x0b46d156183dffdbed8e6c6b0af139b95c058e735878ca7f4dca334e0ea8bd20"
|
|
if got != want {
|
|
t.Errorf("got %q, wanted %q", got, want)
|
|
}
|
|
}
|