mirror of
https://github.com/luxfi/evmgpu.git
synced 2026-10-30 16:57:11 +00:00
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]>
66 lines
4.2 KiB
Go
66 lines
4.2 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"
|
|
)
|
|
|
|
// TestMarshalBlockRequest asserts that the structure or serialization logic hasn't changed, primarily to
|
|
// ensure compatibility with the network.
|
|
func TestMarshalBlockRequest(t *testing.T) {
|
|
blockRequest := BlockRequest{
|
|
Hash: common.BytesToHash([]byte("some hash is here yo")),
|
|
Height: 1337,
|
|
Parents: 64,
|
|
}
|
|
|
|
base64BlockRequest := "AAAAAAAAAAAAAAAAAABzb21lIGhhc2ggaXMgaGVyZSB5bzkFAAAAAAAAQAA="
|
|
|
|
blockRequestBytes, err := Codec.Marshal(Version, blockRequest)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, base64BlockRequest, base64.StdEncoding.EncodeToString(blockRequestBytes))
|
|
|
|
var b BlockRequest
|
|
_, err = Codec.Unmarshal(blockRequestBytes, &b)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, blockRequest.Hash, b.Hash)
|
|
assert.Equal(t, blockRequest.Height, b.Height)
|
|
assert.Equal(t, blockRequest.Parents, b.Parents)
|
|
}
|
|
|
|
// TestMarshalBlockResponse asserts that the structure or serialization logic hasn't changed, primarily to
|
|
// ensure compatibility with the network.
|
|
func TestMarshalBlockResponse(t *testing.T) {
|
|
// create some random bytes
|
|
// use deterministic random source for testing
|
|
r := rand.New(rand.NewSource(1))
|
|
blocksBytes := make([][]byte, 32)
|
|
for i := range blocksBytes {
|
|
blocksBytes[i] = make([]byte, r.Intn(32)+32) // min 32 length, max 64
|
|
_, err := r.Read(blocksBytes[i])
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
blockResponse := BlockResponse{
|
|
Blocks: blocksBytes,
|
|
}
|
|
|
|
base64BlockResponse := "AAAgAAAAIQAAAE8WP18PmmIdcpVmx00QA3xNe7sEB9HixkmBhVrYaB0NhjkAAADR6ZTSxCKs0gigByk5SH9pmeudGKRHhARdh/PGfPInRumVr1olNnlRuqL/bNRxxIPxX7kLrbN8WCE6AAAAtmgLTnyLdjobHUnUlVyEhiFjJSU/7HON16nii/khEZwWDwcCRIYVu9oIMT9qjrZo0gv1BZh1kh5miisAAABb3yx/xIRo0tbFL1BU4tCDa/hMcXTLdHY2TMPb2Wiw9xcu2FeUuzWLDDtSOwAAAF2heG+f69ehnQ97usvgJVqlt9RL7ED4TIkrm//UNimwIjvupfT3Q5H0RdFa/UKUBAN09pJLmMv4cT+NMgAAAJYtJOLK/Mrjph+1hrFDI6a8j5598dkpMz/5k5M76m9bOvbeA3Q2bEcZ5DobBn2JvH8BOQAAAPHxekxyFaO1OeseWEnGB327VyL1cXoomiZvl2R5gZmOvqicC0s3OXARXoLtb0ElyPpzEeTX3vqSLScAAAA2zU8kq/ffhmuqVgODZ61hRd4e6PSosJk+vfiIOgrYvpw5eLBIg+UkAAAAahVqnexqQOmh0AfwM8KCMGG90Oqln45NpkMBBSINCyloi3NLKAAAAI6gENd8luqAp6Zl9gb2pjt/Pf0lZ8GJeeTWDyZobZvy+ybJAf81TN48AAAAFgfuKbpk+Eq0PKDG5rkcH9O+iZBDQXnTr0SRo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Un6mRymoYdL2SXoyNcN/QZJ3nsHZazscVCT84LcnsDByIwAAAOZAq8lEj93rIZHZRcBHZ6+Eev0O212IV7eZrLGOSv+r4wN/LwAAAP7MQW5zTTc8Xr68nNzFlbzOPHvT2N+T+rfhJd3rr+ZaMb1dQeLSzpwrF4kvD+oZMQAAADGikNy/poQG6HcHP/CINOGXpANKpIr6P4W4picIyuu6yIC1uJuT2lOBAWRAIQTmSLY1AAAAImobDzE6id38RUxfj3KsibOLGfU3hMGem+rAPIdaJ9sCneN643pCMYgTSHaFkpNZyoxeuU49AAAAFS3Br0LquOKSXG2u5N5e+fnc8I38vQK4CAk5hYWSig995QvhptwdV2joU3mI/dzlYum5SMkYu6PpM+XEAC0AAADNrne6HSWbGIpLIchvvCPXKLRTR+raZQryTFbQgAqGkTMgiKgFvVXERuJesHU="
|
|
|
|
blockResponseBytes, err := Codec.Marshal(Version, blockResponse)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, base64BlockResponse, base64.StdEncoding.EncodeToString(blockResponseBytes))
|
|
|
|
var b BlockResponse
|
|
_, err = Codec.Unmarshal(blockResponseBytes, &b)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, blockResponse.Blocks, b.Blocks)
|
|
}
|