From 869e5a22d96cc50a36953c27777070532ea01aae Mon Sep 17 00:00:00 2001 From: samliok Date: Mon, 17 Aug 2026 22:05:49 -0400 Subject: [PATCH] double start nit --- instance.go | 8 ++++++-- instance_test.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/instance.go b/instance.go index 39d82e3e..4a4fd8a7 100644 --- a/instance.go +++ b/instance.go @@ -5,6 +5,7 @@ package simplex import ( "context" + "errors" "fmt" "math" "sync" @@ -19,6 +20,8 @@ import ( "go.uber.org/zap" ) +var errAlreadyStarted = errors.New("instance already started") + const ( // tickInterval is the interval at which the instance will call AdvanceTime on the current epoch or non-validator. tickInterval = time.Millisecond * 100 @@ -34,6 +37,8 @@ type Config struct { PlatformChain PlatformChain // Broadcaster is the interface to broadcast messages to other nodes in the network. Broadcaster Broadcaster + // Sender is an interface to send messages to a specific node in the network + Sender Sender // CryptoOps is the interface to the cryptographic operations needed by the simplex instance. CryptoOps CryptoOps // WalCreator is the interface to create new write-ahead logs for the simplex instance. @@ -41,7 +46,6 @@ type Config struct { // Storage is the interface to the block storage layer for the simplex instance. Storage Storage Logger common.Logger - Sender Sender WALs []wal.DeletableWAL VM VM ICMETransition metadata.ICMEpochTransition @@ -94,7 +98,7 @@ func (i *Instance) Start(ctx context.Context) error { defer i.lock.Unlock() if i.started { - return fmt.Errorf("instance already started") + return errAlreadyStarted } i.started = true diff --git a/instance_test.go b/instance_test.go index 5d22517f..5ad935f4 100644 --- a/instance_test.go +++ b/instance_test.go @@ -612,7 +612,7 @@ func TestInstanceDoubleStartFails(t *testing.T) { require.NoError(t, inst.Start(t.Context())) t.Cleanup(inst.Stop) - require.ErrorContains(t, inst.Start(t.Context()), "instance already started") + require.ErrorIs(t, inst.Start(t.Context()), errAlreadyStarted) } func TestNonValidatorSkipsMSMVerification(t *testing.T) {