mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
- Update github.com/luxfi/evm to v0.7.10 (simpler versioning without -lux suffix) - Keep local replace directives for evm/genesis (circular dependency) - Disable lp118 warp type mismatch tests temporarily - Add migration tooling and RPC export capabilities - Update chain manager for better warp handling
101 lines
2.9 KiB
Go
101 lines
2.9 KiB
Go
package core
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
|
|
"github.com/luxfi/evm/consensus/dummy"
|
|
"github.com/luxfi/evm/params"
|
|
"github.com/luxfi/geth/core/rawdb"
|
|
"github.com/luxfi/geth/core/vm"
|
|
"github.com/luxfi/geth/triedb"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGenesisCancun(t *testing.T) {
|
|
require := require.New(t)
|
|
|
|
// Test with Cancun enabled (default TestChainConfig)
|
|
t.Run("WithCancun", func(t *testing.T) {
|
|
gspec := &Genesis{
|
|
Config: params.TestChainConfig,
|
|
Alloc: GenesisAlloc{},
|
|
BaseFee: big.NewInt(875000000),
|
|
Timestamp: 0, // Cancun is active at time 0
|
|
}
|
|
|
|
db := rawdb.NewMemoryDatabase()
|
|
tdb := triedb.NewDatabase(db, triedb.HashDefaults)
|
|
|
|
genesisBlock, err := gspec.Commit(db, tdb)
|
|
require.NoError(err)
|
|
|
|
// Check if header has Cancun fields
|
|
header := genesisBlock.Header()
|
|
t.Logf("Has ParentBeaconRoot: %v", header.ParentBeaconRoot != nil)
|
|
t.Logf("Has ExcessBlobGas: %v", header.ExcessBlobGas != nil)
|
|
t.Logf("Has BlobGasUsed: %v", header.BlobGasUsed != nil)
|
|
|
|
// Try to read it back
|
|
hash := genesisBlock.Hash()
|
|
readHeader := rawdb.ReadHeader(db, hash, 0)
|
|
if readHeader == nil {
|
|
t.Logf("FAIL: Cannot read header with Cancun fields")
|
|
} else {
|
|
t.Logf("SUCCESS: Can read header with Cancun fields")
|
|
}
|
|
|
|
// Try to create blockchain
|
|
engine := dummy.NewCoinbaseFaker()
|
|
chain, err := NewBlockChain(db, DefaultCacheConfig, gspec, engine, vm.Config{}, hash, false)
|
|
if err != nil {
|
|
t.Logf("FAIL: Cannot create blockchain with Cancun: %v", err)
|
|
} else {
|
|
t.Logf("SUCCESS: Created blockchain with Cancun")
|
|
chain.Stop()
|
|
}
|
|
})
|
|
|
|
// Test without Cancun
|
|
t.Run("WithoutCancun", func(t *testing.T) {
|
|
// TestDurangoChainConfig has Shanghai enabled but no Cancun/blob features
|
|
gspec := &Genesis{
|
|
Config: params.TestDurangoChainConfig,
|
|
Alloc: GenesisAlloc{},
|
|
BaseFee: big.NewInt(875000000),
|
|
Timestamp: 0,
|
|
}
|
|
|
|
db := rawdb.NewMemoryDatabase()
|
|
tdb := triedb.NewDatabase(db, triedb.HashDefaults)
|
|
|
|
genesisBlock, err := gspec.Commit(db, tdb)
|
|
require.NoError(err)
|
|
|
|
// Check if header has Cancun fields (should NOT have them)
|
|
header := genesisBlock.Header()
|
|
t.Logf("Has ParentBeaconRoot: %v (expected: false)", header.ParentBeaconRoot != nil)
|
|
t.Logf("Has ExcessBlobGas: %v (expected: false)", header.ExcessBlobGas != nil)
|
|
t.Logf("Has BlobGasUsed: %v (expected: false)", header.BlobGasUsed != nil)
|
|
|
|
// Try to read it back
|
|
hash := genesisBlock.Hash()
|
|
readHeader := rawdb.ReadHeader(db, hash, 0)
|
|
if readHeader == nil {
|
|
t.Logf("FAIL: Cannot read header without Cancun fields")
|
|
} else {
|
|
t.Logf("SUCCESS: Can read header without Cancun fields")
|
|
}
|
|
|
|
// Try to create blockchain
|
|
engine := dummy.NewCoinbaseFaker()
|
|
chain, err := NewBlockChain(db, DefaultCacheConfig, gspec, engine, vm.Config{}, hash, false)
|
|
if err != nil {
|
|
t.Logf("FAIL: Cannot create blockchain without Cancun: %v", err)
|
|
} else {
|
|
t.Logf("SUCCESS: Created blockchain without Cancun")
|
|
chain.Stop()
|
|
}
|
|
})
|
|
}
|