diff --git a/server/fork_integration_test.go b/server/fork_integration_test.go index 76a856b0..53ede4fc 100644 --- a/server/fork_integration_test.go +++ b/server/fork_integration_test.go @@ -69,11 +69,6 @@ func TestForkingAgainstTestnet(t *testing.T) { t.Fatalf("expected ChainID to be Testnet after fork detection, got %q", cfg.ChainID) } - // Create an initial local block so we have a valid reference block ID in the forked store - if _, _, err := srv.Emulator().ExecuteAndCommitBlock(); err != nil { - t.Fatalf("prime local block: %v", err) - } - // Submit a minimal transaction against the forked emulator to ensure tx processing works latest, err := srv.Emulator().GetLatestBlock() if err != nil { @@ -205,11 +200,6 @@ func TestForkingAgainstMainnet(t *testing.T) { t.Fatalf("expected ChainID to be Mainnet after fork detection, got %q", cfg.ChainID) } - // Create an initial local block so we have a valid reference block ID in the forked store - if _, _, err := srv.Emulator().ExecuteAndCommitBlock(); err != nil { - t.Fatalf("prime local block: %v", err) - } - // Test account key retrieval for a known mainnet account with multiple keys // This tests the account key deduplication shim by executing a script that accesses // keys and ensures no errors occur (successful execution proves the shim works) diff --git a/server/server.go b/server/server.go index 9c17725d..6f81770d 100644 --- a/server/server.go +++ b/server/server.go @@ -193,6 +193,19 @@ func NewEmulatorServer(logger *zerolog.Logger, conf *Config) *EmulatorServer { return nil } + // In fork mode, commit an initial reference block so transactions can be submitted immediately + if conf.ForkHost != "" { + block, _, err := emulatedBlockchain.ExecuteAndCommitBlock() + if err != nil { + logger.Error().Err(err).Msg("❗ Failed to commit initial reference block for fork mode") + return nil + } + logger.Info(). + Uint64("blockHeight", block.Height). + Str("blockID", block.ID().String()). + Msg("📦 Committed initial reference block for fork mode") + } + chain := emulatedBlockchain.GetChain() sc := systemcontracts.SystemContractsForChain(chain.ChainID())