Files
evmgpu/plugin/evm/message/code_request_test.go
zeekayandHanzo Dev 1a1c0c2876 test: conform stale golden vectors to the codec the live EVM already speaks
The codec writes integers and length prefixes little-endian now, but six
base64 fixtures in plugin/evm/message and the byte tables in
plugin/evm/validators/state still held the big-endian bytes, so five tests
compared today's output against a wire format nothing writes any more.

The runtime was never wrong. evmgpu's actual output byte-matches the golden
vector shipped in luxfi/evm v1.104.49 — I ran both. Only the fixtures had
gone stale, so they are taken from that line verbatim.

Also correct MaxCodeSize/MaxInitCodeSize in the upstream-params check: Lux
raises the contract code limit to 64KB, and the test still asserted
Ethereum's 24576.

params, plugin/evm/message and plugin/evm/validators/state now pass.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-28 23:27:30 -07:00

59 lines
1.8 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package message
import (
"encoding/base64"
"math/rand"
"testing"
"github.com/luxfi/geth/common"
"github.com/stretchr/testify/assert"
)
// TestMarshalCodeRequest asserts that the structure or serialization logic hasn't changed, primarily to
// ensure compatibility with the network.
func TestMarshalCodeRequest(t *testing.T) {
codeRequest := CodeRequest{
Hashes: []common.Hash{common.BytesToHash([]byte("some code pls"))},
}
base64CodeRequest := "AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHNvbWUgY29kZSBwbHM="
codeRequestBytes, err := Codec.Marshal(Version, codeRequest)
assert.NoError(t, err)
assert.Equal(t, base64CodeRequest, base64.StdEncoding.EncodeToString(codeRequestBytes))
var c CodeRequest
_, err = Codec.Unmarshal(codeRequestBytes, &c)
assert.NoError(t, err)
assert.Equal(t, codeRequest.Hashes, c.Hashes)
}
// TestMarshalCodeResponse asserts that the structure or serialization logic hasn't changed, primarily to
// ensure compatibility with the network.
func TestMarshalCodeResponse(t *testing.T) {
// generate some random code data
// use deterministic random source for testing
r := rand.New(rand.NewSource(1))
codeData := make([]byte, 50)
_, err := r.Read(codeData)
assert.NoError(t, err)
codeResponse := CodeResponse{
Data: [][]byte{codeData},
}
base64CodeResponse := "AAABAAAAMgAAAFL9/AchgmVPFj9fD5piHXKVZsdNEAN8TXu7BAfR4sZJgYVa2GgdDYbR6R4AFnk5y2aU"
codeResponseBytes, err := Codec.Marshal(Version, codeResponse)
assert.NoError(t, err)
assert.Equal(t, base64CodeResponse, base64.StdEncoding.EncodeToString(codeResponseBytes))
var c CodeResponse
_, err = Codec.Unmarshal(codeResponseBytes, &c)
assert.NoError(t, err)
assert.Equal(t, codeResponse.Data, c.Data)
}