core/types: fix deposit request encoding

Felix Lange 2 months ago
parent e64dfdd243
commit 2fa432a530
  1. 2
      core/types/deposit.go
  2. 3
      core/types/deposit_test.go

@ -32,7 +32,7 @@ func DepositLogToRequest(data []byte) ([]byte, error) {
} }
var outputRequest = make([]byte, depositRequestSize) var outputRequest = make([]byte, depositRequestSize)
outputRequest[0] = depositRequestSize outputRequest[0] = depositRequestType
const ( const (
pubkeyOffset = 1 pubkeyOffset = 1
withdrawalCredOffset = pubkeyOffset + 48 withdrawalCredOffset = pubkeyOffset + 48

@ -86,6 +86,9 @@ func FuzzUnpackIntoDeposit(f *testing.F) {
if err != nil { if err != nil {
t.Errorf("error unpacking deposit: %v", err) t.Errorf("error unpacking deposit: %v", err)
} }
if len(got) != depositRequestSize {
t.Errorf("wrong output size: %d, want %d", len(got), depositRequestSize)
}
if !bytes.Equal(enc, got) { if !bytes.Equal(enc, got) {
t.Errorf("roundtrip failed: want %x, got %x", enc, got) t.Errorf("roundtrip failed: want %x, got %x", enc, got)
} }

Loading…
Cancel
Save